Pārlūkot izejas kodu

Remove SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN flag from root layout (#3654)

The flag was initially set to prevent the root layout from being pushed down when showing full screen modals.
This isn't the right approach and it also messed up keyboard handling.
To prevent the root layout from being pushed down in this scenario we should probably handle window insets
Guy Carmeli 6 gadus atpakaļ
vecāks
revīzija
fef4ef91b8
No account linked to committer's email address

+ 0
- 2
lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java Parādīt failu

8
 import android.support.annotation.Nullable;
8
 import android.support.annotation.Nullable;
9
 import android.support.v7.app.AppCompatActivity;
9
 import android.support.v7.app.AppCompatActivity;
10
 import android.view.KeyEvent;
10
 import android.view.KeyEvent;
11
-import android.view.View;
12
 
11
 
13
 import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
12
 import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
14
 import com.facebook.react.modules.core.PermissionAwareActivity;
13
 import com.facebook.react.modules.core.PermissionAwareActivity;
32
         super.onCreate(savedInstanceState);
31
         super.onCreate(savedInstanceState);
33
         navigator = new Navigator(this, new ChildControllersRegistry(), new ModalStack(this), new OverlayManager());
32
         navigator = new Navigator(this, new ChildControllersRegistry(), new ModalStack(this), new OverlayManager());
34
         getReactGateway().onActivityCreated(this);
33
         getReactGateway().onActivityCreated(this);
35
-        navigator.getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
36
         setContentView(navigator.getView());
34
         setContentView(navigator.getView());
37
     }
35
     }
38
 
36
 

+ 4
- 3
lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java Parādīt failu

103
     }
103
     }
104
 
104
 
105
     private void setDrawBehindStatusBar(View view, StatusBarOptions statusBar) {
105
     private void setDrawBehindStatusBar(View view, StatusBarOptions statusBar) {
106
-        ((MarginLayoutParams) view.getLayoutParams()).topMargin = statusBar.drawBehind.isFalseOrUndefined() ?
107
-                UiUtils.getStatusBarHeight(activity) :
108
-                0;
106
+        if (statusBar.visible.isFalse()) {
107
+            ((MarginLayoutParams) view.getLayoutParams()).topMargin = statusBar.drawBehind.isTrue() ?
108
+                    0 : UiUtils.getStatusBarHeight(activity);
109
+        }
109
     }
110
     }
110
 }
111
 }

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ChildController.java Parādīt failu

52
 
52
 
53
     protected boolean isRoot() {
53
     protected boolean isRoot() {
54
         return getParentController() == null &&
54
         return getParentController() == null &&
55
-               !(this instanceof Navigator) &&
55
+                !(this instanceof Navigator) &&
56
                 getView().getParent() != null;
56
                 getView().getParent() != null;
57
     }
57
     }
58
 }
58
 }

+ 0
- 32
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/NavigationActivityTest.java Parādīt failu

1
-package com.reactnativenavigation.viewcontrollers;
2
-
3
-import android.view.View;
4
-
5
-import com.reactnativenavigation.BaseTest;
6
-import com.reactnativenavigation.NavigationActivity;
7
-import com.reactnativenavigation.TestActivity;
8
-
9
-import org.junit.Test;
10
-import org.robolectric.android.controller.ActivityController;
11
-
12
-import static org.assertj.core.api.Java6Assertions.assertThat;
13
-
14
-public class NavigationActivityTest extends BaseTest {
15
-    private ActivityController<? extends NavigationActivity> controller;
16
-    private NavigationActivity uut;
17
-
18
-    @Override
19
-    public void beforeEach() {
20
-        controller = newActivityController(TestActivity.class);
21
-        uut = controller.get();
22
-    }
23
-
24
-    @Test
25
-    public void onCreate_setSystemUiVisibility() {
26
-        controller.setup();
27
-        assertThat(uut
28
-                .getNavigator()
29
-                .getView()
30
-                .getSystemUiVisibility()).isEqualTo(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
31
-    }
32
-}

+ 1
- 0
playground/android/app/src/main/AndroidManifest.xml Parādīt failu

12
         <activity
12
         <activity
13
             android:name=".MainActivity"
13
             android:name=".MainActivity"
14
             android:configChanges="orientation|screenSize|keyboard|keyboardHidden"
14
             android:configChanges="orientation|screenSize|keyboard|keyboardHidden"
15
+            android:windowSoftInputMode="adjustResize"
15
             android:label="@string/app_name"
16
             android:label="@string/app_name"
16
             android:launchMode="singleTask">
17
             android:launchMode="singleTask">
17
             <intent-filter>
18
             <intent-filter>

+ 85
- 0
playground/src/screens/KeyboardScreen.js Parādīt failu

1
+const React = require('react');
2
+const { Component } = require('react');
3
+const {
4
+  View,
5
+  ScrollView,
6
+  Dimensions,
7
+  StyleSheet,
8
+  Image,
9
+  Text,
10
+  Platform,
11
+  TouchableHighlight,
12
+  TextInput
13
+} = require('react-native');
14
+
15
+const testIDs = require('../testIDs');
16
+const Button = require('./Button');
17
+
18
+const { Navigation } = require('react-native-navigation');
19
+let screenWidth = Dimensions.get('window').width;
20
+const LOREM_IPSUM = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis' +
21
+                    'nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum' +
22
+                    'dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
23
+
24
+class KeyboardScreen extends Component {
25
+  static get options() {
26
+    return {
27
+      bottomTabs: {
28
+        drawBehind: true,
29
+      },
30
+      topBar: {
31
+        title: {
32
+          text: 'Keyboard'
33
+        }
34
+      }
35
+    };
36
+  }
37
+
38
+  render() {
39
+    return (
40
+      <View style={styles.root}>
41
+        <ScrollView>
42
+          <Image style={styles.image} source={require('../../img/2048.jpeg')} />
43
+          <Text style={{margin: 8}}>Keyboard e2e</Text>
44
+          <TextInput placeholder='Input 1'/>
45
+          <TextInput
46
+            placeholder='Input 2'
47
+            onFocus={this.hideTabs}
48
+            onBlur={this.showTabs}
49
+            />
50
+          {/* <Text>{LOREM_IPSUM}</Text> */}
51
+        </ScrollView>
52
+      </View>
53
+    );
54
+  }
55
+
56
+  hideTabs = () => {
57
+    Navigation.mergeOptions(this.props.componentId, {
58
+      bottomTabs: {
59
+        visible: false
60
+      }
61
+    });
62
+  }
63
+
64
+  showTabs = () => {
65
+    Navigation.mergeOptions(this.props.componentId, {
66
+      bottomTabs: {
67
+        visible: true
68
+      }
69
+    });
70
+  }
71
+}
72
+
73
+module.exports = KeyboardScreen;
74
+
75
+const styles = StyleSheet.create({
76
+  root: {
77
+    flex: 1,
78
+    backgroundColor: '#E3DCC3'
79
+  },
80
+  image: {
81
+    height: 400,
82
+    width: screenWidth,
83
+    resizeMode: 'cover'
84
+  }
85
+});

+ 2
- 0
playground/src/screens/index.js Parādīt failu

24
 const TopBarBackground = require('./TopBarBackground');
24
 const TopBarBackground = require('./TopBarBackground');
25
 const ComplexLayout = require('./ComplexLayout');
25
 const ComplexLayout = require('./ComplexLayout');
26
 const SearchScreen = require('./SearchScreen');
26
 const SearchScreen = require('./SearchScreen');
27
+const KeyboardScreen = require('./KeyboardScreen');
27
 
28
 
28
 function registerScreens() {
29
 function registerScreens() {
29
   Navigation.registerComponent(`navigation.playground.CustomTransitionDestination`, () => CustomTransitionDestination);
30
   Navigation.registerComponent(`navigation.playground.CustomTransitionDestination`, () => CustomTransitionDestination);
51
   Navigation.registerComponent('CustomRoundedButton', () => CustomRoundedButton);
52
   Navigation.registerComponent('CustomRoundedButton', () => CustomRoundedButton);
52
   Navigation.registerComponent('TopBarBackground', () => TopBarBackground);
53
   Navigation.registerComponent('TopBarBackground', () => TopBarBackground);
53
   Navigation.registerComponent('navigation.playground.SearchControllerScreen', () => SearchScreen);
54
   Navigation.registerComponent('navigation.playground.SearchControllerScreen', () => SearchScreen);
55
+  Navigation.registerComponent('navigation.playground.KeyboardScreen', () => KeyboardScreen);
54
 }
56
 }
55
 
57
 
56
 module.exports = {
58
 module.exports = {