Browse Source

Fix #3450: change presentation context when SearchBar activated (#3501)

Dima Loktev 6 years ago
parent
commit
21e1bf353e
2 changed files with 25 additions and 3 deletions
  1. 3
    0
      lib/ios/RNNTopBarOptions.m
  2. 22
    3
      playground/src/screens/SearchScreen.js

+ 3
- 0
lib/ios/RNNTopBarOptions.m View File

46
 			viewController.navigationItem.searchController = search;
46
 			viewController.navigationItem.searchController = search;
47
 			// enable it back if needed on componentDidAppear
47
 			// enable it back if needed on componentDidAppear
48
 			viewController.navigationItem.hidesSearchBarWhenScrolling = NO;
48
 			viewController.navigationItem.hidesSearchBarWhenScrolling = NO;
49
+			
50
+			// Fixes #3450, otherwise, UIKit will infer the presentation context to be the root most view controller
51
+			viewController.definesPresentationContext = YES;
49
 		}
52
 		}
50
 	}
53
 	}
51
 	
54
 	

+ 22
- 3
playground/src/screens/SearchScreen.js View File

7
   View,
7
   View,
8
   Button,
8
   Button,
9
   Text,
9
   Text,
10
+  TouchableOpacity,
10
   Platform
11
   Platform
11
 } = require('react-native');
12
 } = require('react-native');
12
 
13
 
26
           visible: true
27
           visible: true
27
         },
28
         },
28
         searchBar: true,
29
         searchBar: true,
29
-        searchBarHiddenWhenScrolling: true,
30
         translucent: true,
30
         translucent: true,
31
         searchBarPlaceholder: 'Start Typing'
31
         searchBarPlaceholder: 'Start Typing'
32
       }
32
       }
63
     return text;
63
     return text;
64
   }
64
   }
65
 
65
 
66
+  onItemPressed = () => {
67
+    Navigation.push(this.props.componentId, {
68
+      component: {
69
+        name: 'navigation.playground.PushedScreen',
70
+        options: {
71
+          topBar: {
72
+            title: {
73
+              text: 'PushedScreen'
74
+            },
75
+            largeTitle: {
76
+              visible: true
77
+            },
78
+            translucent: true,
79
+          }
80
+        }
81
+      },
82
+    });
83
+  }
84
+
66
   render() {
85
   render() {
67
     return (
86
     return (
68
       <FlatList
87
       <FlatList
70
         data={this.filteredData()}
89
         data={this.filteredData()}
71
         contentContainerStyle={styles.contentContainer}
90
         contentContainerStyle={styles.contentContainer}
72
         renderItem={({ item }) => (
91
         renderItem={({ item }) => (
73
-          <View style={styles.row}>
92
+          <TouchableOpacity style={styles.row} onPress={this.onItemPressed}>
74
             <Text style={styles.rowText} testID={testIDs.SEARCH_RESULT_ITEM}>
93
             <Text style={styles.rowText} testID={testIDs.SEARCH_RESULT_ITEM}>
75
               {this.highlight(item.key, this.state.query)}
94
               {this.highlight(item.key, this.state.query)}
76
             </Text>
95
             </Text>
77
-          </View>
96
+          </TouchableOpacity>
78
         )}
97
         )}
79
       />
98
       />
80
     );
99
     );