-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3da58bd
commit 0db4472
Showing
6 changed files
with
310 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import React from 'react'; | ||
|
||
import ExplorePage from '../../design-system/components/SearchBar/ExplorePage'; | ||
|
||
const HomePage = () => { | ||
return <></>; | ||
return <ExplorePage />; | ||
}; | ||
|
||
export default HomePage; |
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
169 changes: 169 additions & 0 deletions
169
frontend/mobile/src/app/design-system/components/SearchBar/ExplorePage.tsx
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,169 @@ | ||
import React from 'react'; | ||
import { | ||
FlatList, | ||
Pressable, | ||
SafeAreaView, | ||
ScrollView, | ||
StyleSheet, | ||
View | ||
} from 'react-native'; | ||
|
||
import { router } from 'expo-router'; | ||
|
||
import { eventApi } from '@generatesac/lib'; | ||
import { clubApi } from '@generatesac/lib'; | ||
|
||
import { Text } from '../../components/Text/Text'; | ||
import { Spacing } from '../../shared/spacing'; | ||
import { Box } from '../Box/Box'; | ||
import { EventCard } from '../EventCard'; | ||
import { GlobalLayout } from '../GlobalLayout/GlobalLayout'; | ||
import { ClubCard } from '../clubCard/ClubCard'; | ||
import SearchBar from './SearchBar'; | ||
|
||
const ExplorePage = () => { | ||
const numColumns = 2; | ||
const { | ||
data: eventsData, | ||
error: eventsError, | ||
isLoading: eventsLoading | ||
} = eventApi.useEventsQuery({}); | ||
|
||
const { | ||
data: clubsData, | ||
error: clubsError, | ||
isLoading: clubsLoading | ||
} = clubApi.useClubsQuery({}); | ||
|
||
const handleSearch = (query: string) => { | ||
console.log('Search query:', query); | ||
}; | ||
|
||
const handleCancel = () => { | ||
console.log('Search canceled'); | ||
}; | ||
|
||
const handleBack = () => { | ||
console.log('Back pressed'); | ||
}; | ||
|
||
return ( | ||
<GlobalLayout> | ||
<SafeAreaView style={styles.container}> | ||
<ScrollView showsVerticalScrollIndicator={false}> | ||
<SearchBar | ||
placeholder="Search" | ||
onSearch={handleSearch} | ||
onCancel={handleCancel} | ||
onBack={handleBack} | ||
/> | ||
<Box paddingBottom="s"> | ||
<Box | ||
flexDirection="row" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
> | ||
<Text variant="subheader-2">Recommended Clubs</Text> | ||
<Pressable | ||
onPress={() => router.push('/app/clubs')} | ||
> | ||
<Text variant="caption-1">View all</Text> | ||
</Pressable> | ||
</Box> | ||
{clubsLoading && <Text>Loading...</Text>} | ||
{clubsError && <Text>Error loading clubs.</Text>} | ||
{!clubsLoading && !clubsError && ( | ||
<FlatList | ||
data={clubsData?.slice(0, 2) || []} | ||
keyExtractor={(item) => item.id} | ||
horizontal={false} | ||
showsHorizontalScrollIndicator={false} | ||
scrollEnabled={false} | ||
renderItem={({ item }) => ( | ||
<Box padding="xs"> | ||
<Pressable | ||
onPress={() => | ||
router.push( | ||
`/app/club/${item.id}` | ||
) | ||
} | ||
> | ||
<ClubCard | ||
club={item.name} | ||
// tags={item.tags} | ||
imageUrl={item.logo || ''} | ||
/> | ||
</Pressable> | ||
</Box> | ||
)} | ||
/> | ||
)} | ||
</Box> | ||
<Box> | ||
<Box | ||
flexDirection="row" | ||
justifyContent="space-between" | ||
alignItems="center" | ||
> | ||
<Text variant="subheader-2"> | ||
Recommended Events | ||
</Text> | ||
<Pressable | ||
onPress={() => router.push('/app/events')} | ||
> | ||
<Text variant="caption-1">View all</Text> | ||
</Pressable> | ||
</Box> | ||
{eventsLoading && <Text>Loading...</Text>} | ||
{eventsError && <Text>Error loading events.</Text>} | ||
{!eventsLoading && !eventsError && ( | ||
<FlatList | ||
data={eventsData?.slice(0, 4) || []} | ||
keyExtractor={(item) => item.id} | ||
horizontal={false} | ||
key={numColumns} | ||
numColumns={numColumns} | ||
scrollEnabled={false} | ||
renderItem={({ item }) => ( | ||
<Box padding="xs"> | ||
<Pressable | ||
onPress={() => | ||
router.push( | ||
`/app/event/${item.id}` | ||
) | ||
} | ||
> | ||
<EventCard | ||
variant="small" | ||
event={item.name} | ||
club={item.host} | ||
eventId={item.id} | ||
startTime={item.start_time} | ||
endTime={item.end_time} | ||
image="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSLF3ord7lnV_5Je-pC2AUgUiesHNPcZlpI7A&s" | ||
logo="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT800M6T7YVq_f6W49g_UNL29US7gC63nTitg&s" | ||
/> | ||
</Pressable> | ||
</Box> | ||
)} | ||
/> | ||
)} | ||
</Box> | ||
</ScrollView> | ||
</SafeAreaView> | ||
</GlobalLayout> | ||
); | ||
}; | ||
|
||
export default ExplorePage; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
// flex: 1, | ||
// flexDirection: 'column', | ||
// alignItems: 'flex-start', | ||
// justifyContent: 'flex-start', | ||
// marginVertical: Spacing.m, | ||
// gap: Spacing.l | ||
} | ||
}); |
93 changes: 93 additions & 0 deletions
93
frontend/mobile/src/app/design-system/components/SearchBar/SearchBar.tsx
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,93 @@ | ||
import React, { useState } from 'react'; | ||
import { TextInput, TouchableOpacity } from 'react-native'; | ||
import { StyleSheet } from 'react-native'; | ||
|
||
import { faArrowLeft, faSearch } from '@fortawesome/free-solid-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'; | ||
|
||
import { Colors, SACColors } from '../../shared/colors'; | ||
Check failure on line 8 in frontend/mobile/src/app/design-system/components/SearchBar/SearchBar.tsx GitHub Actions / Lint
|
||
import { createStyles } from '../../theme'; | ||
import { Box } from '../Box/Box'; | ||
import { Text } from '../Text/Text'; | ||
import { TextBox } from '../Textbox/Textbox'; | ||
|
||
interface SearchBarProps { | ||
placeholder?: string; | ||
onSearch: (query: string) => void; | ||
onCancel?: () => void; | ||
onBack?: () => void; | ||
initialQuery?: string; | ||
} | ||
|
||
const SearchBar: React.FC<SearchBarProps> = ({ | ||
placeholder = 'Search', | ||
onSearch, | ||
onCancel, | ||
onBack, | ||
initialQuery = '' | ||
}) => { | ||
const [query, setQuery] = useState(initialQuery); | ||
|
||
const handleSearch = () => { | ||
onSearch(query); | ||
}; | ||
|
||
return ( | ||
<Box | ||
flexDirection="row" | ||
alignItems="center" | ||
width={'100%'} | ||
paddingBottom="s" | ||
> | ||
{onBack && ( | ||
<TouchableOpacity onPress={onBack}> | ||
<FontAwesomeIcon icon={faArrowLeft} size={16} /> | ||
</TouchableOpacity> | ||
)} | ||
<Box | ||
flexDirection="row" | ||
alignItems="center" | ||
flex={1} | ||
borderRadius="sm" | ||
paddingHorizontal="s" | ||
borderColor="gray" | ||
borderWidth={1} | ||
marginHorizontal="s" | ||
> | ||
<FontAwesomeIcon icon={faSearch} size={16} /> | ||
<TextInput | ||
style={styles.input} | ||
placeholder={placeholder} | ||
value={query} | ||
onChangeText={setQuery} | ||
onSubmitEditing={handleSearch} | ||
/> | ||
</Box> | ||
{query.length > 0 && onCancel && ( | ||
<TouchableOpacity | ||
onPress={() => { | ||
setQuery(''); | ||
onCancel && onCancel(); | ||
}} | ||
style={styles.cancelButton} | ||
> | ||
<Text color="gray">Cancel</Text> | ||
</TouchableOpacity> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
input: { | ||
flex: 1, | ||
height: 40, | ||
fontSize: 16, | ||
marginLeft: 8 | ||
}, | ||
cancelButton: { | ||
marginLeft: 8 | ||
} | ||
}); | ||
|
||
export default SearchBar; |
41 changes: 41 additions & 0 deletions
41
frontend/mobile/src/app/design-system/components/clubCard/ClubCard.tsx
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,41 @@ | ||
import { Tag as TagProps } from '@generatesac/lib'; | ||
|
||
import { Box } from '../Box/Box'; | ||
import { ClubIcon } from '../ClubIcon/ClubIcon'; | ||
import { Tag } from '../Tag/Tag'; | ||
import { Text } from '../Text/Text'; | ||
|
||
interface ClubCardProps { | ||
club: string; | ||
imageUrl: string; | ||
tags?: TagProps[]; | ||
} | ||
|
||
export const ClubCard: React.FC<ClubCardProps> = ({ club, imageUrl, tags }) => { | ||
return ( | ||
<Box | ||
flexDirection="row" | ||
alignItems="center" | ||
padding="m" | ||
borderRadius="sm" | ||
backgroundColor="white" | ||
shadowOffset={{ width: 0, height: 2 }} | ||
elevation={2} | ||
shadowOpacity={0.1} | ||
> | ||
<ClubIcon size={44} imageUrl={imageUrl} /> | ||
<Box marginLeft="m"> | ||
<Text variant="body-1">{club}</Text> | ||
{tags && ( | ||
<Box flexDirection="row" flexWrap="wrap"> | ||
{tags.map((tag) => ( | ||
<Tag key={tag.id} variant="eventCard"> | ||
<Text variant="caption-1">{tag.name}</Text> | ||
</Tag> | ||
))} | ||
</Box> | ||
)} | ||
</Box> | ||
</Box> | ||
); | ||
}; |
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