diff --git a/app/(app)/(tabs)/index.tsx b/app/(app)/(tabs)/index.tsx index 5f39c75..b353dfe 100644 --- a/app/(app)/(tabs)/index.tsx +++ b/app/(app)/(tabs)/index.tsx @@ -1,13 +1,15 @@ -import { List, Surface, Text } from 'react-native-paper' +import { useRouter } from 'expo-router' +import React from 'react' +import { Pressable } from 'react-native' +import { Surface } from 'react-native-paper' import { useCourses } from '@/lib/clients/classroom' -import { View } from 'react-native' -import React from 'react' -import { Link } from 'expo-router' +import CourseCard from '@/lib/ui/components/CourseCard' import Loading from '@/lib/ui/components/Loading' function TabsHome() { const { data, isLoading } = useCourses() + const router = useRouter() if (isLoading) { return @@ -15,11 +17,15 @@ function TabsHome() { return ( - My Courses {data?.courses.map((course) => ( - - {course.name} - + { + router.push(`/drawer/courses/${course.id}`) + }} + > + + ))} ) diff --git a/lib/ui/components/CourseCard.tsx b/lib/ui/components/CourseCard.tsx new file mode 100644 index 0000000..f2d4815 --- /dev/null +++ b/lib/ui/components/CourseCard.tsx @@ -0,0 +1,43 @@ +import type { classroom_v1 } from '@googleapis/classroom' +import { View } from 'react-native' +import { Card, Text } from 'react-native-paper' + +const COURSE_COLORS = [ + 'bg-green-600', + 'bg-blue-600', + 'bg-yellow-500', + 'bg-red-600', + 'bg-pink-400', + 'bg-gray-500', +] + +export default function CourseCard(course: classroom_v1.Schema$Course) { + const { name, section, courseState, id } = course + const colorIndex = parseInt(id || '0', 16) % COURSE_COLORS.length + const bannerColor = COURSE_COLORS[colorIndex] + + return ( + + + + {name || 'Untitled Course'} + + + + + {section && ( + + {section} + + )} + {courseState && courseState !== 'ACTIVE' && ( + + + {courseState} + + + )} + + + ) +}