Skip to content

Commit

Permalink
Remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Soopyboo32 committed Oct 8, 2024
1 parent aba1657 commit 9e791a0
Showing 1 changed file with 78 additions and 12 deletions.
90 changes: 78 additions & 12 deletions src/screens/BrowseSourceScreen/components/FilterBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { getValueFor } from './filterUtils';
import { getString } from '@strings/translations';
import { ThemeColors } from '@theme/types';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { SwitchItem } from '@components';
import Switch from '@components/Switch/Switch';

const insertOrRemoveIntoArray = (array: string[], val: string): string[] =>
array.indexOf(val) > -1 ? array.filter(ele => ele !== val) : [...array, val];
Expand Down Expand Up @@ -57,23 +57,39 @@ const FilterItem: React.FC<FilterItemProps> = ({
setFalse: closeCard,
} = useBoolean();
const { width: screenWidth } = useWindowDimensions();
if (filter.type === FilterTypes.Switch) {
if (filter.type === FilterTypes.TextInput) {
const value = getValueFor<(typeof filter)['type']>(
filter,
selectedFilters[filterKey],
);
return (
<View style={styles.switchContainer}>
<SwitchItem
theme={theme}
label={filter.label}
onPress={() => {
<View style={styles.textContainer}>
<TextInput
style={{ flex: 1, width: screenWidth - 48 }}
mode="outlined"
label={
<Text
style={[
styles.label,
{
color: theme.onSurface,
backgroundColor: overlay(2, theme.surface),
},
]}
>
{` ${filter.label} `}
</Text>
}
defaultValue={value}
theme={{ colors: { background: 'transparent' } }}
outlineColor={theme.onSurface}
textColor={theme.onSurface}
onChangeText={text =>
setSelectedFilters(prevState => ({
...prevState,
[filterKey]: { value: !value, type: FilterTypes.Switch },
}));
}}
value={value}
[filterKey]: { value: text, type: FilterTypes.TextInput },
}))
}
/>
</View>
);
Expand Down Expand Up @@ -105,7 +121,7 @@ const FilterItem: React.FC<FilterItemProps> = ({
styles.label,
{
color: isVisible ? theme.primary : theme.onSurface,
backgroundColor: theme.surface,
backgroundColor: overlay(2, theme.surface),
},
]}
>
Expand Down Expand Up @@ -187,6 +203,42 @@ const FilterItem: React.FC<FilterItemProps> = ({
</View>
);
}
if (filter.type === FilterTypes.Switch) {
const value = getValueFor<(typeof filter)['type']>(
filter,
selectedFilters[filterKey],
);
return (
<Pressable
android_ripple={{ color: theme.rippleColor }}
style={[styles.container]}
onPress={() => {
setSelectedFilters(prevState => ({
...prevState,
[filterKey]: { value: !value, type: FilterTypes.Switch },
}));
}}
>
<View style={styles.switchContainer}>
<View style={styles.switchLabelContainer}>
<Text style={[{ color: theme.onSurface }, styles.switchLabel]}>
{filter.label}
</Text>
</View>
<Switch
value={value}
onValueChange={() => {
setSelectedFilters(prevState => ({
...prevState,
[filterKey]: { value: !value, type: FilterTypes.Switch },
}));
}}
theme={theme}
/>
</View>
</Pressable>
);
}
if (filter.type === FilterTypes.ExcludableCheckboxGroup) {
const value = getValueFor<(typeof filter)['type']>(
filter,
Expand Down Expand Up @@ -366,13 +418,27 @@ const styles = StyleSheet.create({
paddingBottom: 8,
paddingTop: 8,
},
switchLabelContainer: {
flex: 1,
justifyContent: 'center',
},
switchLabel: {
fontSize: 16,
},
switchContainer: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
marginVertical: 8,
paddingHorizontal: 24,
},
textContainer: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
marginVertical: 8,
paddingHorizontal: 24,
},
pickerContainer: {
flex: 1,
flexDirection: 'row',
Expand Down

0 comments on commit 9e791a0

Please sign in to comment.