Bladeren bron

scroll in overlay not working for android (#4557)

Added overlay with a ScrollView for testing purposes
eladgel 6 jaren geleden
bovenliggende
commit
54569eeeaf

+ 15
- 0
playground/src/screens/OptionsScreen.js Bestand weergeven

@@ -133,6 +133,7 @@ class OptionsScreen extends Component {
133 133
         <Button title='Custom Transition' testID={testIDs.CUSTOM_TRANSITION_BUTTON} onPress={this.onClickCustomTransition} />
134 134
         {Platform.OS === 'android' && <Button title='Hide fab' testID={testIDs.HIDE_FAB} onPress={this.onClickFab} />}
135 135
         <Button title='Show overlay' testID={testIDs.SHOW_OVERLAY_BUTTON} onPress={() => this.onClickShowOverlay(true)} />
136
+        <Button title='Show touch through overlay with scroll' testID={testIDs.SHOW_TOUCH_THROUGH_OVERLAY_SCROLLER} onPress={() => this.onClickShowOverlayWithScroll(true)} />
136 137
         <Button title='Show touch through overlay' testID={testIDs.SHOW_TOUCH_THROUGH_OVERLAY_BUTTON} onPress={() => this.onClickShowOverlay(false)} />
137 138
         <Button title='Push Default Options Screen' testID={testIDs.PUSH_DEFAULT_OPTIONS_BUTTON} onPress={this.onClickPushDefaultOptionsScreen} />
138 139
         <Button title='Show TopBar react view' testID={testIDs.SHOW_TOPBAR_REACT_VIEW} onPress={this.onShowTopBarReactView} />
@@ -277,6 +278,20 @@ class OptionsScreen extends Component {
277 278
     });
278 279
   }
279 280
 
281
+  onClickShowOverlayWithScroll = async (interceptTouchOutside) => {
282
+    await Navigation.showOverlay({
283
+      component: {
284
+        name: 'navigation.playground.CustomDialogWithScroll',
285
+        options: {
286
+          overlay: {
287
+            interceptTouchOutside
288
+          }
289
+        }
290
+      }
291
+    });
292
+  }
293
+
294
+
280 295
   onClickPushDefaultOptionsScreen = () => {
281 296
     Navigation.setDefaultOptions({
282 297
       topBar: {

+ 69
- 0
playground/src/screens/complexlayouts/CustomDialogWithScroll.js Bestand weergeven

@@ -0,0 +1,69 @@
1
+const React = require('react');
2
+const { PureComponent } = require('react');
3
+
4
+const { Text, Button, View, Alert, Platform ,ScrollView} = require('react-native');
5
+const { Navigation } = require('react-native-navigation');
6
+
7
+const testIDs = require('../../testIDs');
8
+
9
+class CustomDialogWithScroll extends PureComponent {
10
+    static options() {
11
+        return {
12
+            statusBarBackgroundColor: 'green'
13
+        };
14
+    }
15
+
16
+    render() {
17
+        return (
18
+            <View style={styles.container}>
19
+                <ScrollView style={styles.root}>
20
+                    <View style={{height: 60, backgroundColor: 'red'}}/>
21
+                    <View style={{height: 60, backgroundColor: 'green'}}/>
22
+                    <View style={{height: 60, backgroundColor: 'red'}}/>
23
+                    <View style={{height: 60, backgroundColor: 'green'}}/>
24
+                    <View style={{height: 60, backgroundColor: 'red'}}/>
25
+                    <View style={{height: 60, backgroundColor: 'green'}}/>
26
+                </ScrollView>
27
+            </View>
28
+        );
29
+    }
30
+
31
+    didDisappear() {
32
+        if (Platform.OS === 'android') {
33
+            Alert.alert('Overlay disappeared');
34
+        }
35
+    }
36
+}
37
+
38
+const styles = {
39
+    root: {
40
+        width: 400,
41
+        height: 200,
42
+    },
43
+    container: {
44
+
45
+        width: 400,
46
+        height: 200,
47
+        flexDirection: 'column',
48
+        justifyContent: 'center',
49
+        alignItems: 'center',
50
+        alignSelf: 'center'
51
+    },
52
+    h1: {
53
+        fontSize: 24,
54
+        textAlign: 'center',
55
+        margin: 10
56
+    },
57
+    h2: {
58
+        fontSize: 12,
59
+        textAlign: 'center',
60
+        margin: 10
61
+    },
62
+    footer: {
63
+        fontSize: 10,
64
+        color: '#888',
65
+        marginTop: 10
66
+    }
67
+};
68
+
69
+module.exports = CustomDialogWithScroll;

+ 2
- 0
playground/src/screens/index.js Bestand weergeven

@@ -13,6 +13,7 @@ const ScrollViewScreen = require('./ScrollViewScreen');
13 13
 const CustomTransitionOrigin = require('./CustomTransitionOrigin');
14 14
 const CustomTransitionDestination = require('./CustomTransitionDestination');
15 15
 const CustomDialog = require('./CustomDialog');
16
+const CustomDialogWithScroll = require('./complexlayouts/CustomDialogWithScroll');
16 17
 const BandHandlerScreen = require('./BackHandlerScreen');
17 18
 const SideMenuScreen = require('./SideMenuScreen');
18 19
 const TopTabScreen = require('./TopTabScreen');
@@ -50,6 +51,7 @@ function registerScreens() {
50 51
   Navigation.registerComponent(`navigation.playground.OrientationSelectScreen`, () => OrientationSelectScreen);
51 52
   Navigation.registerComponent(`navigation.playground.OrientationDetectScreen`, () => OrientationDetectScreen);
52 53
   Navigation.registerComponent('navigation.playground.CustomDialog', () => CustomDialog);
54
+  Navigation.registerComponent('navigation.playground.CustomDialogWithScroll', () => CustomDialogWithScroll);
53 55
   Navigation.registerComponent('navigation.playground.BackHandlerScreen', () => BandHandlerScreen);
54 56
   Navigation.registerComponent('navigation.playground.SideMenuScreen', () => SideMenuScreen);
55 57
   Navigation.registerComponent('navigation.playground.TopTabScreen', () => TopTabScreen);

+ 1
- 0
playground/src/testIDs.js Bestand weergeven

@@ -59,6 +59,7 @@ module.exports = {
59 59
   SECOND_TAB_BAR_BUTTON: `SECOND_TAB_BAR_BUTTON`,
60 60
   THIRD_TAB_BAR_BUTTON: `THIRD_TAB_BAR_BUTTON`,
61 61
   SHOW_OVERLAY_BUTTON: `SHOW_OVERLAY_BUTTON`,
62
+  SHOW_TOUCH_THROUGH_OVERLAY_SCROLLER: `SHOW_TOUCH_THROUGH_OVERLAY_SCROLLER`,
62 63
   SHOW_TOUCH_THROUGH_OVERLAY_BUTTON: `SHOW_TOUCH_THROUGH_OVERLAY_BUTTON`,
63 64
   OK_BUTTON: `OK_BUTTON`,
64 65
   MODAL_WITH_STACK_BUTTON: `MODAL_WITH_STACK_BUTTON`,