Skip to content

Commit

Permalink
App is done
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapawar1 committed Apr 24, 2024
1 parent 32b8493 commit e989663
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 41 deletions.
14 changes: 12 additions & 2 deletions src/app/(tabs)/genre/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,18 @@ function GenreScreen() {
</View>

<View style={[styles.dropdownContainer, styles.firstDropdown]}>
<FilterDropdown placeholder='Topic' value={selectedTopicsForFiltering} data={topicFilterOptions} setter={setSelectedTopicsForFiltering} />
<FilterDropdown placeholder='Tone' value={selectedTonesForFiltering} data={toneFilterOptions} setter={setSelectedTonesForFiltering} />
<FilterDropdown
placeholder="Topic"
value={selectedTopicsForFiltering}
data={topicFilterOptions}
setter={setSelectedTopicsForFiltering}
/>
<FilterDropdown
placeholder="Tone"
value={selectedTonesForFiltering}
data={toneFilterOptions}
setter={setSelectedTonesForFiltering}
/>
</View>

{genreStoryIds.length === 0 && !isLoading ? (
Expand Down
67 changes: 48 additions & 19 deletions src/app/(tabs)/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import {
import colors from '../../../styles/colors';
import globalStyles from '../../../styles/globalStyles';
import { GenreType } from '../genre';
import { FilterDropdown, FilterSingleDropdown } from '../../../components/FilterDropdown/FilterDropdown';
import {
FilterDropdown,
FilterSingleDropdown,
} from '../../../components/FilterDropdown/FilterDropdown';

const getRecentSearch = async () => {
try {
Expand Down Expand Up @@ -195,7 +198,7 @@ function SearchScreen() {
getRecentStory().then((viewed: StoryPreview[]) =>
setRecentlyViewed(viewed),
);
})().then(() => { });
})().then(() => {});
}, []);

useEffect(() => {
Expand Down Expand Up @@ -425,24 +428,39 @@ function SearchScreen() {
<ScrollView
horizontal={true}
showsHorizontalScrollIndicator={false}
contentContainerStyle={[
styles.dropdownContainer,
]}
contentContainerStyle={[styles.dropdownContainer]}
>
{search
?
<FilterDropdown placeholder='Genre' value={selectedMultipleGenresForFiltering} data={genreFilterOptions} setter={setSelectedMultipleGenresForFiltering} />
:
<FilterSingleDropdown placeholder='Genre' value={selectedGenre} data={genreFilterOptions} setter={setSelectedGenre} />
}

<FilterDropdown placeholder='Topic' value={selectedTopicsForFiltering} data={topicFilterOptions} setter={setSelectedTopicsForFiltering} />
<FilterDropdown placeholder='Tone' value={selectedTonesForFiltering} data={toneFilterOptions} setter={setSelectedTonesForFiltering} />
{search ? (
<FilterDropdown
placeholder="Genre"
value={selectedMultipleGenresForFiltering}
data={genreFilterOptions}
setter={setSelectedMultipleGenresForFiltering}
/>
) : (
<FilterSingleDropdown
placeholder="Genre"
value={selectedGenre}
data={genreFilterOptions}
setter={setSelectedGenre}
/>
)}

<FilterDropdown
placeholder="Topic"
value={selectedTopicsForFiltering}
data={topicFilterOptions}
setter={setSelectedTopicsForFiltering}
/>
<FilterDropdown
placeholder="Tone"
value={selectedTonesForFiltering}
data={toneFilterOptions}
setter={setSelectedTonesForFiltering}
/>
</ScrollView>
)}


{/* {search && ( */}
{/* <View style={styles.default}> */}
{/* <Button */}
Expand All @@ -459,8 +477,13 @@ function SearchScreen() {
Showing results 1-{searchResults.length}
</Text>

<TouchableOpacity style={styles.clearFiltersButton} onPress={() => clearFilters()}>
<Text style={[globalStyles.bodyUnderline, styles.clearFilters]}>Clear Filters</Text>
<TouchableOpacity
style={styles.clearFiltersButton}
onPress={() => clearFilters()}
>
<Text style={[globalStyles.bodyUnderline, styles.clearFilters]}>
Clear Filters
</Text>
</TouchableOpacity>
</View>
) : search && searchResults.length === 0 ? (
Expand All @@ -475,7 +498,13 @@ function SearchScreen() {
</View>
<Text style={[globalStyles.subHeading2, { textAlign: 'center' }]}>
Try searching by title or author,{' '}
<Text onPress={clearFilters} style={[globalStyles.bodyUnderline, styles.clearFilters]}>clearing filters</Text>,
<Text
onPress={clearFilters}
style={[globalStyles.bodyUnderline, styles.clearFilters]}
>
clearing filters
</Text>
,
</Text>
<Text style={[globalStyles.subHeading2, { textAlign: 'center' }]}>
or check if your spelling is correct.
Expand Down Expand Up @@ -648,7 +677,7 @@ function SearchScreen() {
{/* title="Genre" */}
{/* /> */}
</View>
</SafeAreaView >
</SafeAreaView>
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/app/(tabs)/search/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const styles = StyleSheet.create({
marginHorizontal: 8,
},
numDisplay: {
marginTop: 24,
marginTop: 20,
marginBottom: 8,
},
contentContainerRecents: {
Expand Down Expand Up @@ -125,12 +125,12 @@ const styles = StyleSheet.create({
marginLeft: 45,
},
clearFilters: {
color: colors.fadedBlack
color: colors.fadedBlack,
},
clearFiltersButton: {
marginBottom: 8,
marginTop: 'auto'
}
marginTop: 'auto',
},
});

export default styles;
36 changes: 24 additions & 12 deletions src/components/FilterDropdown/FilterDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dropdown, MultiSelect } from "react-native-element-dropdown";
import globalStyles from "../../styles/globalStyles";
import styles from "./styles"
import { View } from "react-native";
import { Dropdown, MultiSelect } from 'react-native-element-dropdown';
import globalStyles from '../../styles/globalStyles';
import styles from './styles';
import { View } from 'react-native';
import { Icon } from 'react-native-elements';

import colors from '../../styles/colors';
Expand All @@ -13,7 +13,12 @@ type FilterDropdownProps = {
setter: React.Dispatch<React.SetStateAction<string[]>>;
};

function FilterDropdown({ placeholder, value, data, setter }: FilterDropdownProps) {
function FilterDropdown({
placeholder,
value,
data,
setter,
}: FilterDropdownProps) {
return (
<MultiSelect
mode="default"
Expand All @@ -34,7 +39,9 @@ function FilterDropdown({ placeholder, value, data, setter }: FilterDropdownProp
labelField="label"
valueField="value"
placeholder={placeholder}
renderRightIcon={() => <Icon color={colors.darkGrey} name="arrow-drop-down" type="material" />}
renderRightIcon={() => (
<Icon color={colors.darkGrey} name="arrow-drop-down" type="material" />
)}
onChange={item => {
if (item) {
setter(item);
Expand All @@ -47,11 +54,16 @@ function FilterDropdown({ placeholder, value, data, setter }: FilterDropdownProp
type FilterSingleDropdownProps = {
placeholder: string;
value: string;
data: string[]
data: string[];
setter: React.Dispatch<React.SetStateAction<string>>;
}
};

function FilterSingleDropdown({ placeholder, value, data, setter }: FilterSingleDropdownProps) {
function FilterSingleDropdown({
placeholder,
value,
data,
setter,
}: FilterSingleDropdownProps) {
return (
<Dropdown
mode="default"
Expand All @@ -71,7 +83,9 @@ function FilterSingleDropdown({ placeholder, value, data, setter }: FilterSingle
labelField="label"
valueField="value"
placeholder={placeholder}
renderRightIcon={() => <Icon color={colors.darkGrey} name="arrow-drop-down" type="material" />}
renderRightIcon={() => (
<Icon color={colors.darkGrey} name="arrow-drop-down" type="material" />
)}
onChange={item => {
if (item) {
setter(item.value);
Expand All @@ -82,5 +96,3 @@ function FilterSingleDropdown({ placeholder, value, data, setter }: FilterSingle
}

export { FilterDropdown, FilterSingleDropdown };


4 changes: 1 addition & 3 deletions src/components/FilterDropdown/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'flex-start',
},
firstDropdown: {
},
firstDropdown: {},
iconStyle: {
width: 20,
height: 20,
Expand All @@ -34,7 +33,6 @@ const styles = StyleSheet.create({
fontSize: 14,
color: colors.darkGrey,
},

});

export default styles;
4 changes: 3 additions & 1 deletion src/components/GenreCard/GenreCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ function GenreCard({ subgenres, pressFunction, cardColor }: GenreCardProps) {
return (
<TouchableOpacity onPress={pressFunction}>
<View style={[styles.card, { backgroundColor: cardColor }]}>
<Text style={[globalStyles.subHeading1, styles.overlayText]}>{subgenres}</Text>
<Text style={[globalStyles.subHeading1, styles.overlayText]}>
{subgenres}
</Text>
</View>
</TouchableOpacity>
);
Expand Down

0 comments on commit e989663

Please sign in to comment.