-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pause monitoring * updated options
- Loading branch information
Showing
5 changed files
with
121 additions
and
40 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
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 |
---|---|---|
@@ -1,57 +1,131 @@ | ||
import React from 'react'; | ||
import { View, Image, TextInput, StyleSheet } from 'react-native'; | ||
import { | ||
View, | ||
Image, | ||
TextInput, | ||
StyleSheet, | ||
Modal, | ||
Text, | ||
TouchableWithoutFeedback, | ||
TouchableOpacity, | ||
} from 'react-native'; | ||
|
||
import Button from './Button'; | ||
import { Theme, useThemedStyles, useTheme } from '../theme'; | ||
|
||
interface Props { | ||
value: string; | ||
onChangeText(text: string): void; | ||
options: { text: string; onPress: () => void }[]; | ||
} | ||
|
||
const SearchBar: React.FC<Props> = ({ value, onChangeText }) => { | ||
const SearchBar: React.FC<Props> = ({ options, value, onChangeText }) => { | ||
const styles = useThemedStyles(themedStyles); | ||
const theme = useTheme(); | ||
const [openOptions, setOpenOptions] = React.useState(false); | ||
|
||
return ( | ||
<View style={styles.searchContainer}> | ||
<Image | ||
source={require('./search.png')} | ||
resizeMode="contain" | ||
style={styles.searchIcon} | ||
/> | ||
<TextInput | ||
onChangeText={onChangeText} | ||
value={value} | ||
placeholder="Filter URLs" | ||
underlineColorAndroid="transparent" | ||
style={styles.textInputSearch} | ||
placeholderTextColor={theme.colors.muted} | ||
/> | ||
<View style={styles.searchBar}> | ||
<Image | ||
source={require('./search.png')} | ||
resizeMode="contain" | ||
style={styles.icon} | ||
/> | ||
<TextInput | ||
onChangeText={onChangeText} | ||
value={value} | ||
placeholder="Filter URLs" | ||
underlineColorAndroid="transparent" | ||
style={styles.textInputSearch} | ||
placeholderTextColor={theme.colors.muted} | ||
/> | ||
</View> | ||
<TouchableOpacity | ||
style={styles.menu} | ||
onPress={() => setOpenOptions((prev) => !prev)} | ||
> | ||
<Image | ||
source={require('./more.png')} | ||
resizeMode="contain" | ||
style={styles.icon} | ||
/> | ||
</TouchableOpacity> | ||
<Modal | ||
visible={openOptions} | ||
animationType="fade" | ||
transparent={true} | ||
onDismiss={() => setOpenOptions(false)} | ||
onRequestClose={() => setOpenOptions(false)} | ||
> | ||
<View style={styles.modalRoot}> | ||
<TouchableWithoutFeedback onPress={() => setOpenOptions(false)}> | ||
<View style={styles.backdrop} /> | ||
</TouchableWithoutFeedback> | ||
<View style={styles.modalContent}> | ||
<Text style={styles.title}>Options</Text> | ||
{options.map(({ text, onPress }) => ( | ||
<Button key={text} onPress={onPress}> | ||
{text} | ||
</Button> | ||
))} | ||
</View> | ||
</View> | ||
</Modal> | ||
</View> | ||
); | ||
}; | ||
|
||
const themedStyles = (theme: Theme) => | ||
StyleSheet.create({ | ||
searchContainer: { | ||
searchBar: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
paddingHorizontal: 10, | ||
margin: 5, | ||
borderWidth: 1, | ||
borderColor: theme.colors.muted, | ||
borderRadius: 20, | ||
flex: 1, | ||
}, | ||
modalRoot: { | ||
...StyleSheet.absoluteFillObject, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
flex: 1, | ||
}, | ||
modalContent: { | ||
borderRadius: 8, | ||
padding: 16, | ||
maxWidth: '100%', | ||
backgroundColor: 'white', | ||
}, | ||
searchIcon: { | ||
backdrop: { | ||
...StyleSheet.absoluteFillObject, | ||
backgroundColor: 'rgba(0,0,0,0.5)', | ||
}, | ||
icon: { | ||
width: 20, | ||
height: 20, | ||
marginRight: 10, | ||
alignSelf: 'center', | ||
}, | ||
textInputSearch: { | ||
height: 30, | ||
padding: 0, | ||
flexGrow: 1, | ||
color: theme.colors.text, | ||
}, | ||
searchContainer: { | ||
flexDirection: 'row', | ||
}, | ||
menu: { alignSelf: 'center' }, | ||
title: { | ||
fontSize: 20, | ||
paddingBottom: 10, | ||
fontWeight: 'bold', | ||
textAlign: 'center', | ||
}, | ||
}); | ||
|
||
export default SearchBar; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.