Преглед на файлове

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

Dima Loktev преди 6 години
родител
ревизия
21e1bf353e
променени са 2 файла, в които са добавени 25 реда и са изтрити 3 реда
  1. 3
    0
      lib/ios/RNNTopBarOptions.m
  2. 22
    3
      playground/src/screens/SearchScreen.js

+ 3
- 0
lib/ios/RNNTopBarOptions.m Целия файл

@@ -46,6 +46,9 @@ extern const NSInteger BLUR_TOPBAR_TAG;
46 46
 			viewController.navigationItem.searchController = search;
47 47
 			// enable it back if needed on componentDidAppear
48 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 Целия файл

@@ -7,6 +7,7 @@ const {
7 7
   View,
8 8
   Button,
9 9
   Text,
10
+  TouchableOpacity,
10 11
   Platform
11 12
 } = require('react-native');
12 13
 
@@ -26,7 +27,6 @@ class SearchControllerScreen extends Component {
26 27
           visible: true
27 28
         },
28 29
         searchBar: true,
29
-        searchBarHiddenWhenScrolling: true,
30 30
         translucent: true,
31 31
         searchBarPlaceholder: 'Start Typing'
32 32
       }
@@ -63,6 +63,25 @@ class SearchControllerScreen extends Component {
63 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 85
   render() {
67 86
     return (
68 87
       <FlatList
@@ -70,11 +89,11 @@ class SearchControllerScreen extends Component {
70 89
         data={this.filteredData()}
71 90
         contentContainerStyle={styles.contentContainer}
72 91
         renderItem={({ item }) => (
73
-          <View style={styles.row}>
92
+          <TouchableOpacity style={styles.row} onPress={this.onItemPressed}>
74 93
             <Text style={styles.rowText} testID={testIDs.SEARCH_RESULT_ITEM}>
75 94
               {this.highlight(item.key, this.state.query)}
76 95
             </Text>
77
-          </View>
96
+          </TouchableOpacity>
78 97
         )}
79 98
       />
80 99
     );