From 9112700a2a080f57dcc7e6f005458adeaaa466e2 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Thu, 16 Mar 2023 10:50:03 +0100 Subject: [PATCH] feat: add `setText` command on SearchBar (#1739) ## Description Add `setText` native command to SearchBar imperative API. ## Changes Added the JS impl, native impl (both Android & iOS, Fabric & Paper), updated JS types & codegen specs. ## Test code and steps to reproduce `Test1097` in both `FabricTestExample` & `TestsExample` ## Checklist - [x] Included code example that can be used to test this change - [x] Updated TS types - [x] Updated documentation: - [x] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [x] Ensured that CI passes --- FabricTestExample/src/Test1097.tsx | 18 +++++++++++------- TestsExample/src/Test1097.tsx | 4 ++++ .../swmansion/rnscreens/CustomSearchView.kt | 6 +++--- .../swmansion/rnscreens/SearchBarManager.kt | 1 + .../com/swmansion/rnscreens/SearchBarView.kt | 4 ++++ guides/GUIDE_FOR_LIBRARY_AUTHORS.md | 1 + ios/RNSSearchBar.mm | 13 +++++++++++++ native-stack/README.md | 1 + src/fabric/SearchBarNativeComponent.ts | 9 ++++++++- src/index.native.tsx | 10 ++++++++++ src/types.tsx | 2 ++ 11 files changed, 58 insertions(+), 11 deletions(-) diff --git a/FabricTestExample/src/Test1097.tsx b/FabricTestExample/src/Test1097.tsx index 41ee101fa5..8c5a737932 100644 --- a/FabricTestExample/src/Test1097.tsx +++ b/FabricTestExample/src/Test1097.tsx @@ -146,20 +146,20 @@ function Third({navigation}: {navigation: NavigationProp}) { hideNavigationBar: false, autoCapitalize: 'sentences', placeholder: 'Some text', - onChangeText: (e: NativeSyntheticEvent<{text: string}>) => console.warn(`Text changed to ${e.nativeEvent.text}`), + onChangeText: (e: NativeSyntheticEvent<{text: string}>) => + console.warn(`Text changed to ${e.nativeEvent.text}`), onCancelButtonPress: () => console.warn('Cancel button pressed'), onSearchButtonPress: () => console.warn('Search button pressed'), onFocus: () => console.warn('onFocus event'), onBlur: () => console.warn('onBlur event'), - } + }; React.useEffect(() => { navigation.setOptions({ - searchBar: searchBarProps - }) + searchBar: searchBarProps, + }); }, [navigation]); - return ( }) { title="Focus search bar" onPress={() => searchBarRef.current?.focus()} /> -