From bdd712833c013fac6e37b1da8404deb83817a268 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Fri, 15 Jul 2022 18:06:33 +1200 Subject: [PATCH] Reduce number of colors in theme --- App.tsx | 30 ++++++++++++++++++++++++------ EditPlan.tsx | 11 ++++++++++- MassiveFab.tsx | 21 +++++++++++++++------ SetItem.tsx | 30 +++++++++++++++++++++--------- 4 files changed, 70 insertions(+), 22 deletions(-) diff --git a/App.tsx b/App.tsx index e19aa82..b40bfc7 100644 --- a/App.tsx +++ b/App.tsx @@ -1,15 +1,15 @@ import AsyncStorage from '@react-native-async-storage/async-storage'; import {createDrawerNavigator} from '@react-navigation/drawer'; import { - DarkTheme, - DefaultTheme, + DarkTheme as NavigationDarkTheme, + DefaultTheme as NavigationDefaultTheme, NavigationContainer, } from '@react-navigation/native'; import React, {useEffect, useState} from 'react'; import {StatusBar, useColorScheme} from 'react-native'; import { - DarkTheme as DarkThemePaper, - DefaultTheme as DefaultThemePaper, + DarkTheme as PaperDarkTheme, + DefaultTheme as PaperDefaultTheme, Provider, } from 'react-native-paper'; import {SQLiteDatabase} from 'react-native-sqlite-storage'; @@ -29,6 +29,23 @@ export const DatabaseContext = React.createContext({} as any); const {getItem, setItem} = AsyncStorage; +const CombinedDefaultTheme = { + ...PaperDefaultTheme, + ...NavigationDefaultTheme, + colors: { + ...PaperDefaultTheme.colors, + ...NavigationDefaultTheme.colors, + }, +}; +const CombinedDarkTheme = { + ...PaperDarkTheme, + ...NavigationDarkTheme, + colors: { + ...PaperDarkTheme.colors, + ...NavigationDarkTheme.colors, + }, +}; + const App = () => { const [db, setDb] = useState(null); const dark = useColorScheme() === 'dark'; @@ -54,9 +71,10 @@ const App = () => { return ( }}> - + diff --git a/EditPlan.tsx b/EditPlan.tsx index 9d7daab..01f92b6 100644 --- a/EditPlan.tsx +++ b/EditPlan.tsx @@ -1,11 +1,13 @@ import { + DarkTheme, + DefaultTheme, RouteProp, useFocusEffect, useNavigation, useRoute, } from '@react-navigation/native'; import React, {useCallback, useContext, useEffect, useState} from 'react'; -import {ScrollView, StyleSheet, Text, View} from 'react-native'; +import {ScrollView, StyleSheet, Text, useColorScheme, View} from 'react-native'; import {Button, IconButton, Switch} from 'react-native-paper'; import {DatabaseContext} from './App'; import {PlanPageParams} from './PlanPage'; @@ -20,6 +22,7 @@ export default function EditPlan() { const [names, setNames] = useState([]); const db = useContext(DatabaseContext); const navigation = useNavigation(); + const dark = useColorScheme() === 'dark'; useFocusEffect( useCallback(() => { @@ -90,6 +93,9 @@ export default function EditPlan() { {DAYS.map(day => ( toggleDay(value, day)} @@ -109,6 +115,9 @@ export default function EditPlan() { {names.map(name => ( toggleWorkout(value, name)} diff --git a/MassiveFab.tsx b/MassiveFab.tsx index d04bcbf..ac5c587 100644 --- a/MassiveFab.tsx +++ b/MassiveFab.tsx @@ -1,16 +1,25 @@ -import {AnimatedFAB} from 'react-native-paper'; +import {DarkTheme, DefaultTheme} from '@react-navigation/native'; import React from 'react'; +import {useColorScheme} from 'react-native'; +import {FAB} from 'react-native-paper'; export default function MassiveFab( - props: Partial>, + props: Partial>, ) { + const dark = useColorScheme() === 'dark'; + return ( - ); } diff --git a/SetItem.tsx b/SetItem.tsx index d04eadc..9b491b6 100644 --- a/SetItem.tsx +++ b/SetItem.tsx @@ -1,10 +1,11 @@ import {NavigationProp, useNavigation} from '@react-navigation/native'; import React, {useCallback, useContext, useState} from 'react'; -import {GestureResponderEvent} from 'react-native'; +import {GestureResponderEvent, Text} from 'react-native'; import {Divider, List, Menu} from 'react-native-paper'; import {DatabaseContext} from './App'; import {HomePageParams} from './HomePage'; import Set from './set'; +import {format} from './time'; export default function SetItem({ item, @@ -48,14 +49,25 @@ export default function SetItem({ description={`${item.reps} x ${item.weight}${item.unit}`} onLongPress={longPress} right={() => ( - setShowMenu(false)}> - - - - + <> + + {format(new Date(item.created))} + + setShowMenu(false)}> + + + + + )} />