Browse Source

Revert "scrollview is not scrollable when using overlay in android (#4554)" (#4555)

This reverts commit db24ecd25d.
Guy Carmeli 5 years ago
parent
commit
8b738b0229
No account linked to committer's email address
1 changed files with 57 additions and 86 deletions
  1. 57
    86
      playground/src/screens/CustomTopBar.js

+ 57
- 86
playground/src/screens/CustomTopBar.js View File

@@ -1,91 +1,62 @@
1 1
 const React = require('react');
2
-const { PureComponent } = require('react');
3
-
4
-const { Text, Button, ScrollView, View, Alert, Platform } = require('react-native');
2
+const { Component } = require('react');
3
+const {
4
+  StyleSheet,
5
+  View,
6
+  TouchableOpacity,
7
+  Text,
8
+  Alert,
9
+  Platform
10
+} = require('react-native');
5 11
 const { Navigation } = require('react-native-navigation');
6 12
 
7
-const testIDs = require('../testIDs');
8
-
9
-class CustomDialog extends PureComponent {
10
-    static get 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
-    onCLickOk() {
38
-        Navigation.dismissOverlay(this.props.componentId);
39
-    }
40
-
41
-    onCLickSetRoot() {
42
-        Navigation.setRoot({
43
-            root: {
44
-                component: {
45
-                    name: 'navigation.playground.TextScreen'
46
-                }
47
-            }
48
-        });
49
-    }
50
-
51
-    onCLickSetInterceptTouch() {
52
-        Navigation.mergeOptions(this.props.componentId, {
53
-            overlay: {
54
-                interceptTouchOutside: false
55
-            }
56
-        });
57
-    }
13
+class CustomTopBar extends Component {
14
+
15
+  constructor(props) {
16
+    super(props);
17
+    this.state = {};
18
+    this.subscription = Navigation.events().bindComponent(this);
19
+  }
20
+
21
+  componentDidAppear() {
22
+    console.log('RNN', 'CTB.componentDidAppear');
23
+  }
24
+
25
+  componentDidDisappear() {
26
+    console.log('RNN', `CTB.componentDidDisappear`);
27
+  }
28
+
29
+  componentDidMount() {
30
+    console.log('RNN', `CTB.componentDidMount`);
31
+  }
32
+
33
+  componentWillUnmount() {
34
+    console.log('RNN', `CTB.componentWillUnmount`);
35
+    this.subscription.remove();
36
+  }
37
+
38
+  render() {
39
+    return (
40
+      <View style={styles.container}>
41
+        <TouchableOpacity onPress={() => Alert.alert(this.props.title, 'Thanks for that :)')}>
42
+          <Text style={styles.text}>Press Me</Text>
43
+        </TouchableOpacity>
44
+      </View>
45
+    );
46
+  }
58 47
 }
59 48
 
60
-const styles = {
61
-    root: {
62
-        width: 400,
63
-        height: 200,
64
-    },
65
-    container: {
66
-
67
-        width: 400,
68
-        height: 200,
69
-        flexDirection: 'column',
70
-        justifyContent: 'center',
71
-        alignItems: 'center',
72
-        alignSelf: 'center'
73
-    },
74
-    h1: {
75
-        fontSize: 24,
76
-        textAlign: 'center',
77
-        margin: 10
78
-    },
79
-    h2: {
80
-        fontSize: 12,
81
-        textAlign: 'center',
82
-        margin: 10
83
-    },
84
-    footer: {
85
-        fontSize: 10,
86
-        color: '#888',
87
-        marginTop: 10
88
-    }
89
-};
90
-
91
-module.exports = CustomDialog;
49
+module.exports = CustomTopBar;
50
+
51
+const styles = StyleSheet.create({
52
+  container: {
53
+    flex: 1,
54
+    flexDirection: 'column',
55
+    justifyContent: 'center',
56
+    alignSelf: 'center'
57
+  },
58
+  text: {
59
+    alignSelf: 'center',
60
+    color: 'black',
61
+  }
62
+});