fix(goal-flow): 완료 시트 즉시 오픈·엔터 제출·잠깐쉬기 5분 알림 적용
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useReducedMotion } from '@/shared/lib/useReducedMotion';
|
||||
import { cn } from '@/shared/lib/cn';
|
||||
import { useToast } from '@/shared/ui';
|
||||
import { SpaceTimerHudWidget } from '@/widgets/space-timer-hud';
|
||||
import { GoalCompleteSheet } from './GoalCompleteSheet';
|
||||
@@ -23,10 +22,9 @@ export const SpaceFocusHudWidget = ({
|
||||
const reducedMotion = useReducedMotion();
|
||||
const [flashVisible, setFlashVisible] = useState(false);
|
||||
const [sheetOpen, setSheetOpen] = useState(false);
|
||||
const [completePulseVisible, setCompletePulseVisible] = useState(false);
|
||||
const playbackStateRef = useRef<'running' | 'paused'>('running');
|
||||
const flashTimerRef = useRef<number | null>(null);
|
||||
const completePulseTimerRef = useRef<number | null>(null);
|
||||
const restReminderTimerRef = useRef<number | null>(null);
|
||||
|
||||
const triggerFlash = useCallback((durationMs: number) => {
|
||||
if (reducedMotion || !visible) {
|
||||
@@ -51,9 +49,9 @@ export const SpaceFocusHudWidget = ({
|
||||
window.clearTimeout(flashTimerRef.current);
|
||||
flashTimerRef.current = null;
|
||||
}
|
||||
if (completePulseTimerRef.current) {
|
||||
window.clearTimeout(completePulseTimerRef.current);
|
||||
completePulseTimerRef.current = null;
|
||||
if (restReminderTimerRef.current) {
|
||||
window.clearTimeout(restReminderTimerRef.current);
|
||||
restReminderTimerRef.current = null;
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
@@ -88,34 +86,12 @@ export const SpaceFocusHudWidget = ({
|
||||
}
|
||||
|
||||
const handleOpenCompleteSheet = () => {
|
||||
setCompletePulseVisible(true);
|
||||
|
||||
if (completePulseTimerRef.current) {
|
||||
window.clearTimeout(completePulseTimerRef.current);
|
||||
}
|
||||
|
||||
completePulseTimerRef.current = window.setTimeout(() => {
|
||||
setCompletePulseVisible(false);
|
||||
setSheetOpen(true);
|
||||
completePulseTimerRef.current = null;
|
||||
}, 700);
|
||||
setSheetOpen(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<GoalFlashOverlay goal={goal} visible={flashVisible} />
|
||||
<div
|
||||
className={cn(
|
||||
'pointer-events-none fixed inset-x-0 z-20 flex justify-center px-4 transition-opacity duration-[240ms] ease-out motion-reduce:duration-0',
|
||||
completePulseVisible ? 'opacity-100' : 'opacity-0',
|
||||
)}
|
||||
style={{ bottom: 'calc(env(safe-area-inset-bottom, 0px) + 5.1rem)' }}
|
||||
aria-hidden
|
||||
>
|
||||
<div className="rounded-full border border-white/12 bg-black/24 px-3 py-1 text-xs text-white/84 backdrop-blur-md">
|
||||
완료!
|
||||
</div>
|
||||
</div>
|
||||
<SpaceTimerHudWidget
|
||||
timerLabel={timerLabel}
|
||||
goal={goal}
|
||||
@@ -141,7 +117,16 @@ export const SpaceFocusHudWidget = ({
|
||||
onClose={() => setSheetOpen(false)}
|
||||
onRest={() => {
|
||||
setSheetOpen(false);
|
||||
pushToast({ title: '좋아요, 잠깐 쉬고 다시 이어가요.' });
|
||||
pushToast({ title: '좋아요. 5분 뒤에 다시 알려드릴게요.' });
|
||||
|
||||
if (restReminderTimerRef.current) {
|
||||
window.clearTimeout(restReminderTimerRef.current);
|
||||
}
|
||||
|
||||
restReminderTimerRef.current = window.setTimeout(() => {
|
||||
pushToast({ title: '5분이 지났어요. 다음 한 조각으로 돌아와요.' });
|
||||
restReminderTimerRef.current = null;
|
||||
}, 5 * 60 * 1000);
|
||||
}}
|
||||
onConfirm={(nextGoal) => {
|
||||
onGoalUpdate(nextGoal);
|
||||
|
||||
Reference in New Issue
Block a user