CupertinoTabBar: Add clickable cursor on web (#96996)
This commit is contained in:
parent
66826e8fef
commit
4f7d7b5619
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
import 'dart:ui' show ImageFilter;
|
import 'dart:ui' show ImageFilter;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
@ -235,6 +237,8 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
tabIndex: index + 1,
|
tabIndex: index + 1,
|
||||||
tabCount: items.length,
|
tabCount: items.length,
|
||||||
),
|
),
|
||||||
|
child: MouseRegion(
|
||||||
|
cursor: kIsWeb ? SystemMouseCursors.click : MouseCursor.defer,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: onTap == null ? null : () { onTap!(index); },
|
onTap: onTap == null ? null : () { onTap!(index); },
|
||||||
@ -248,6 +252,7 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
active: active,
|
active: active,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
@ -568,4 +570,41 @@ Future<void> main() async {
|
|||||||
decoratedBoxHiddenBorder.decoration as BoxDecoration;
|
decoratedBoxHiddenBorder.decoration as BoxDecoration;
|
||||||
expect(boxDecorationHiddenBorder.border, isNull);
|
expect(boxDecorationHiddenBorder.border, isNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Hovering over tab bar item updates cursor to clickable on Web', (WidgetTester tester) async {
|
||||||
|
await pumpWidgetWithBoilerplate(
|
||||||
|
tester,
|
||||||
|
MediaQuery(
|
||||||
|
data: const MediaQueryData(),
|
||||||
|
child: Center(
|
||||||
|
child: CupertinoTabBar(
|
||||||
|
items: const <BottomNavigationBarItem>[
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(CupertinoIcons.alarm),
|
||||||
|
label: 'Tab 1',
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(CupertinoIcons.app_badge),
|
||||||
|
label: 'Tab 2',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse, pointer: 1);
|
||||||
|
await gesture.addPointer(location: const Offset(10, 10));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||||
|
|
||||||
|
final Offset tabItem = tester.getCenter(find.text('Tab 1'));
|
||||||
|
await gesture.moveTo(tabItem);
|
||||||
|
addTearDown(gesture.removePointer);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
|
||||||
|
kIsWeb ? SystemMouseCursors.click : SystemMouseCursors.basic,
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user