瀏覽代碼

fix keyboardHeight

lucky1213 4 年之前
父節點
當前提交
208f5fb4ea

+ 2
- 9
packages/zefyr/example/android/app/src/main/AndroidManifest.xml 查看文件

1
+
1
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
     package="com.zefyr.example">
3
     package="com.zefyr.example">
3
-
4
-    <!-- The INTERNET permission is required for development. Specifically,
5
-         flutter needs it to communicate with the running application
6
-         to allow setting breakpoints, to provide hot reload, etc.
7
-    -->
8
-    <uses-permission android:name="android.permission.INTERNET"/>
9
-
10
     <!-- io.flutter.app.FlutterApplication is an android.app.Application that
4
     <!-- io.flutter.app.FlutterApplication is an android.app.Application that
11
          calls FlutterMain.startInitialization(this); in its onCreate method.
5
          calls FlutterMain.startInitialization(this); in its onCreate method.
12
          In most cases you can leave this as-is, but you if you want to provide
6
          In most cases you can leave this as-is, but you if you want to provide
23
             android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
17
             android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
24
             android:hardwareAccelerated="true"
18
             android:hardwareAccelerated="true"
25
             android:windowSoftInputMode="adjustResize">
19
             android:windowSoftInputMode="adjustResize">
26
-            
27
             <intent-filter>
20
             <intent-filter>
28
                 <action android:name="android.intent.action.MAIN"/>
21
                 <action android:name="android.intent.action.MAIN"/>
29
                 <category android:name="android.intent.category.LAUNCHER"/>
22
                 <category android:name="android.intent.category.LAUNCHER"/>
35
             android:name="flutterEmbedding"
28
             android:name="flutterEmbedding"
36
             android:value="2" />
29
             android:value="2" />
37
     </application>
30
     </application>
38
-</manifest>
31
+</manifest>

+ 0
- 7
packages/zefyr/example/android/app/src/main/kotlin/com/zefyr/example/MainActivity.kt 查看文件

1
 package com.zefyr.example
1
 package com.zefyr.example
2
 
2
 
3
-import android.os.Bundle
4
-
5
-import io.flutter.app.FlutterActivity
6
 import androidx.annotation.NonNull;
3
 import androidx.annotation.NonNull;
7
 import io.flutter.embedding.android.FlutterActivity
4
 import io.flutter.embedding.android.FlutterActivity
8
 import io.flutter.embedding.engine.FlutterEngine
5
 import io.flutter.embedding.engine.FlutterEngine
9
 import io.flutter.plugins.GeneratedPluginRegistrant
6
 import io.flutter.plugins.GeneratedPluginRegistrant
10
 
7
 
11
 class MainActivity: FlutterActivity() {
8
 class MainActivity: FlutterActivity() {
12
-  override fun onCreate(savedInstanceState: Bundle?) {
13
-    super.onCreate(savedInstanceState)
14
-    GeneratedPluginRegistrant.registerWith(this)
15
-  }
16
     override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
9
     override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
17
         GeneratedPluginRegistrant.registerWith(flutterEngine);
10
         GeneratedPluginRegistrant.registerWith(flutterEngine);
18
     }
11
     }

+ 5
- 2
packages/zefyr/lib/src/widgets/editable_text.dart 查看文件

117
   void requestKeyboard() {
117
   void requestKeyboard() {
118
     final scope = ZefyrScope.of(context);
118
     final scope = ZefyrScope.of(context);
119
     if (_focusNode.hasFocus) {
119
     if (_focusNode.hasFocus) {
120
-      // var show = scope.overlayBuilder == null ? true : false;
121
-      _input.openConnection(widget.controller.plainTextEditingValue, widget.keyboardAppearance, showKeyboard: _focusNode.consumeKeyboardToken());
120
+      var show = _focusNode.consumeKeyboardToken();
121
+      if (MediaQuery.of(context).viewInsets.bottom == 0 && scope.toolbarAction == null) {
122
+        show = true;
123
+      }
124
+      _input.openConnection(widget.controller.plainTextEditingValue, widget.keyboardAppearance, showKeyboard: show);
122
     } else {
125
     } else {
123
       FocusScope.of(context).requestFocus(_focusNode);
126
       FocusScope.of(context).requestFocus(_focusNode);
124
     }
127
     }

+ 12
- 2
packages/zefyr/lib/src/widgets/toolbar.dart 查看文件

273
   }
273
   }
274
 
274
 
275
   void closeOverlay() {
275
   void closeOverlay() {
276
-    if (!hasOverlay) return;
276
+    if (!hasOverlay) {
277
+      editor.showKeyboard();
278
+      editor.keepOverlay = false;
279
+      return;
280
+    }
277
     _overlayAnimation.reverse().whenComplete(() async {
281
     _overlayAnimation.reverse().whenComplete(() async {
278
       setState(() {
282
       setState(() {
279
         _overlayBuilder = null;
283
         _overlayBuilder = null;
317
     switch (platform) {
321
     switch (platform) {
318
       case TargetPlatform.iOS:
322
       case TargetPlatform.iOS:
319
       case TargetPlatform.android:
323
       case TargetPlatform.android:
320
-        widget = hasOverlay ? buildButton(context, ZefyrToolbarAction.showKeyboard) : buildButton(context, ZefyrToolbarAction.hideKeyboard);
324
+        if (MediaQuery.of(context).viewInsets.bottom == 0) {
325
+          widget = buildButton(context, ZefyrToolbarAction.showKeyboard);
326
+        } else {
327
+          widget = buildButton(context, ZefyrToolbarAction.hideKeyboard);
328
+        }
329
+        // widget = hasOverlay ? buildButton(context, ZefyrToolbarAction.showKeyboard) : buildButton(context, ZefyrToolbarAction.hideKeyboard);
321
         break;
330
         break;
322
       default:
331
       default:
323
         break;
332
         break;
372
       autoImplyTrailing: false,
381
       autoImplyTrailing: false,
373
     );
382
     );
374
     layers.add(toolbar);
383
     layers.add(toolbar);
384
+    print(MediaQuery.of(context).viewInsets.bottom);
375
     if (hasOverlay) {
385
     if (hasOverlay) {
376
       Widget widget = Container(
386
       Widget widget = Container(
377
         height: keyboardHeight ?? 300,
387
         height: keyboardHeight ?? 300,