diff --git a/src/components/area.tsx b/src/components/area.tsx new file mode 100644 index 0000000..9f31d52 --- /dev/null +++ b/src/components/area.tsx @@ -0,0 +1,50 @@ +import { ReactElement } from "react"; +import { Card, Icon, Text } from "react-native-paper"; +import { StyleSheet, View } from "react-native"; + +export default function Area({ + title, + icon, + children, + right, +}: { + title: string; + icon: string; + children?: ReactElement | ReactElement[]; + right?: undefined | ReactElement; +}) { + return ( + + + + + + + {title} + + {right} + + {children && {children}} + + + + ); +} + +const styles = StyleSheet.create({ + container: { + gap: 16, + }, + header: { + display: "flex", + flexDirection: "row", + alignItems: "center", + gap: 5, + }, + text: { + flex: 1, + }, + content: { + gap: 10, + }, +}); diff --git a/src/components/feed/feed.tsx b/src/components/feed/feed.tsx index 305578e..2f89fa1 100644 --- a/src/components/feed/feed.tsx +++ b/src/components/feed/feed.tsx @@ -4,20 +4,18 @@ import { useAtomValue } from "jotai"; import { feedAtom } from "../../stores/feed"; import { ActivityIndicator, Card } from "react-native-paper"; import Item from "./item"; +import Area from "../area"; export default function Feed() { const feed = useAtomValue(feedAtom); return ( - - - - {feed ? ( - feed.map((item, index) => ) - ) : ( - - )} - - + + {feed ? ( + feed.map((item, index) => ) + ) : ( + + )} + ); } diff --git a/src/components/register/listing.tsx b/src/components/register/listing.tsx index b1ed5ad..cd03d1a 100644 --- a/src/components/register/listing.tsx +++ b/src/components/register/listing.tsx @@ -10,6 +10,7 @@ import { StyleSheet, TouchableOpacity } from "react-native"; import { useNavigation } from "@react-navigation/native"; import { NativeStackNavigationProp } from "react-native-screens/native-stack"; import { StackParamList } from "../../../App"; +import Area from "../area"; type SlotNavigationProps = NativeStackNavigationProp; @@ -38,23 +39,14 @@ export default function Listing() { const slots = useAtomValue(slotsAtom); return ( - - - - {slots ? ( - slots.map((slot, index) => ( - - )) - ) : ( - - )} - - + + {slots ? ( + slots.map((slot, index) => ( + + )) + ) : ( + + )} + ); } - -const styles = StyleSheet.create({ - content: { - gap: 10, - }, -}); diff --git a/src/components/register/precenseCard.tsx b/src/components/register/precenseCard.tsx index 0634895..f794f95 100644 --- a/src/components/register/precenseCard.tsx +++ b/src/components/register/precenseCard.tsx @@ -38,7 +38,7 @@ export default function PresenceCard({ if (!slot.presence) return; return ( - <> + ))} - + ); } diff --git a/src/components/register/presence.tsx b/src/components/register/presence.tsx index c7bb683..93515d2 100644 --- a/src/components/register/presence.tsx +++ b/src/components/register/presence.tsx @@ -44,7 +44,7 @@ export default function Presence({ {presence.name} - {presence.stripcard_count && ( + {!!presence.stripcard_count && ( diff --git a/src/screens/calendar/calendar.tsx b/src/screens/calendar/calendar.tsx index 755147f..f828ac9 100644 --- a/src/screens/calendar/calendar.tsx +++ b/src/screens/calendar/calendar.tsx @@ -7,6 +7,7 @@ import { useEffect, useState } from "react"; import { parse, VEvent } from "unfucked-ical"; import Item from "../../components/feed/item"; import { ActionType, FeedItem, sortFeeds } from "../../stores/feed"; +import Area from "../../components/area"; export default function CalendarScreen() { const [date, setDate] = useState(new Date()); @@ -64,45 +65,41 @@ export default function CalendarScreen() { - - - - - Vanaf - + + {Platform.OS === "ios" && ( + setDate(date as Date)} + mode={"date"} + /> + )} + {Platform.OS === "android" && ( + + )} + + } + /> - {Platform.OS === "ios" && ( - setDate(date as Date)} - mode={"date"} - /> - )} - {Platform.OS === "android" && ( - - )} - - - - - - - {items.map((item, index) => ( - - ))} - - + + {items.map((item, index) => ( + + ))} + diff --git a/src/screens/calendar/event.tsx b/src/screens/calendar/event.tsx index 539d315..8026609 100644 --- a/src/screens/calendar/event.tsx +++ b/src/screens/calendar/event.tsx @@ -19,6 +19,7 @@ import { useAtom } from "jotai"; import { useContext } from "react"; import AuthContext, { Authed } from "../../auth"; import * as WebBrowser from "expo-web-browser"; +import Area from "../../components/area"; function friday() { return isFriday(new Date()) ? new Date() : nextFriday(new Date()); @@ -168,19 +169,13 @@ export default function EventScreen({ route, navigation }: Props) { )} {getDescription() && ( - - - - {getDescription()} - - + + {getDescription()} + )} - - - - {getDates()} - - + + {getDates()} + ); diff --git a/src/screens/feed/search.tsx b/src/screens/feed/search.tsx index 8d5ca72..af1fe71 100644 --- a/src/screens/feed/search.tsx +++ b/src/screens/feed/search.tsx @@ -14,6 +14,7 @@ import { ActionType, FeedItem } from "../../stores/feed"; import Item from "../../components/feed/item"; import { parse } from "fast-html-parser"; import * as WebBrowser from "expo-web-browser"; +import Area from "../../components/area"; export interface Item { id: number; @@ -135,45 +136,39 @@ export default function SearchScreen() { > {searched && ( <> - - - - {itemResults ? ( - itemResults.length > 0 ? ( - itemResults.map((result, index) => ( - - )) - ) : ( - - Geen producten gevonden - - - ) + + {itemResults ? ( + itemResults.length > 0 ? ( + itemResults.map((result, index) => ( + + )) ) : ( - - )} - - - - - - {articleResults ? ( - articleResults.length > 0 ? ( - articleResults.map((result, index) => ( - - )) - ) : ( - - Geen artikelen gevonden - - ) + + Geen producten gevonden + + + ) + ) : ( + + )} + + + {articleResults ? ( + articleResults.length > 0 ? ( + articleResults.map((result, index) => ( + + )) ) : ( - - )} - - + + Geen artikelen gevonden + + ) + ) : ( + + )} + )} diff --git a/src/screens/feed/slot.tsx b/src/screens/feed/slot.tsx index 6e81449..afb7152 100644 --- a/src/screens/feed/slot.tsx +++ b/src/screens/feed/slot.tsx @@ -8,6 +8,7 @@ import { StackParamList } from "../../../App"; import AuthContext, { Authed } from "../../auth"; import { AANMELDEN } from "../../env"; import PresenceCard from "../../components/register/precenseCard"; +import Area from "../../components/area"; type Props = StackScreenProps; @@ -96,45 +97,29 @@ export default function SlotScreen({ route, navigation }: Props) { )} - - - Beschikbaarheid - - - - - Er zijn {slot.available}/{slot.available + slot.taken} plekken - beschikbaar. - - - + + + Er zijn {slot.available}/{slot.available + slot.taken} plekken + beschikbaar. + + - - - Begeleiders - - - + + {slot.tutors.length === 0 && ( Er zijn nog geen begeleiders aangemeld )} {slot.tutors.map((tutor) => ( {tutor} ))} - - + + {slot.presence && ( <> - - - Leden - - - - - - + + + )} diff --git a/src/screens/settings.tsx b/src/screens/settings.tsx index 37d07cf..386055b 100644 --- a/src/screens/settings.tsx +++ b/src/screens/settings.tsx @@ -6,6 +6,7 @@ import * as WebBrowser from "expo-web-browser"; import auth from "../auth"; import logging from "../logging"; import * as Sharing from "expo-sharing"; +import Area from "../components/area"; export default function SettingsScreen() { const authState = useContext(AuthContext); @@ -33,52 +34,50 @@ export default function SettingsScreen() { - - - - + + - - - - - - - - - {authState.authenticated === Authed.AUTHENTICATED && ( - - - {authState.user.given_name} {authState.user.family_name} ( - {authState.user.sub}) - - - - )} - {authState.authenticated === Authed.GUEST && ( - - Demo Mode - - - )} - + + + + + <> + {authState.authenticated === Authed.AUTHENTICATED && ( + <> + + {authState.user.given_name} {authState.user.family_name} ( + {authState.user.sub}) + + + + )} + {authState.authenticated === Authed.GUEST && ( + <> + Demo Mode + + + )} + +