fix(auth): 登录注册与手机号登录键盘避让
This commit is contained in:
1 parent
86588d7faa
commit
6c2f77926b
6 files changed
+332
-9
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/remote/api_client.dart';
|
||||
@@ -97,6 +98,38 @@ void main() {
|
||||
expect(find.text('Enter a valid phone number'), findsOneWidget);
|
||||
expect(adapter.requests, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_code_above_ios_keyboard', (tester) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.view.viewInsets = const FakeViewPadding(bottom: 300);
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
addTearDown(tester.view.resetViewInsets);
|
||||
final adapter = FakeHttpAdapter(
|
||||
(_) async => FakeHttpResponse(
|
||||
jsonEncode({'code': 0, 'message': 'ok', 'data': null}),
|
||||
),
|
||||
);
|
||||
final auth = AuthController(
|
||||
AuthApi(ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter)),
|
||||
AuthSessionStore(),
|
||||
);
|
||||
await _pumpHost(tester, auth);
|
||||
await tester.tap(find.byKey(const Key('open-phone-sheet')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('auth-phone-code')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
tester.getBottomLeft(find.byKey(const Key('auth-phone-code'))).dy,
|
||||
lessThanOrEqualTo(844 - 300),
|
||||
);
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _pumpHost(WidgetTester tester, AuthController auth) {
|
||||
|
||||
Reference in new issue
Block a user