fix(auth): 登录注册与手机号登录键盘避让
This commit is contained in:
1 parent
86588d7faa
commit
6c2f77926b
6 files changed
+332
-9
No files matched your search
@@ -1,8 +1,29 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// iOS 使用实时 viewInsets;Android adjustNothing 下取 MethodChannel 最大值。
|
||||
double effectiveKeyboardInset(
|
||||
BuildContext context,
|
||||
KeyboardInsetNotifier notifier, {
|
||||
double maxRatio = 0.6,
|
||||
}) {
|
||||
final media = MediaQuery.of(context);
|
||||
final viewInset = media.viewInsets.bottom;
|
||||
final channelInset =
|
||||
!kIsWeb && defaultTargetPlatform == TargetPlatform.android
|
||||
? notifier.value / media.devicePixelRatio
|
||||
: 0.0;
|
||||
final inset = math.max(viewInset, channelInset);
|
||||
final maxInset = media.size.height * maxRatio;
|
||||
if (!inset.isFinite || inset > maxInset) return 0;
|
||||
return math.max(0, inset);
|
||||
}
|
||||
|
||||
/// Provides the Android IME height even when `adjustNothing` keeps
|
||||
/// `MediaQuery.viewInsets` at zero.
|
||||
class KeyboardInsetNotifier extends ChangeNotifier {
|
||||
|
||||
Reference in new issue
Block a user