feat(flutter): 增加关键操作震动反馈
This commit is contained in:
1 parent
e609e3ad8d
commit
8a481d5c62
20 files changed
+308
-72
No files matched your search
@@ -11,10 +11,12 @@ import 'package:fruitshorts/core/data/remote/auth_api.dart';
|
||||
import 'package:fruitshorts/core/data/remote/api_client.dart';
|
||||
import 'package:fruitshorts/core/data/services/auth_controller.dart';
|
||||
import 'package:fruitshorts/core/data/services/auth_session_store.dart';
|
||||
import 'package:fruitshorts/core/platform/haptics.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/auth/auth_view.dart';
|
||||
|
||||
import '../support/fake_http_adapter.dart';
|
||||
import '../support/fake_haptics.dart';
|
||||
|
||||
/// 登录/注册页的可读证据:校验提示 + 登录/注册切换 + 未登录时不会去发请求。
|
||||
void main() {
|
||||
@@ -27,6 +29,7 @@ void main() {
|
||||
WidgetTester tester, {
|
||||
bool signUp = false,
|
||||
AuthApi? api,
|
||||
FakeHaptics? haptics,
|
||||
}) async {
|
||||
final auth = AuthController(
|
||||
api ??
|
||||
@@ -42,8 +45,11 @@ void main() {
|
||||
AuthSessionStore(),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
ChangeNotifierProvider<AuthController>.value(
|
||||
value: auth,
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<AuthController>.value(value: auth),
|
||||
Provider<Haptics>.value(value: haptics ?? FakeHaptics()),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -168,7 +174,8 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
final api = _PendingAuthApi();
|
||||
await pumpAuthPage(tester, api: api);
|
||||
final haptics = FakeHaptics();
|
||||
await pumpAuthPage(tester, api: api, haptics: haptics);
|
||||
await tester.enterText(find.byKey(const Key('auth-email')), 'a@b.com');
|
||||
await tester.enterText(find.byKey(const Key('auth-password')), 'abcd1234');
|
||||
await tester.tap(find.byKey(const Key('auth-password')));
|
||||
@@ -176,6 +183,7 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(api.loginCalls, 1);
|
||||
expect(haptics.lightImpacts, 1);
|
||||
expect(
|
||||
tester.widget<TextField>(find.byKey(const Key('auth-email'))).enabled,
|
||||
isFalse,
|
||||
|
||||
Reference in new issue
Block a user