Browse Source

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 years ago
parent
commit
d565f39794

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/params/LightBoxParams.java View File

6
     public StyleParams.Color backgroundColor;
6
     public StyleParams.Color backgroundColor;
7
     public boolean tapBackgroundToDismiss;
7
     public boolean tapBackgroundToDismiss;
8
     public boolean overrideBackPress;
8
     public boolean overrideBackPress;
9
+    public int adjustSoftInput;
9
 }
10
 }

+ 33
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/LightBoxParamsParser.java View File

1
 package com.reactnativenavigation.params.parsers;
1
 package com.reactnativenavigation.params.parsers;
2
 
2
 
3
 import android.os.Bundle;
3
 import android.os.Bundle;
4
+import android.view.WindowManager;
5
+
4
 import com.reactnativenavigation.params.LightBoxParams;
6
 import com.reactnativenavigation.params.LightBoxParams;
5
 import com.reactnativenavigation.params.NavigationParams;
7
 import com.reactnativenavigation.params.NavigationParams;
6
 
8
 
21
         result.backgroundColor = getColor(params, "backgroundColor");
23
         result.backgroundColor = getColor(params, "backgroundColor");
22
         result.tapBackgroundToDismiss = params.getBoolean("tapBackgroundToDismiss");
24
         result.tapBackgroundToDismiss = params.getBoolean("tapBackgroundToDismiss");
23
         result.overrideBackPress = params.getBoolean("overrideBackPress");
25
         result.overrideBackPress = params.getBoolean("overrideBackPress");
26
+        result.adjustSoftInput = Adjustment.fromString(params.getString("adjustSoftInput")).value;
24
         return result;
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 View File

40
         createContent(activity, params);
40
         createContent(activity, params);
41
         setCancelable(cancelable);
41
         setCancelable(cancelable);
42
         getWindow().setWindowAnimations(android.R.style.Animation);
42
         getWindow().setWindowAnimations(android.R.style.Animation);
43
+        getWindow().setSoftInputMode(params.adjustSoftInput);
43
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
44
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
44
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
45
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
45
             getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
46
             getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

+ 2
- 1
docs/screen-api.md View File

104
  style: {
104
  style: {
105
    backgroundBlur: "dark", // 'dark' / 'light' / 'xlight' / 'none' - the type of blur on the background
105
    backgroundBlur: "dark", // 'dark' / 'light' / 'xlight' / 'none' - the type of blur on the background
106
    backgroundColor: "#ff000080" // tint color for the background, you can specify alpha here (optional)
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