Skip to content

Commit

Permalink
Explore page init
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerSchaefer4 committed Jun 20, 2024
1 parent 3da58bd commit 0db4472
Show file tree
Hide file tree
Showing 6 changed files with 310 additions and 3 deletions.
4 changes: 3 additions & 1 deletion frontend/mobile/src/app/app/(tabs)/index.tsx
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;
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { Avatar } from '@rneui/themed';

interface ClubIconProps {
imageUrl: string;
size?: number;
}

export const ClubIcon: React.FC<ClubIconProps> = ({ imageUrl }) => {
export const ClubIcon: React.FC<ClubIconProps> = ({ imageUrl, size }) => {
return (
<Avatar
size={77}
size={size ? size : 77}
rounded
source={{ uri: imageUrl }}
containerStyle={{
Expand Down
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

Check failure on line 8 in frontend/mobile/src/app/design-system/components/SearchBar/ExplorePage.tsx

View workflow job for this annotation

GitHub Actions / Lint

'View' is defined but never used
} 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';

Check failure on line 17 in frontend/mobile/src/app/design-system/components/SearchBar/ExplorePage.tsx

View workflow job for this annotation

GitHub Actions / Lint

'Spacing' is defined but never used
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
}
});
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

View workflow job for this annotation

GitHub Actions / Lint

'Colors' is defined but never used

Check failure on line 8 in frontend/mobile/src/app/design-system/components/SearchBar/SearchBar.tsx

View workflow job for this annotation

GitHub Actions / Lint

'SACColors' is defined but never used
import { createStyles } from '../../theme';

Check failure on line 9 in frontend/mobile/src/app/design-system/components/SearchBar/SearchBar.tsx

View workflow job for this annotation

GitHub Actions / Lint

'createStyles' is defined but never used
import { Box } from '../Box/Box';
import { Text } from '../Text/Text';
import { TextBox } from '../Textbox/Textbox';

Check failure on line 12 in frontend/mobile/src/app/design-system/components/SearchBar/SearchBar.tsx

View workflow job for this annotation

GitHub Actions / Lint

'TextBox' is defined but never used

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;
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>
);
};
1 change: 1 addition & 0 deletions frontend/mobile/src/app/design-system/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export * from './components/Tag/Tag';
export * from './components/Preview/Event/EventPreview';
export * from './components/Preview/Club/ClubPreview';
export * from './components/Tag/Tags';
export * from './components/SearchBar/ExplorePage';

0 comments on commit 0db4472

Please sign in to comment.