From 9c808ce84b9b7666e06d1bfee82a5060f2470459 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Sat, 5 Nov 2022 14:40:06 +1300 Subject: [PATCH] Add progress circle to TimerPage --- TimerPage.tsx | 56 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/TimerPage.tsx b/TimerPage.tsx index 4324a8c..adfd5a0 100644 --- a/TimerPage.tsx +++ b/TimerPage.tsx @@ -1,11 +1,20 @@ -import React, {useEffect, useState} from 'react' -import {NativeEventEmitter, NativeModules, StyleSheet, View} from 'react-native' +import React, {useEffect, useMemo, useState} from 'react' +import { + Dimensions, + NativeEventEmitter, + NativeModules, + StyleSheet, + View, +} from 'react-native' import {Button, Text} from 'react-native-paper' +import {ProgressCircle} from 'react-native-svg-charts' import {MARGIN, PADDING} from './constants' import {settingsRepo} from './db' import DrawerHeader from './DrawerHeader' import MassiveFab from './MassiveFab' import Settings from './settings' +import {useTheme} from './use-theme' +import {useTheme as usePaperTheme} from 'react-native-paper' interface TickEvent { minutes: string @@ -16,6 +25,8 @@ export default function TimerPage() { const [minutes, setMinutes] = useState('00') const [seconds, setSeconds] = useState('00') const [settings, setSettings] = useState() + const {color} = useTheme() + const {colors} = usePaperTheme() useEffect(() => { settingsRepo.findOne({where: {}}).then(setSettings) @@ -37,6 +48,18 @@ export default function TimerPage() { NativeModules.AlarmModule.add(...params) } + const progress = useMemo(() => { + return (Number(minutes) * 60 + Number(seconds)) / 210 + }, [minutes, seconds]) + + const left = useMemo(() => { + return Dimensions.get('screen').width * 0.5 - 85 + }, []) + + const top = useMemo(() => { + return Dimensions.get('screen').height * 0.5 - 45 + }, []) + return ( <> @@ -47,21 +70,26 @@ export default function TimerPage() { justifyContent: 'center', alignItems: 'center', }}> - Remaining - - {minutes}:{seconds} - - + + + {minutes}:{seconds} + + + + ) } - -const styles = StyleSheet.create({ - text: { - fontSize: 32, - marginBottom: MARGIN, - }, -})