From b5183f84b44529e267a014568e2e6ab4d0bdc4b8 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Thu, 7 Dec 2023 17:00:48 +0100 Subject: [PATCH] wip --- front/Navigation.tsx | 37 +++++++++++++++++++----------- front/components/UI/ScaffoldCC.tsx | 11 --------- front/views/V2/DiscoveryView.tsx | 2 -- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/front/Navigation.tsx b/front/Navigation.tsx index f3cb08f..0c00dbe 100644 --- a/front/Navigation.tsx +++ b/front/Navigation.tsx @@ -5,7 +5,7 @@ import { ParamListBase, useNavigation as navigationHook, } from '@react-navigation/native'; -import React, { useEffect, useMemo } from 'react'; +import React, { Component, ComponentProps, ComponentType, ReactElement, ReactNode, useEffect, useMemo } from 'react'; import { DarkTheme, DefaultTheme, NavigationContainer } from '@react-navigation/native'; import { RootState, useSelector } from './state/Store'; import { useDispatch } from 'react-redux'; @@ -33,6 +33,7 @@ import ForgotPasswordView from './views/ForgotPasswordView'; import DiscoveryView from './views/V2/DiscoveryView'; import MusicView from './views/MusicView'; import Leaderboardiew from './views/LeaderboardView'; +import { LinearGradient } from 'expo-linear-gradient'; // Util function to hide route props in URL const removeMe = () => ''; @@ -126,7 +127,7 @@ const publicRoutes = () => // eslint-disable-next-line @typescript-eslint/no-explicit-any type Route = { - component: (arg: RouteProps) => JSX.Element | (() => JSX.Element); + component: ComponentType; options: object; }; @@ -134,7 +135,7 @@ type OmitOrUndefined = T extends undefined ? T : Omit type RouteParams> = { [RouteName in keyof Routes]: OmitOrUndefined< - Parameters[0], + ComponentProps, keyof NativeStackScreenProps<{}> >; }; @@ -145,23 +146,31 @@ type AppRouteParams = PrivateRoutesParams & PublicRoutesParams; const Stack = createNativeStackNavigator(); -const RouteToScreen = - (component: Route['component']) => - // eslint-disable-next-line react/display-name - (props: NativeStackScreenProps) => ( - <> - {component({ ...props.route.params, route: props.route } as Parameters< - Route['component'] - >[0])} - - ); +const RouteToScreen = (Component: Route['component']) => + function Route(props: NativeStackScreenProps) { + const colorScheme = useColorScheme(); + + return ( + + + + ); + }; const routesToScreens = (routes: Partial>) => Object.entries(routes).map(([name, route], routeIndex) => ( )); diff --git a/front/components/UI/ScaffoldCC.tsx b/front/components/UI/ScaffoldCC.tsx index 18c4599..a4dc351 100644 --- a/front/components/UI/ScaffoldCC.tsx +++ b/front/components/UI/ScaffoldCC.tsx @@ -68,17 +68,6 @@ const ScaffoldCC = ({ {children} )} - {colorScheme === 'dark' && ( - - )} ); }; diff --git a/front/views/V2/DiscoveryView.tsx b/front/views/V2/DiscoveryView.tsx index d8d07a9..5905262 100644 --- a/front/views/V2/DiscoveryView.tsx +++ b/front/views/V2/DiscoveryView.tsx @@ -20,7 +20,6 @@ const HomeView = (props: RouteProps<{}>) => { const suggestions = suggestionsQuery.data?.slice(4) ?? []; return ( - ) => { - ); };