feat(flutter): 增加关键操作震动反馈
This commit is contained in:
1 parent
e609e3ad8d
commit
8a481d5c62
20 files changed
+308
-72
No files matched your search
@@ -9,6 +9,7 @@ import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
||||
import 'package:fruitshorts/core/data/services/auth_controller.dart';
|
||||
import 'package:fruitshorts/core/data/services/auth_session_store.dart';
|
||||
import 'package:fruitshorts/core/data/services/favorite_controller.dart';
|
||||
import 'package:fruitshorts/core/platform/haptics.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/favorites/favorites_page.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -16,6 +17,7 @@ import 'package:shared_preferences_platform_interface/in_memory_shared_preferenc
|
||||
import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
|
||||
|
||||
import '../support/fake_http_adapter.dart';
|
||||
import '../support/fake_haptics.dart';
|
||||
|
||||
Drama _card(String id) => Drama(
|
||||
id: id,
|
||||
@@ -58,11 +60,13 @@ void main() {
|
||||
cards: [_card('signal')],
|
||||
)..failRemove = true;
|
||||
final favorites = FavoriteController(repository);
|
||||
final haptics = FakeHaptics();
|
||||
|
||||
await _pumpPage(tester, auth: auth, favorites: favorites);
|
||||
await _pumpPage(tester, auth: auth, favorites: favorites, haptics: haptics);
|
||||
await tester.tap(find.byKey(const Key('favorite-remove-signal')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(haptics.lightImpacts, 1);
|
||||
expect(find.text('Drama signal'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Could not update favorites. Please retry.'),
|
||||
@@ -134,12 +138,14 @@ Future<void> _pumpPage(
|
||||
WidgetTester tester, {
|
||||
required AuthController auth,
|
||||
required FavoriteController favorites,
|
||||
FakeHaptics? haptics,
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<AuthController>.value(value: auth),
|
||||
ChangeNotifierProvider<FavoriteController>.value(value: favorites),
|
||||
Provider<Haptics>.value(value: haptics ?? FakeHaptics()),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
|
||||
Reference in new issue
Block a user