-
-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bring Fabric to SearchBar (#1470)
* chore: add JS for SearchBar Component style props still have to be adjusted. Same for other props that are not implemented yet. * chore: add event types to codegen * chore: add iOS props to JS * chore: add Android only props to JS * chore: update interface for Fabric * chore: add enum conversion for autoCapitalization prop * chore: add props update (except colors) * chore: add componentDescriptorProvider & RNSSearchBarCls * chore: make event blocks Paper specific (in interface) * chore: make Fabric impl not emit any events (just for now) * fix: import ComponentDescriptors header * refact: extract common initialization code to initCommonProps * chore: create SearchButtonPressedEvent type * chore: create ChangeTextEvent type * chore: create event emitting methods * refact: make use of event emitting methods * chore: move #import RNSSearchBar.h statemets to common section This can be done now, as SearchBar should work on Fabric * refact: add TODO for missing props * chore: change ctor for Fabric in RNSSearchBarManager I don't exactly know if it is required but it should not break anything. If this change is useless we can restore it later. * chore: make RNSSearchbarManager#view method paper only * refact: update TODO comments * chore: move RNSScreen#hideHeaderIfNecessary method to common section This change was not tested. Usage of self.view.reactSubviews raises my concerns as I'm not sure if this property always holds correct state on Fabric * chore: remove message that SearchBar is not yer Fabric compatible * chore: udpate style for SearchBar component * feat: implement color-related props * chore: enable call to hideheaderIfNecessary * chore: add Test758 from TestExample * fix: weird merge artifact This if def was present on main & not on current branch, but after running `git merge main` git took the version of code from the current branch?! * chore: add Test758 to App.js
- Loading branch information
Showing
13 changed files
with
411 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import * as React from 'react'; | ||
import {Button, NativeSyntheticEvent, ScrollView} from 'react-native'; | ||
import { | ||
NavigationContainer, | ||
NavigationProp, | ||
ParamListBase, | ||
} from '@react-navigation/native'; | ||
import { | ||
createNativeStackNavigator, | ||
NativeStackScreenProps, | ||
} from 'react-native-screens/native-stack'; | ||
import {SearchBarProps} from 'react-native-screens'; | ||
|
||
const AppStack = createNativeStackNavigator(); | ||
|
||
export default function App(): JSX.Element { | ||
return ( | ||
<NavigationContainer> | ||
<AppStack.Navigator | ||
screenOptions={{ | ||
headerLargeTitle: true, | ||
headerTranslucent: false, | ||
}}> | ||
<AppStack.Screen name="First" component={First} /> | ||
<AppStack.Screen name="Second" component={Second} /> | ||
</AppStack.Navigator> | ||
</NavigationContainer> | ||
); | ||
} | ||
|
||
function First({navigation}: NativeStackScreenProps<ParamListBase>) { | ||
React.useLayoutEffect(() => { | ||
navigation.setOptions({ | ||
searchBar: searchBarOptions, | ||
}); | ||
}, [navigation]); | ||
|
||
const [search, setSearch] = React.useState(''); | ||
|
||
const searchBarOptions: SearchBarProps = { | ||
barTintColor: 'powderblue', | ||
tintColor: 'red', | ||
textColor: 'red', | ||
hideWhenScrolling: true, | ||
obscureBackground: false, | ||
hideNavigationBar: false, | ||
autoCapitalize: 'sentences', | ||
placeholder: 'Some text', | ||
cancelButtonText: 'Some text', | ||
onChangeText: (e: NativeSyntheticEvent<{text: string}>) => | ||
setSearch(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'), | ||
}; | ||
|
||
const items = [ | ||
'Apples', | ||
'Pie', | ||
'Juice', | ||
'Cake', | ||
'Nuggets', | ||
'Some', | ||
'Other', | ||
'Stuff', | ||
'To', | ||
'Fill', | ||
'The', | ||
'Scrolling', | ||
'Space', | ||
]; | ||
|
||
return ( | ||
<ScrollView | ||
contentInsetAdjustmentBehavior="automatic" | ||
keyboardDismissMode="on-drag"> | ||
<Button | ||
title="Tap me for second screen" | ||
onPress={() => navigation.navigate('Second')} | ||
/> | ||
{items | ||
.filter( | ||
(item) => item.toLowerCase().indexOf(search.toLowerCase()) !== -1, | ||
) | ||
.map((item) => ( | ||
<Button | ||
title={item} | ||
key={item} | ||
onPress={() => { | ||
console.warn(`${item} clicked`); | ||
}} | ||
/> | ||
))} | ||
</ScrollView> | ||
); | ||
} | ||
|
||
function Second({navigation}: {navigation: NavigationProp<ParamListBase>}) { | ||
return ( | ||
<ScrollView contentInsetAdjustmentBehavior="automatic"> | ||
<Button | ||
title="Tap me for first screen" | ||
onPress={() => navigation.navigate('First')} | ||
/> | ||
</ScrollView> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.