feat: 앱 날씨 사주 — /saju 생년월일 입력(연·월·일 칩, 시각 −/+), 오늘 점수 링·할 일 카드, 사주 명식, 레벨로 열리는 이번 주·금전·연애·이달·올해, 궁합(Lv.5), 기기·계정 생년월일 저장, ?open= 으로 그 칸 (GA saju_input·saju_view)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
skkimandClaude committed 2026-11-04 17:46:31 +09:00
1 parent 47526c1cef
commit 02ebcda0ea
10 files changed
+1073 -1

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
import { useLocalSearchParams } from 'expo-router';
import { useMemo, useRef, useState } from 'react';
import { ScrollView, View } from 'react-native';
import { BirthForm } from '@/components/saju/birth-form';
import { OpenTarget } from '@/components/saju/parts';
import { Reading } from '@/components/saju/reading';
import { ScreenHeader } from '@/components/screen-header';
import { Text } from '@/components/text';
import { useAccountBirth, useBirth } from '@/lib/saju-birth';
type Pos = { base: number | null; panel: number | null; done: boolean };
function tryScroll(p: Pos, view: ScrollView | null) {
if (p.done || p.base == null || p.panel == null || !view) return;
p.done = true;
view.scrollTo({ y: Math.max(0, p.base + p.panel - 12), animated: true });
}
/** 날씨 사주(/saju): 오늘 점수와 할 일, 내 기운, 레벨로 열리는 칸. ?open=saju_love 처럼 열면 그 칸으로 내려간다 (웹 SajuPage, #hash) */
export default function SajuScreen() {
const params = useLocalSearchParams<{ open?: string }>();
const birth = useBirth();
const loading = useAccountBirth();
const [editing, setEditing] = useState(false);
const scroll = useRef<ScrollView>(null);
// 결과 묶음의 위치와 그 안에서 연 칸의 위치를 둘 다 알아야 내려갈 수 있다 (어느 쪽이 먼저 잡힐지 모른다)
const pos = useRef<Pos>({ base: null, panel: null, done: false });
const target = useMemo(
() => ({
id: params.open,
onLayout: (y: number) => {
pos.current.panel = y;
tryScroll(pos.current, scroll.current);
},
}),
[params.open],
);
return (
<View className="flex-1">
<ScreenHeader title="날씨 사주" />
<ScrollView ref={scroll} contentContainerClassName="pb-8" keyboardShouldPersistTaps="handled">
{loading && !birth ? (
<Text className="px-4 py-16 text-center font-semibold text-ink2">내 생년월일을 불러오는 중이에요…</Text>
) : !birth || editing ? (
<BirthForm initial={birth} onDone={() => setEditing(false)} onCancel={birth ? () => setEditing(false) : undefined} />
) : (
<View
onLayout={(e) => {
pos.current.base = e.nativeEvent.layout.y;
tryScroll(pos.current, scroll.current);
}}
>
<OpenTarget value={target}>
<Reading birth={birth} onEdit={() => setEditing(true)} />
</OpenTarget>
</View>
)}
</ScrollView>
</View>
);
}