From fd384397564566fe3f910f3df39a7de6852c5756 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Fri, 26 Aug 2022 13:54:51 +1200 Subject: [PATCH] Change color scheme --- App.tsx | 6 ++++-- MassiveFab.tsx | 7 ++++--- MassiveInput.tsx | 22 ++++++++++++++++++++++ MassiveSwitch.tsx | 8 ++++++-- SetForm.tsx | 35 +++++++++-------------------------- SettingsPage.tsx | 20 ++++++-------------- ViewBest.tsx | 14 ++++++-------- 7 files changed, 57 insertions(+), 55 deletions(-) create mode 100644 MassiveInput.tsx diff --git a/App.tsx b/App.tsx index ae12cca..a37ad27 100644 --- a/App.tsx +++ b/App.tsx @@ -30,7 +30,7 @@ export const SnackbarContext = React.createContext<{ toast: (value: string, timeout: number) => void; }>({toast: () => null}); -const CombinedDefaultTheme = { +export const CombinedDefaultTheme = { ...PaperDefaultTheme, ...NavigationDefaultTheme, colors: { @@ -38,12 +38,14 @@ const CombinedDefaultTheme = { ...NavigationDefaultTheme.colors, }, }; -const CombinedDarkTheme = { +export const CombinedDarkTheme = { ...PaperDarkTheme, ...NavigationDarkTheme, colors: { ...PaperDarkTheme.colors, ...NavigationDarkTheme.colors, + primary: '#B3E5fC', + background: '#121212', }, }; diff --git a/MassiveFab.tsx b/MassiveFab.tsx index ac5c587..be4fa4f 100644 --- a/MassiveFab.tsx +++ b/MassiveFab.tsx @@ -1,7 +1,7 @@ -import {DarkTheme, DefaultTheme} from '@react-navigation/native'; import React from 'react'; import {useColorScheme} from 'react-native'; import {FAB} from 'react-native-paper'; +import {CombinedDarkTheme, CombinedDefaultTheme} from './App'; export default function MassiveFab( props: Partial>, @@ -12,13 +12,14 @@ export default function MassiveFab( ); diff --git a/MassiveInput.tsx b/MassiveInput.tsx new file mode 100644 index 0000000..a0d2c88 --- /dev/null +++ b/MassiveInput.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import {useColorScheme} from 'react-native'; +import {TextInput} from 'react-native-paper'; + +export default function MassiveInput( + props: Partial> & { + innerRef?: React.Ref; + }, +) { + const dark = useColorScheme() === 'dark'; + + return ( + + ); +} diff --git a/MassiveSwitch.tsx b/MassiveSwitch.tsx index ad4ccfe..c8c36fb 100644 --- a/MassiveSwitch.tsx +++ b/MassiveSwitch.tsx @@ -1,7 +1,7 @@ import React from 'react'; -import {DarkTheme, DefaultTheme} from '@react-navigation/native'; import {useColorScheme} from 'react-native'; import {Switch} from 'react-native-paper'; +import {CombinedDarkTheme, CombinedDefaultTheme} from './App'; export default function MassiveSwitch( props: Partial>, @@ -10,7 +10,11 @@ export default function MassiveSwitch( return ( diff --git a/SetForm.tsx b/SetForm.tsx index 7d46af4..719b12e 100644 --- a/SetForm.tsx +++ b/SetForm.tsx @@ -1,6 +1,7 @@ import React, {useRef, useState} from 'react'; -import {ScrollView, StyleSheet, Text} from 'react-native'; -import {Button, TextInput} from 'react-native-paper'; +import {ScrollView, Text} from 'react-native'; +import {Button} from 'react-native-paper'; +import MassiveInput from './MassiveInput'; import Set from './set'; export default function SetForm({ @@ -37,19 +38,15 @@ export default function SetForm({ return ( <> - repsRef.current?.focus()} - mode="outlined" /> - setSelection(e.nativeEvent.selection)} autoFocus={!!name} - selectTextOnFocus blurOnSubmit={false} - ref={repsRef} - mode="outlined" + innerRef={repsRef} /> - - {set.created && ( @@ -113,9 +102,3 @@ export default function SetForm({ ); } - -const styles = StyleSheet.create({ - marginBottom: { - marginBottom: 10, - }, -}); diff --git a/SettingsPage.tsx b/SettingsPage.tsx index 77ec31a..abf3cb2 100644 --- a/SettingsPage.tsx +++ b/SettingsPage.tsx @@ -6,12 +6,13 @@ import React, { useState, } from 'react'; import {NativeModules, StyleSheet, Text, View} from 'react-native'; -import {Button, Searchbar, TextInput} from 'react-native-paper'; +import DocumentPicker from 'react-native-document-picker'; +import {Button, Searchbar} from 'react-native-paper'; import {DatabaseContext, SnackbarContext} from './App'; import ConfirmDialog from './ConfirmDialog'; +import MassiveInput from './MassiveInput'; import MassiveSwitch from './MassiveSwitch'; import Settings from './settings'; -import DocumentPicker from 'react-native-document-picker'; export default function SettingsPage() { const [vibrate, setVibrate] = useState(true); @@ -87,24 +88,20 @@ export default function SettingsPage() { { name: 'Sets per workout', element: ( - { setMaxSets(value); }} - style={styles.text} - selectTextOnFocus /> ), }, { name: 'Rest minutes', element: ( - { setMinutes(text); }} - style={styles.text} - selectTextOnFocus /> ), }, { name: 'Rest seconds', element: ( - { setSeconds(s); }} - style={styles.text} - selectTextOnFocus /> ), }, diff --git a/ViewBest.tsx b/ViewBest.tsx index 0b7dec3..49e40ee 100644 --- a/ViewBest.tsx +++ b/ViewBest.tsx @@ -1,6 +1,4 @@ import { - DarkTheme, - DefaultTheme, RouteProp, useFocusEffect, useNavigation, @@ -15,15 +13,15 @@ import React, { useState, } from 'react'; import {Text, useColorScheme, View} from 'react-native'; +import {FileSystem} from 'react-native-file-access'; import {IconButton} from 'react-native-paper'; import Share from 'react-native-share'; import {Grid, LineChart, XAxis, YAxis} from 'react-native-svg-charts'; import ViewShot from 'react-native-view-shot'; -import {DatabaseContext} from './App'; +import {CombinedDarkTheme, CombinedDefaultTheme, DatabaseContext} from './App'; import {BestPageParams} from './BestPage'; import Set from './set'; import {formatMonth} from './time'; -import {FileSystem} from 'react-native-file-access'; interface Volume { name: string; @@ -125,8 +123,8 @@ export default function ViewBest() { curve={shape.curveBasis} svg={{ stroke: dark - ? DarkTheme.colors.primary - : DefaultTheme.colors.primary, + ? CombinedDarkTheme.colors.primary + : CombinedDefaultTheme.colors.primary, }}> @@ -162,8 +160,8 @@ export default function ViewBest() { curve={shape.curveBasis} svg={{ stroke: dark - ? DarkTheme.colors.primary - : DefaultTheme.colors.primary, + ? CombinedDarkTheme.colors.primary + : CombinedDefaultTheme.colors.primary, }}>