Pārlūkot izejas kodu

Show controls on mouse hover

Ben Hagen 6 gadi atpakaļ
vecāks
revīzija
4a2163da44
2 mainītis faili ar 38 papildinājumiem un 28 dzēšanām
  1. 15 10
      lib/src/cupertino_controls.dart
  2. 23 18
      lib/src/material_controls.dart

+ 15 - 10
lib/src/cupertino_controls.dart

@@ -65,18 +65,23 @@ class _CupertinoControlsState extends State<CupertinoControls> {
     final barHeight = orientation == Orientation.portrait ? 30.0 : 47.0;
     final barHeight = orientation == Orientation.portrait ? 30.0 : 47.0;
     final buttonPadding = orientation == Orientation.portrait ? 16.0 : 24.0;
     final buttonPadding = orientation == Orientation.portrait ? 16.0 : 24.0;
 
 
-    return GestureDetector(
-      onTap: () {
+    return MouseRegion(
+      onHover: (_) {
         _cancelAndRestartTimer();
         _cancelAndRestartTimer();
       },
       },
-      child: AbsorbPointer(
-        absorbing: _hideStuff,
-        child: Column(
-          children: <Widget>[
-            _buildTopBar(backgroundColor, iconColor, barHeight, buttonPadding),
-            _buildHitArea(),
-            _buildBottomBar(backgroundColor, iconColor, barHeight),
-          ],
+      child: GestureDetector(
+        onTap: () {
+          _cancelAndRestartTimer();
+        },
+        child: AbsorbPointer(
+          absorbing: _hideStuff,
+          child: Column(
+            children: <Widget>[
+              _buildTopBar(backgroundColor, iconColor, barHeight, buttonPadding),
+              _buildHitArea(),
+              _buildBottomBar(backgroundColor, iconColor, barHeight),
+            ],
+          ),
         ),
         ),
       ),
       ),
     );
     );

+ 23 - 18
lib/src/material_controls.dart

@@ -48,24 +48,29 @@ class _MaterialControlsState extends State<MaterialControls> {
             );
             );
     }
     }
 
 
-    return GestureDetector(
-      onTap: () => _cancelAndRestartTimer(),
-      child: AbsorbPointer(
-        absorbing: _hideStuff,
-        child: Column(
-          children: <Widget>[
-            _latestValue != null &&
-                        !_latestValue.isPlaying &&
-                        _latestValue.duration == null ||
-                    _latestValue.isBuffering
-                ? const Expanded(
-                    child: const Center(
-                      child: const CircularProgressIndicator(),
-                    ),
-                  )
-                : _buildHitArea(),
-            _buildBottomBar(context),
-          ],
+    return MouseRegion(
+      onHover: (_) {
+        _cancelAndRestartTimer();
+      },
+      child: GestureDetector(
+        onTap: () => _cancelAndRestartTimer(),
+        child: AbsorbPointer(
+          absorbing: _hideStuff,
+          child: Column(
+            children: <Widget>[
+              _latestValue != null &&
+                          !_latestValue.isPlaying &&
+                          _latestValue.duration == null ||
+                      _latestValue.isBuffering
+                  ? const Expanded(
+                      child: const Center(
+                        child: const CircularProgressIndicator(),
+                      ),
+                    )
+                  : _buildHitArea(),
+              _buildBottomBar(context),
+            ],
+          ),
         ),
         ),
       ),
       ),
     );
     );