Explorar el Código

fix keyboardHeight

lucky1213 hace 4 años
padre
commit
208f5fb4ea

+ 2
- 9
packages/zefyr/example/android/app/src/main/AndroidManifest.xml Ver fichero

@@ -1,12 +1,6 @@
1
+
1 2
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2 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 4
     <!-- io.flutter.app.FlutterApplication is an android.app.Application that
11 5
          calls FlutterMain.startInitialization(this); in its onCreate method.
12 6
          In most cases you can leave this as-is, but you if you want to provide
@@ -23,7 +17,6 @@
23 17
             android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
24 18
             android:hardwareAccelerated="true"
25 19
             android:windowSoftInputMode="adjustResize">
26
-            
27 20
             <intent-filter>
28 21
                 <action android:name="android.intent.action.MAIN"/>
29 22
                 <category android:name="android.intent.category.LAUNCHER"/>
@@ -35,4 +28,4 @@
35 28
             android:name="flutterEmbedding"
36 29
             android:value="2" />
37 30
     </application>
38
-</manifest>
31
+</manifest>

+ 0
- 7
packages/zefyr/example/android/app/src/main/kotlin/com/zefyr/example/MainActivity.kt Ver fichero

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

+ 5
- 2
packages/zefyr/lib/src/widgets/editable_text.dart Ver fichero

@@ -117,8 +117,11 @@ class ZefyrEditableTextState extends State<ZefyrEditableText>
117 117
   void requestKeyboard() {
118 118
     final scope = ZefyrScope.of(context);
119 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 125
     } else {
123 126
       FocusScope.of(context).requestFocus(_focusNode);
124 127
     }

+ 12
- 2
packages/zefyr/lib/src/widgets/toolbar.dart Ver fichero

@@ -273,7 +273,11 @@ class ZefyrToolbarState extends State<ZefyrToolbar>
273 273
   }
274 274
 
275 275
   void closeOverlay() {
276
-    if (!hasOverlay) return;
276
+    if (!hasOverlay) {
277
+      editor.showKeyboard();
278
+      editor.keepOverlay = false;
279
+      return;
280
+    }
277 281
     _overlayAnimation.reverse().whenComplete(() async {
278 282
       setState(() {
279 283
         _overlayBuilder = null;
@@ -317,7 +321,12 @@ class ZefyrToolbarState extends State<ZefyrToolbar>
317 321
     switch (platform) {
318 322
       case TargetPlatform.iOS:
319 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 330
         break;
322 331
       default:
323 332
         break;
@@ -372,6 +381,7 @@ class ZefyrToolbarState extends State<ZefyrToolbar>
372 381
       autoImplyTrailing: false,
373 382
     );
374 383
     layers.add(toolbar);
384
+    print(MediaQuery.of(context).viewInsets.bottom);
375 385
     if (hasOverlay) {
376 386
       Widget widget = Container(
377 387
         height: keyboardHeight ?? 300,