Преглед изворни кода

add adjust soft input optional config for Lightbox on android platform (#1697)

* add adjust soft input optional config for Lightbox on android platform

* Add doc about adjustSoftInput for showLightBox
simin.chen пре 7 година
родитељ
комит
d565f39794

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/params/LightBoxParams.java Прегледај датотеку

@@ -6,4 +6,5 @@ public class LightBoxParams {
6 6
     public StyleParams.Color backgroundColor;
7 7
     public boolean tapBackgroundToDismiss;
8 8
     public boolean overrideBackPress;
9
+    public int adjustSoftInput;
9 10
 }

+ 33
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/LightBoxParamsParser.java Прегледај датотеку

@@ -1,6 +1,8 @@
1 1
 package com.reactnativenavigation.params.parsers;
2 2
 
3 3
 import android.os.Bundle;
4
+import android.view.WindowManager;
5
+
4 6
 import com.reactnativenavigation.params.LightBoxParams;
5 7
 import com.reactnativenavigation.params.NavigationParams;
6 8
 
@@ -21,6 +23,37 @@ public class LightBoxParamsParser extends Parser {
21 23
         result.backgroundColor = getColor(params, "backgroundColor");
22 24
         result.tapBackgroundToDismiss = params.getBoolean("tapBackgroundToDismiss");
23 25
         result.overrideBackPress = params.getBoolean("overrideBackPress");
26
+        result.adjustSoftInput = Adjustment.fromString(params.getString("adjustSoftInput")).value;
24 27
         return result;
25 28
     }
29
+
30
+    public enum Adjustment {
31
+        NOTHING("nothing", WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING),
32
+        PAN("pan", WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN),
33
+        RESIZE("resize", WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE),
34
+        UNSPECIFIED("unspecified", WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
35
+
36
+        private String name;
37
+        private int value;
38
+
39
+        Adjustment(String name, int value) {
40
+            this.name = name;
41
+            this.value = value;
42
+        }
43
+
44
+        @Override
45
+        public String toString() {
46
+            return name;
47
+        }
48
+
49
+        public static Adjustment fromString(String name) {
50
+            for (Adjustment adjustment : values()) {
51
+                if (adjustment.name.equals(name)) {
52
+                    return adjustment;
53
+                }
54
+            }
55
+            return UNSPECIFIED;
56
+        }
57
+
58
+    }
26 59
 }

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/views/LightBox.java Прегледај датотеку

@@ -40,6 +40,7 @@ public class LightBox extends Dialog implements DialogInterface.OnDismissListene
40 40
         createContent(activity, params);
41 41
         setCancelable(cancelable);
42 42
         getWindow().setWindowAnimations(android.R.style.Animation);
43
+        getWindow().setSoftInputMode(params.adjustSoftInput);
43 44
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
44 45
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
45 46
             getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

+ 2
- 1
docs/screen-api.md Прегледај датотеку

@@ -104,7 +104,8 @@ this.props.navigator.showLightBox({
104 104
  style: {
105 105
    backgroundBlur: "dark", // 'dark' / 'light' / 'xlight' / 'none' - the type of blur on the background
106 106
    backgroundColor: "#ff000080" // tint color for the background, you can specify alpha here (optional)
107
- }
107
+ },
108
+ adjustSoftInput: "resize", // android only, adjust soft input, modes: 'nothing', 'pan', 'resize', 'unspecified' (optional, default 'unspecified')
108 109
 });
109 110
 ```
110 111