Implemented timer into task details, uploaded example images for app and centred headers on all screens
@@ -66,7 +66,6 @@ export default function TabLayout() {
|
|||||||
}}>
|
}}>
|
||||||
<Tabs.Screen name="index" options={{title: 'Dashboard', tabBarLabel: 'Dashboard', }} />
|
<Tabs.Screen name="index" options={{title: 'Dashboard', tabBarLabel: 'Dashboard', }} />
|
||||||
<Tabs.Screen name="subjects" options={{title: "Subjects"}} />
|
<Tabs.Screen name="subjects" options={{title: "Subjects"}} />
|
||||||
<Tabs.Screen name="timer" options={{title: "Timer"}} />
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,7 @@ export default function HomeScreen() {
|
|||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
options={{
|
options={{
|
||||||
title: "Home",
|
title: "Home",
|
||||||
|
headerTitleAlign: 'center',
|
||||||
headerTitleStyle: defaultStyles.title,
|
headerTitleStyle: defaultStyles.title,
|
||||||
headerRight: () => {
|
headerRight: () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ export default function Subjects() {
|
|||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
options={{
|
options={{
|
||||||
title: 'Subjects',
|
title: 'Subjects',
|
||||||
|
headerTitleAlign: 'center',
|
||||||
headerRight: () => (
|
headerRight: () => (
|
||||||
<Pressable
|
<Pressable
|
||||||
className="rounded-full bg-app-subtle px-4 py-2"
|
className="rounded-full bg-app-subtle px-4 py-2"
|
||||||
|
|||||||
@@ -223,6 +223,7 @@ export default function UpsertAssignment() {
|
|||||||
options={{
|
options={{
|
||||||
title: isEditMode ? 'Edit Assignment' : 'Create Assignment',
|
title: isEditMode ? 'Edit Assignment' : 'Create Assignment',
|
||||||
headerTitleStyle: defaultStyles.title,
|
headerTitleStyle: defaultStyles.title,
|
||||||
|
headerTitleAlign: 'center',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ export default function ViewDetailsAssignment() {
|
|||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
options={{
|
options={{
|
||||||
title: 'Details',
|
title: 'Details',
|
||||||
|
headerTitleAlign: 'center',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ export default function UpsertSubject() {
|
|||||||
|
|
||||||
if(result.error) {
|
if(result.error) {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
isEditMode
|
isEditMode
|
||||||
? 'Subject could not be updated, please try again'
|
? 'Subject could not be updated, please try again'
|
||||||
: 'Subject could not be created, please try again'
|
: 'Subject could not be created, please try again'
|
||||||
);
|
);
|
||||||
@@ -129,6 +129,7 @@ export default function UpsertSubject() {
|
|||||||
options= {{
|
options= {{
|
||||||
title: isEditMode ? 'Edit Subject' : 'Create Subject',
|
title: isEditMode ? 'Edit Subject' : 'Create Subject',
|
||||||
headerTitleStyle: defaultStyles.title,
|
headerTitleStyle: defaultStyles.title,
|
||||||
|
headerTitleAlign: 'center',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ export default function ViewDetailsSubject() {
|
|||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
options={{
|
options={{
|
||||||
title: 'Subject Details',
|
title: 'Subject Details',
|
||||||
|
headerTitleAlign: 'center',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export default function TaskLayout() {
|
|||||||
<Stack>
|
<Stack>
|
||||||
<Stack.Screen name="upsertTask" options={{ title: "Create Task" }} />
|
<Stack.Screen name="upsertTask" options={{ title: "Create Task" }} />
|
||||||
<Stack.Screen name="viewDetailsTask" options={{ title: "Task Details" }} />
|
<Stack.Screen name="viewDetailsTask" options={{ title: "Task Details" }} />
|
||||||
|
<Stack.Screen name='timer' options={{title: 'Sprint'}} />
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,12 @@
|
|||||||
|
import {
|
||||||
|
GetActiveSprint,
|
||||||
|
RemoveActiveSprint,
|
||||||
|
SaveActiveSprint,
|
||||||
|
} from '@/lib/asyncStorage';
|
||||||
|
import { supabase } from '@/lib/supabase';
|
||||||
|
import type { Task } from '@/lib/types';
|
||||||
import * as Haptics from 'expo-haptics';
|
import * as Haptics from 'expo-haptics';
|
||||||
|
import { Stack, useLocalSearchParams } from 'expo-router';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {
|
import {
|
||||||
Animated,
|
Animated,
|
||||||
@@ -8,7 +16,7 @@ import {
|
|||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
View,
|
View
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
const { width, height } = Dimensions.get('window');
|
const { width, height } = Dimensions.get('window');
|
||||||
@@ -40,11 +48,6 @@ const CANCEL_ANIMATION_DELAY_MS = 250;
|
|||||||
const BUTTON_PRESS_IN_MS = 80;
|
const BUTTON_PRESS_IN_MS = 80;
|
||||||
const BUTTON_PRESS_OUT_MS = 140;
|
const BUTTON_PRESS_OUT_MS = 140;
|
||||||
|
|
||||||
const placeholderTask = {
|
|
||||||
name: 'Read chapter 4',
|
|
||||||
description: 'Focus on the summary questions and write down anything unclear.',
|
|
||||||
};
|
|
||||||
|
|
||||||
function formatTime(totalSeconds: number) {
|
function formatTime(totalSeconds: number) {
|
||||||
const minutes = Math.floor(totalSeconds / 60);
|
const minutes = Math.floor(totalSeconds / 60);
|
||||||
const seconds = totalSeconds % 60;
|
const seconds = totalSeconds % 60;
|
||||||
@@ -56,7 +59,9 @@ export default function TimerScreen() {
|
|||||||
const [containerHeight, setContainerHeight] = React.useState(0);
|
const [containerHeight, setContainerHeight] = React.useState(0);
|
||||||
const [duration, setDuration] = React.useState(TIMER_OPTIONS[0]);
|
const [duration, setDuration] = React.useState(TIMER_OPTIONS[0]);
|
||||||
const [timerIsRunning, setIsRunning] = React.useState(false);
|
const [timerIsRunning, setIsRunning] = React.useState(false);
|
||||||
|
const [timerOverlayVisible, setTimerOverlayVisible] = React.useState(false);
|
||||||
const [timeRemaining, setTimeRemaining] = React.useState(0);
|
const [timeRemaining, setTimeRemaining] = React.useState(0);
|
||||||
|
const [task, setTask] = React.useState<Task | null>(null);
|
||||||
|
|
||||||
const scrollX = React.useRef(new Animated.Value(0)).current;
|
const scrollX = React.useRef(new Animated.Value(0)).current;
|
||||||
const timerAnimation = React.useRef(new Animated.Value(0)).current;
|
const timerAnimation = React.useRef(new Animated.Value(0)).current;
|
||||||
@@ -76,15 +81,41 @@ export default function TimerScreen() {
|
|||||||
const sessionStartedAtRef = React.useRef<number | null>(null);
|
const sessionStartedAtRef = React.useRef<number | null>(null);
|
||||||
const sessionDurationMsRef = React.useRef(0);
|
const sessionDurationMsRef = React.useRef(0);
|
||||||
const cancelAccelStartedRef = React.useRef(false);
|
const cancelAccelStartedRef = React.useRef(false);
|
||||||
|
const cancelHoldCompletedRef = React.useRef(false);
|
||||||
const cancelHoldActiveRef = React.useRef(false);
|
const cancelHoldActiveRef = React.useRef(false);
|
||||||
const cancelHoldIdRef = React.useRef(0);
|
const cancelHoldIdRef = React.useRef(0);
|
||||||
const cancelHoldStartedAtRef = React.useRef(0);
|
const cancelHoldStartedAtRef = React.useRef(0);
|
||||||
|
|
||||||
|
const { tId } = useLocalSearchParams<{ tId?: string}>();
|
||||||
|
const timerOverlayHeight = Math.max(containerHeight, 1);
|
||||||
|
const timerOverlayOffscreenY = timerOverlayHeight + 1000;
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (containerHeight > 0 && !timerIsRunning) {
|
if (containerHeight > 0 && !timerIsRunning) {
|
||||||
timerAnimation.setValue(containerHeight);
|
timerAnimation.setValue(timerOverlayOffscreenY);
|
||||||
}
|
}
|
||||||
}, [containerHeight, timerIsRunning, timerAnimation]);
|
}, [containerHeight, timerIsRunning, timerAnimation, timerOverlayOffscreenY]);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!tId) {
|
||||||
|
setTask(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchTask = async () => {
|
||||||
|
const {data, error} = await supabase
|
||||||
|
.from('tasks')
|
||||||
|
.select('*')
|
||||||
|
.eq('tId', tId)
|
||||||
|
.single()
|
||||||
|
|
||||||
|
|
||||||
|
if (!error && data) {
|
||||||
|
setTask(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchTask();
|
||||||
|
}, [tId])
|
||||||
|
|
||||||
const pressedButtonScale = pressedButtonAnimation.interpolate({
|
const pressedButtonScale = pressedButtonAnimation.interpolate({
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
@@ -102,11 +133,7 @@ export default function TimerScreen() {
|
|||||||
const timerOverlayTranslateY = Animated.add(
|
const timerOverlayTranslateY = Animated.add(
|
||||||
timerAnimation,
|
timerAnimation,
|
||||||
cancelOverlayAnimation
|
cancelOverlayAnimation
|
||||||
).interpolate({
|
);
|
||||||
inputRange: [0, Math.max(containerHeight, 1)],
|
|
||||||
outputRange: [0, Math.max(containerHeight, 1)],
|
|
||||||
extrapolate: 'clamp',
|
|
||||||
});
|
|
||||||
|
|
||||||
const countdownTranslateX = focusModeAnimation.interpolate({
|
const countdownTranslateX = focusModeAnimation.interpolate({
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
@@ -115,7 +142,7 @@ export default function TimerScreen() {
|
|||||||
|
|
||||||
const countdownTranslateY = focusModeAnimation.interpolate({
|
const countdownTranslateY = focusModeAnimation.interpolate({
|
||||||
inputRange: [0, 1],
|
inputRange: [0, 1],
|
||||||
outputRange: [0, -containerHeight * 0.35],
|
outputRange: [0, -height * 0.35],
|
||||||
});
|
});
|
||||||
|
|
||||||
const countdownScale = focusModeAnimation.interpolate({
|
const countdownScale = focusModeAnimation.interpolate({
|
||||||
@@ -201,15 +228,18 @@ export default function TimerScreen() {
|
|||||||
sessionDurationMsRef.current = 0;
|
sessionDurationMsRef.current = 0;
|
||||||
cancelHoldActiveRef.current = false;
|
cancelHoldActiveRef.current = false;
|
||||||
cancelAccelStartedRef.current = false;
|
cancelAccelStartedRef.current = false;
|
||||||
|
cancelHoldCompletedRef.current = false;
|
||||||
|
|
||||||
timerAnimation.setValue(containerHeight);
|
timerAnimation.setValue(timerOverlayOffscreenY);
|
||||||
cancelOverlayAnimation.setValue(0);
|
cancelOverlayAnimation.setValue(0);
|
||||||
|
setTimerOverlayVisible(false);
|
||||||
setTimeRemaining(0);
|
setTimeRemaining(0);
|
||||||
setIsRunning(false);
|
setIsRunning(false);
|
||||||
}, [cancelOverlayAnimation, containerHeight, timerAnimation]);
|
}, [cancelOverlayAnimation, timerAnimation, timerOverlayOffscreenY]);
|
||||||
|
|
||||||
const finishTimer = React.useCallback(() => {
|
const finishTimer = React.useCallback(() => {
|
||||||
clearCountdownInterval();
|
clearCountdownInterval();
|
||||||
|
void RemoveActiveSprint();
|
||||||
|
|
||||||
Animated.parallel([
|
Animated.parallel([
|
||||||
Animated.timing(countdownAnimation, {
|
Animated.timing(countdownAnimation, {
|
||||||
@@ -263,14 +293,14 @@ export default function TimerScreen() {
|
|||||||
// runs it to the bottom over the remaining session time.
|
// runs it to the bottom over the remaining session time.
|
||||||
const startProgressAnimation = React.useCallback(
|
const startProgressAnimation = React.useCallback(
|
||||||
(fromY: number) => {
|
(fromY: number) => {
|
||||||
const elapsedRatio = fromY / containerHeight;
|
const elapsedRatio = fromY / timerOverlayHeight;
|
||||||
const remainingMs = sessionDurationMsRef.current * (1 - elapsedRatio);
|
const remainingMs = sessionDurationMsRef.current * (1 - elapsedRatio);
|
||||||
|
|
||||||
sessionStartedAtRef.current = Date.now() - sessionDurationMsRef.current * elapsedRatio;
|
sessionStartedAtRef.current = Date.now() - sessionDurationMsRef.current * elapsedRatio;
|
||||||
timerAnimation.setValue(fromY);
|
timerAnimation.setValue(fromY);
|
||||||
|
|
||||||
const progressAnimation = Animated.timing(timerAnimation, {
|
const progressAnimation = Animated.timing(timerAnimation, {
|
||||||
toValue: containerHeight,
|
toValue: timerOverlayHeight,
|
||||||
duration: remainingMs,
|
duration: remainingMs,
|
||||||
useNativeDriver: true,
|
useNativeDriver: true,
|
||||||
});
|
});
|
||||||
@@ -286,33 +316,18 @@ export default function TimerScreen() {
|
|||||||
finishTimer();
|
finishTimer();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[containerHeight, finishTimer, timerAnimation]
|
[finishTimer, timerAnimation, timerOverlayHeight]
|
||||||
);
|
);
|
||||||
|
|
||||||
const runStartSequence = React.useCallback(() => {
|
const runStartSequence = React.useCallback(() => {
|
||||||
const runningAnimation = Animated.sequence([
|
buttonAnimation.setValue(1);
|
||||||
Animated.parallel([
|
cancelButtonAnimation.setValue(1);
|
||||||
Animated.timing(buttonAnimation, {
|
countdownAnimation.setValue(1);
|
||||||
toValue: 1,
|
timerAnimation.setValue(0);
|
||||||
duration: 300,
|
|
||||||
useNativeDriver: true,
|
startProgressAnimation(0);
|
||||||
}),
|
|
||||||
Animated.timing(cancelButtonAnimation, {
|
const focusAnimation = Animated.parallel([
|
||||||
toValue: 1,
|
|
||||||
duration: 300,
|
|
||||||
useNativeDriver: true,
|
|
||||||
}),
|
|
||||||
Animated.timing(countdownAnimation, {
|
|
||||||
toValue: 1,
|
|
||||||
duration: 300,
|
|
||||||
useNativeDriver: true,
|
|
||||||
}),
|
|
||||||
Animated.timing(timerAnimation, {
|
|
||||||
toValue: 0,
|
|
||||||
duration: 300,
|
|
||||||
useNativeDriver: true,
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
Animated.timing(focusModeAnimation, {
|
Animated.timing(focusModeAnimation, {
|
||||||
toValue: 1,
|
toValue: 1,
|
||||||
duration: 450,
|
duration: 450,
|
||||||
@@ -325,15 +340,9 @@ export default function TimerScreen() {
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
runningAnimationRef.current = runningAnimation;
|
runningAnimationRef.current = focusAnimation;
|
||||||
runningAnimation.start(({ finished }) => {
|
focusAnimation.start(() => {
|
||||||
runningAnimationRef.current = null;
|
runningAnimationRef.current = null;
|
||||||
|
|
||||||
if (!finished) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
startProgressAnimation(0);
|
|
||||||
});
|
});
|
||||||
}, [
|
}, [
|
||||||
buttonAnimation,
|
buttonAnimation,
|
||||||
@@ -346,41 +355,109 @@ export default function TimerScreen() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const startCountdown = React.useCallback(
|
const startCountdown = React.useCallback(
|
||||||
(totalSeconds: number) => {
|
(endTime: number) => {
|
||||||
setTimeRemaining(totalSeconds);
|
|
||||||
clearCountdownInterval();
|
clearCountdownInterval();
|
||||||
|
|
||||||
countdownRef.current = setInterval(() => {
|
const updateRemainingTime = () => {
|
||||||
setTimeRemaining((currentTime) => {
|
const remainingSeconds = Math.max(
|
||||||
if (currentTime <= 1) {
|
0,
|
||||||
clearCountdownInterval();
|
Math.ceil((endTime - Date.now()) / 1000)
|
||||||
return 0;
|
);
|
||||||
}
|
|
||||||
|
|
||||||
return currentTime - 1;
|
setTimeRemaining(remainingSeconds);
|
||||||
});
|
|
||||||
}, 1000);
|
if (remainingSeconds <= 0) {
|
||||||
|
clearCountdownInterval();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateRemainingTime();
|
||||||
|
countdownRef.current = setInterval(updateRemainingTime, 1000);
|
||||||
},
|
},
|
||||||
[clearCountdownInterval]
|
[clearCountdownInterval]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!tId || timerIsRunning || containerHeight === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const restoreSprint = async () => {
|
||||||
|
const activeSprint = await GetActiveSprint();
|
||||||
|
|
||||||
|
if (!activeSprint || activeSprint.taskId !== tId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const remainingMs = activeSprint.endTime - Date.now();
|
||||||
|
|
||||||
|
if (remainingMs <= 0) {
|
||||||
|
await RemoveActiveSprint();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalMs = activeSprint.durationSeconds * 1000;
|
||||||
|
const elapsedMs = totalMs - remainingMs;
|
||||||
|
const elapsedRatio = Math.max(0, Math.min(elapsedMs / totalMs, 1));
|
||||||
|
const restoredY = timerOverlayHeight * elapsedRatio;
|
||||||
|
|
||||||
|
setIsRunning(true);
|
||||||
|
setTimerOverlayVisible(true);
|
||||||
|
sessionStartedAtRef.current = Date.now() - elapsedMs;
|
||||||
|
sessionDurationMsRef.current = totalMs;
|
||||||
|
|
||||||
|
buttonAnimation.setValue(1);
|
||||||
|
cancelButtonAnimation.setValue(1);
|
||||||
|
countdownAnimation.setValue(1);
|
||||||
|
focusModeAnimation.setValue(1);
|
||||||
|
taskDetailsAnimation.setValue(1);
|
||||||
|
cancelOverlayAnimation.setValue(0);
|
||||||
|
|
||||||
|
startCountdown(activeSprint.endTime);
|
||||||
|
startProgressAnimation(restoredY);
|
||||||
|
};
|
||||||
|
|
||||||
|
void restoreSprint();
|
||||||
|
}, [
|
||||||
|
buttonAnimation,
|
||||||
|
cancelButtonAnimation,
|
||||||
|
cancelOverlayAnimation,
|
||||||
|
containerHeight,
|
||||||
|
countdownAnimation,
|
||||||
|
focusModeAnimation,
|
||||||
|
startCountdown,
|
||||||
|
startProgressAnimation,
|
||||||
|
taskDetailsAnimation,
|
||||||
|
tId,
|
||||||
|
timerOverlayHeight,
|
||||||
|
timerIsRunning,
|
||||||
|
]);
|
||||||
|
|
||||||
const startTimerSession = React.useCallback(() => {
|
const startTimerSession = React.useCallback(() => {
|
||||||
if (timerIsRunning || containerHeight === 0) {
|
if (!tId || timerIsRunning || containerHeight === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
||||||
setIsRunning(true);
|
setIsRunning(true);
|
||||||
|
setTimerOverlayVisible(true);
|
||||||
|
|
||||||
taskDetailsAnimation.setValue(0);
|
taskDetailsAnimation.setValue(0);
|
||||||
countdownAnimation.setValue(0);
|
countdownAnimation.setValue(0);
|
||||||
cancelOverlayAnimation.setValue(0);
|
cancelOverlayAnimation.setValue(0);
|
||||||
|
|
||||||
const totalSeconds = duration * TIMER_UNIT_IN_SECONDS;
|
const totalSeconds = duration * TIMER_UNIT_IN_SECONDS;
|
||||||
|
const endTime = Date.now() + totalSeconds * 1000;
|
||||||
sessionStartedAtRef.current = Date.now();
|
sessionStartedAtRef.current = Date.now();
|
||||||
sessionDurationMsRef.current = totalSeconds * 1000;
|
sessionDurationMsRef.current = totalSeconds * 1000;
|
||||||
|
|
||||||
startCountdown(totalSeconds);
|
void SaveActiveSprint({
|
||||||
|
taskId: tId,
|
||||||
|
durationSeconds: totalSeconds,
|
||||||
|
endTime,
|
||||||
|
});
|
||||||
|
|
||||||
|
startCountdown(endTime);
|
||||||
runStartSequence();
|
runStartSequence();
|
||||||
}, [
|
}, [
|
||||||
cancelOverlayAnimation,
|
cancelOverlayAnimation,
|
||||||
@@ -390,6 +467,7 @@ export default function TimerScreen() {
|
|||||||
runStartSequence,
|
runStartSequence,
|
||||||
startCountdown,
|
startCountdown,
|
||||||
taskDetailsAnimation,
|
taskDetailsAnimation,
|
||||||
|
tId,
|
||||||
timerIsRunning,
|
timerIsRunning,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -400,46 +478,50 @@ export default function TimerScreen() {
|
|||||||
|
|
||||||
clearCountdownInterval();
|
clearCountdownInterval();
|
||||||
clearCancelHoldTimeouts();
|
clearCancelHoldTimeouts();
|
||||||
stopRunningAnimations();
|
void RemoveActiveSprint();
|
||||||
|
|
||||||
Animated.parallel([
|
runningAnimationRef.current?.stop();
|
||||||
Animated.timing(cancelButtonAnimation, {
|
runningAnimationRef.current = null;
|
||||||
toValue: 0,
|
|
||||||
duration: 180,
|
progressAnimationRef.current?.stop();
|
||||||
useNativeDriver: true,
|
progressAnimationRef.current = null;
|
||||||
}),
|
|
||||||
Animated.timing(taskDetailsAnimation, {
|
timerAnimation.stopAnimation(() => {
|
||||||
toValue: 0,
|
cancelOverlayAnimation.stopAnimation(() => {
|
||||||
duration: 220,
|
timerAnimation.setValue(timerOverlayOffscreenY);
|
||||||
useNativeDriver: true,
|
cancelOverlayAnimation.setValue(0);
|
||||||
}),
|
setTimerOverlayVisible(false);
|
||||||
Animated.timing(focusModeAnimation, {
|
|
||||||
toValue: 0,
|
Animated.parallel([
|
||||||
duration: 250,
|
Animated.timing(cancelButtonAnimation, {
|
||||||
useNativeDriver: true,
|
toValue: 0,
|
||||||
}),
|
duration: 180,
|
||||||
Animated.timing(countdownAnimation, {
|
useNativeDriver: true,
|
||||||
toValue: 0,
|
}),
|
||||||
duration: 180,
|
Animated.timing(taskDetailsAnimation, {
|
||||||
useNativeDriver: true,
|
toValue: 0,
|
||||||
}),
|
duration: 220,
|
||||||
Animated.timing(timerAnimation, {
|
useNativeDriver: true,
|
||||||
toValue: containerHeight,
|
}),
|
||||||
duration: 300,
|
Animated.timing(focusModeAnimation, {
|
||||||
useNativeDriver: true,
|
toValue: 0,
|
||||||
}),
|
duration: 250,
|
||||||
Animated.timing(cancelOverlayAnimation, {
|
useNativeDriver: true,
|
||||||
toValue: 0,
|
}),
|
||||||
duration: 120,
|
Animated.timing(countdownAnimation, {
|
||||||
useNativeDriver: true,
|
toValue: 0,
|
||||||
}),
|
duration: 180,
|
||||||
]).start(() => {
|
useNativeDriver: true,
|
||||||
Animated.timing(buttonAnimation, {
|
}),
|
||||||
toValue: 0,
|
]).start(() => {
|
||||||
duration: 220,
|
Animated.timing(buttonAnimation, {
|
||||||
useNativeDriver: true,
|
toValue: 0,
|
||||||
}).start(() => {
|
duration: 220,
|
||||||
resetSessionValues();
|
useNativeDriver: true,
|
||||||
|
}).start(() => {
|
||||||
|
resetSessionValues();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, [
|
}, [
|
||||||
@@ -448,13 +530,12 @@ export default function TimerScreen() {
|
|||||||
cancelOverlayAnimation,
|
cancelOverlayAnimation,
|
||||||
clearCancelHoldTimeouts,
|
clearCancelHoldTimeouts,
|
||||||
clearCountdownInterval,
|
clearCountdownInterval,
|
||||||
containerHeight,
|
|
||||||
countdownAnimation,
|
countdownAnimation,
|
||||||
focusModeAnimation,
|
focusModeAnimation,
|
||||||
resetSessionValues,
|
resetSessionValues,
|
||||||
stopRunningAnimations,
|
|
||||||
taskDetailsAnimation,
|
taskDetailsAnimation,
|
||||||
timerAnimation,
|
timerAnimation,
|
||||||
|
timerOverlayOffscreenY,
|
||||||
timerIsRunning,
|
timerIsRunning,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -466,6 +547,7 @@ export default function TimerScreen() {
|
|||||||
cancelHoldActiveRef.current = true;
|
cancelHoldActiveRef.current = true;
|
||||||
cancelHoldStartedAtRef.current = Date.now();
|
cancelHoldStartedAtRef.current = Date.now();
|
||||||
cancelAccelStartedRef.current = false;
|
cancelAccelStartedRef.current = false;
|
||||||
|
cancelHoldCompletedRef.current = false;
|
||||||
|
|
||||||
cancelHoldAnimationDelayRef.current = setTimeout(() => {
|
cancelHoldAnimationDelayRef.current = setTimeout(() => {
|
||||||
cancelHoldAnimationDelayRef.current = null;
|
cancelHoldAnimationDelayRef.current = null;
|
||||||
@@ -486,8 +568,8 @@ export default function TimerScreen() {
|
|||||||
const elapsedAtCancelMs = Date.now() + remainingHoldMs - sessionStartedAt;
|
const elapsedAtCancelMs = Date.now() + remainingHoldMs - sessionStartedAt;
|
||||||
const expectedProgress = elapsedAtCancelMs / sessionDurationMsRef.current;
|
const expectedProgress = elapsedAtCancelMs / sessionDurationMsRef.current;
|
||||||
const clampedProgress = Math.max(0, Math.min(expectedProgress, 1));
|
const clampedProgress = Math.max(0, Math.min(expectedProgress, 1));
|
||||||
const expectedYAtCancel = containerHeight * clampedProgress;
|
const expectedYAtCancel = timerOverlayHeight * clampedProgress;
|
||||||
const cancelOffset = Math.max(0, containerHeight - expectedYAtCancel);
|
const cancelOffset = Math.max(0, timerOverlayHeight - expectedYAtCancel);
|
||||||
|
|
||||||
Animated.timing(cancelOverlayAnimation, {
|
Animated.timing(cancelOverlayAnimation, {
|
||||||
toValue: cancelOffset,
|
toValue: cancelOffset,
|
||||||
@@ -501,12 +583,13 @@ export default function TimerScreen() {
|
|||||||
cancelHoldActiveRef.current = false;
|
cancelHoldActiveRef.current = false;
|
||||||
cancelHoldIdRef.current += 1;
|
cancelHoldIdRef.current += 1;
|
||||||
cancelAccelStartedRef.current = false;
|
cancelAccelStartedRef.current = false;
|
||||||
|
cancelHoldCompletedRef.current = true;
|
||||||
|
|
||||||
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Warning);
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Warning);
|
||||||
cancelTimer();
|
cancelTimer();
|
||||||
cancelHoldTimeoutRef.current = null;
|
cancelHoldTimeoutRef.current = null;
|
||||||
}, HOLD_TO_CANCEL_MS);
|
}, HOLD_TO_CANCEL_MS);
|
||||||
}, [animateButtonPress, cancelOverlayAnimation, cancelTimer, containerHeight]);
|
}, [animateButtonPress, cancelOverlayAnimation, cancelTimer, timerOverlayHeight]);
|
||||||
|
|
||||||
const handleCancelHoldEnd = React.useCallback(() => {
|
const handleCancelHoldEnd = React.useCallback(() => {
|
||||||
animateButtonPress(false);
|
animateButtonPress(false);
|
||||||
@@ -515,6 +598,10 @@ export default function TimerScreen() {
|
|||||||
|
|
||||||
clearCancelHoldTimeouts();
|
clearCancelHoldTimeouts();
|
||||||
|
|
||||||
|
if (cancelHoldCompletedRef.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!cancelAccelStartedRef.current) {
|
if (!cancelAccelStartedRef.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -591,12 +678,23 @@ export default function TimerScreen() {
|
|||||||
>
|
>
|
||||||
<StatusBar hidden />
|
<StatusBar hidden />
|
||||||
|
|
||||||
|
<Stack.Screen
|
||||||
|
options={{
|
||||||
|
title: timerIsRunning ? '' : 'Sprint',
|
||||||
|
headerBackVisible: !timerIsRunning,
|
||||||
|
headerTransparent: true,
|
||||||
|
headerTintColor: colors.text,
|
||||||
|
headerTitleAlign: 'center',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<Animated.View
|
<Animated.View
|
||||||
|
pointerEvents="none"
|
||||||
style={[
|
style={[
|
||||||
StyleSheet.absoluteFillObject,
|
|
||||||
styles.timerOverlay,
|
styles.timerOverlay,
|
||||||
{
|
{
|
||||||
height: containerHeight,
|
height: timerOverlayHeight,
|
||||||
|
opacity: timerOverlayVisible ? 1 : 0,
|
||||||
width,
|
width,
|
||||||
transform: [{ translateY: timerOverlayTranslateY }],
|
transform: [{ translateY: timerOverlayTranslateY }],
|
||||||
},
|
},
|
||||||
@@ -711,8 +809,8 @@ export default function TimerScreen() {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Text style={styles.taskName}>{placeholderTask.name}</Text>
|
<Text style={styles.taskName}>{task?.title ?? 'Sprint'}</Text>
|
||||||
<Text style={styles.taskDescription}>{placeholderTask.description}</Text>
|
<Text style={styles.taskDescription}>{task?.description || 'Focus on this task until the timer ends.'}</Text>
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
@@ -722,8 +820,13 @@ const styles = StyleSheet.create({
|
|||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: colors.black,
|
backgroundColor: colors.black,
|
||||||
|
overflow: 'hidden',
|
||||||
},
|
},
|
||||||
timerOverlay: {
|
timerOverlay: {
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
backgroundColor: colors.red,
|
backgroundColor: colors.red,
|
||||||
},
|
},
|
||||||
startButtonContainer: {
|
startButtonContainer: {
|
||||||
@@ -812,7 +915,7 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
countdownOverlay: {
|
countdownOverlay: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: height / 3,
|
top: height / 2.5 ,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
@@ -148,6 +148,7 @@ export default function UpsertTask() {
|
|||||||
options={{
|
options={{
|
||||||
title: isEditMode ? 'Edit Task' : 'Create Task',
|
title: isEditMode ? 'Edit Task' : 'Create Task',
|
||||||
headerTitleStyle: defaultStyles.title,
|
headerTitleStyle: defaultStyles.title,
|
||||||
|
headerTitleAlign: 'center',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ export default function ViewDetailsTask() {
|
|||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
options={{
|
options={{
|
||||||
title: 'Task Details',
|
title: 'Task Details',
|
||||||
|
headerTitleAlign: 'center',
|
||||||
headerRight: () => (
|
headerRight: () => (
|
||||||
<Pressable
|
<Pressable
|
||||||
className="rounded-full bg-app-subtle px-4 py-2"
|
className="rounded-full bg-app-subtle px-4 py-2"
|
||||||
@@ -281,7 +282,18 @@ export default function ViewDetailsTask() {
|
|||||||
Edit
|
Edit
|
||||||
</Text>
|
</Text>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
<Pressable
|
||||||
|
className='mr-3 flex-1 items-center justify-center rounded-2xl border border-app-border bg-app-subtle py-3'
|
||||||
|
onPress={() =>
|
||||||
|
router.push({
|
||||||
|
pathname: '/task/timer',
|
||||||
|
params: { tId: task.tId}
|
||||||
|
})
|
||||||
|
}>
|
||||||
|
<Text className='text.sm font-bold text-text-secondary'>
|
||||||
|
Start Sprint
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
<Pressable
|
<Pressable
|
||||||
className="flex-1 items-center justify-center rounded-2xl border border-app-border bg-app-surface py-3"
|
className="flex-1 items-center justify-center rounded-2xl border border-app-border bg-app-surface py-3"
|
||||||
onPress={() => DeleteTask(task.tId)}
|
onPress={() => DeleteTask(task.tId)}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 162 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 384 KiB After Width: | Height: | Size: 551 KiB |
|
Before Width: | Height: | Size: 551 KiB After Width: | Height: | Size: 551 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 551 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 162 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 551 KiB |
|
Before Width: | Height: | Size: 551 KiB |
@@ -1,6 +1,13 @@
|
|||||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||||
|
|
||||||
const notificationKey = (aId: string) => `assignment_notification_${aId}`;
|
const notificationKey = (aId: string) => `assignment_notification_${aId}`;
|
||||||
|
const activeSprintKey = 'active_sprint';
|
||||||
|
|
||||||
|
export type ActiveSprint = {
|
||||||
|
taskId: string;
|
||||||
|
durationSeconds: number;
|
||||||
|
endTime: number;
|
||||||
|
};
|
||||||
|
|
||||||
export async function SaveAssignmentNotificationId(aId: string, notificationId: string) {
|
export async function SaveAssignmentNotificationId(aId: string, notificationId: string) {
|
||||||
await AsyncStorage.setItem(notificationKey(aId), notificationId);
|
await AsyncStorage.setItem(notificationKey(aId), notificationId);
|
||||||
@@ -13,3 +20,21 @@ export async function GetAssignmentNotificationId(aId: string) {
|
|||||||
export async function RemoveAssignmentNotificationId(aId: string) {
|
export async function RemoveAssignmentNotificationId(aId: string) {
|
||||||
await AsyncStorage.removeItem(notificationKey(aId));
|
await AsyncStorage.removeItem(notificationKey(aId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function SaveActiveSprint(activeSprint: ActiveSprint) {
|
||||||
|
await AsyncStorage.setItem(activeSprintKey, JSON.stringify(activeSprint));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GetActiveSprint() {
|
||||||
|
const activeSprint = await AsyncStorage.getItem(activeSprintKey);
|
||||||
|
|
||||||
|
if (!activeSprint) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return JSON.parse(activeSprint) as ActiveSprint;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function RemoveActiveSprint() {
|
||||||
|
await AsyncStorage.removeItem(activeSprintKey);
|
||||||
|
}
|
||||||
|
|||||||