feat: 앱 날씨 사주 — /saju 생년월일 입력(연·월·일 칩, 시각 −/+), 오늘 점수 링·할 일 카드, 사주 명식, 레벨로 열리는 이번 주·금전·연애·이달·올해, 궁합(Lv.5), 기기·계정 생년월일 저장, ?open= 으로 그 칸 (GA saju_input·saju_view)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
47526c1cef
commit
02ebcda0ea
10 files changed
+1073
-1
No files matched your search
@@ -0,0 +1,139 @@
|
||||
import type { ResSaju } from '@nalssigak/shared/api/client/types.gen';
|
||||
import { Image } from 'expo-image';
|
||||
import { Pressable, View } from 'react-native';
|
||||
|
||||
import { useSoft } from '@/components/sheets/parts';
|
||||
import { Text } from '@/components/text';
|
||||
|
||||
import { EL_ART, EL_COLOR, EL_WORD, Panel } from './parts';
|
||||
|
||||
const POS_WORD: Record<string, string> = { hour: '시', day: '일', month: '월', year: '연' };
|
||||
const STRENGTH_WORD: Record<string, string> = {
|
||||
신강: '나를 돕는 기운이 센 사주. 태어난 달(월령)의 힘을 먼저 봐요',
|
||||
중화: '나를 돕는 기운과 다른 기운이 비슷한 사주',
|
||||
신약: '나를 돕는 기운이 약한 사주',
|
||||
};
|
||||
const TEN_GOD_WORD: Record<string, string> = {
|
||||
비견: '나와 같은 기운',
|
||||
겁재: '나와 같지만 겨루는 기운',
|
||||
식신: '내가 만들어 내는 기운',
|
||||
상관: '내가 드러내는 기운',
|
||||
편재: '내가 크게 굴리는 재물',
|
||||
정재: '내가 차곡차곡 모으는 재물',
|
||||
편관: '나를 세게 다잡는 기운',
|
||||
정관: '나를 바르게 이끄는 기운',
|
||||
편인: '나를 돕는 남다른 지혜',
|
||||
정인: '나를 돕는 배움·도움',
|
||||
};
|
||||
|
||||
function Art({ el, size }: { el: string; size: number }) {
|
||||
const src = EL_ART[el];
|
||||
return src != null ? <Image source={src} style={{ width: size, height: size }} contentFit="contain" /> : null;
|
||||
}
|
||||
|
||||
function Char({ c, ko, el, me }: { c: string; ko: string; el: string; me?: boolean }) {
|
||||
const [fg, bg] = EL_COLOR[el] ?? ['#28304a', '#f3f6fb'];
|
||||
return (
|
||||
<View className="items-center rounded-xl py-1.5" style={{ backgroundColor: bg, borderWidth: me ? 2 : 0, borderColor: '#ff7a45' }}>
|
||||
<Text className="font-batang text-[22px] leading-tight" style={{ color: fg }}>
|
||||
{c}
|
||||
</Text>
|
||||
<Text className="text-[10.5px] font-extrabold" style={{ color: fg }}>
|
||||
{ko}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function Note({ term, word }: { term: string; word: string }) {
|
||||
return (
|
||||
<Text className="text-[12.5px] leading-relaxed font-semibold text-ink2">
|
||||
<Text className="font-extrabold text-ink">{term}</Text> = {word}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
/** 사주 명식: 가장 센 기운, 오행 막대, 네 기둥, 용어 풀이 */
|
||||
export function MeCard({ r, onEdit }: { r: ResSaju; onEdit: () => void }) {
|
||||
const soft = useSoft();
|
||||
const me = r.me!;
|
||||
const cols = [...me.pillars].reverse();
|
||||
const els = Object.entries(me.elements ?? {});
|
||||
const total = els.reduce((a, [, v]) => a + v, 0);
|
||||
const gods = [...new Set(me.pillars.flatMap((p) => [p.stem_ten_god, p.branch_ten_god]).filter((g): g is string => !!g && g in TEN_GOD_WORD))];
|
||||
const strength = me.strength ?? (me.strong == null ? null : me.strong ? '신강' : '신약');
|
||||
const top = me.top_element;
|
||||
return (
|
||||
<Panel
|
||||
icon={me.scene_icon}
|
||||
title="사주 명식"
|
||||
right={
|
||||
<Pressable onPress={onEdit} hitSlop={8} accessibilityRole="button">
|
||||
<Text className="text-xs font-extrabold text-orange">생년월일 바꾸기</Text>
|
||||
</Pressable>
|
||||
}
|
||||
>
|
||||
{!!top && !!strength && (
|
||||
<View className="flex-row items-center gap-3">
|
||||
<Art el={top} size={64} />
|
||||
<View className="min-w-0 flex-1">
|
||||
<Text className="font-jua text-[18px] leading-snug text-ink">
|
||||
{EL_WORD[top]}({top}) 기운이 가장 센 {strength} 사주
|
||||
</Text>
|
||||
<Text className="mt-0.5 text-[13px] font-semibold text-ink2">
|
||||
나를 돕는 기운 {Math.round((me.support ?? 0) * 100)}% · {me.scene}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
{total > 0 && (
|
||||
<>
|
||||
<View className="mt-2.5 h-2.5 flex-row overflow-hidden rounded-full" accessibilityRole="image" accessibilityLabel={els.map(([k, v]) => `${k} ${Math.round(v)}`).join(', ')}>
|
||||
{els.map(([k, v]) => (
|
||||
<View key={k} style={{ width: `${(v / total) * 100}%`, backgroundColor: EL_COLOR[k]?.[0] }} />
|
||||
))}
|
||||
</View>
|
||||
<View className="mt-1.5 flex-row justify-between">
|
||||
{els.map(([k, v]) => (
|
||||
<View key={k} className="flex-row items-center gap-0.5">
|
||||
<Art el={k} size={20} />
|
||||
<Text className="text-[12px] font-extrabold" style={{ color: EL_COLOR[k]?.[0] }}>
|
||||
{k} {Math.round(v)}
|
||||
</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
<View className="mt-3 flex-row gap-1.5">
|
||||
{(me.hour_known ? cols : [null, ...cols]).map((p, i) => (
|
||||
<View key={p?.position ?? `none-${i}`} className="flex-1 gap-1">
|
||||
<Text className="text-center text-[11px] font-extrabold text-ink3">{p ? `${POS_WORD[p.position]}주` : '시주'}</Text>
|
||||
{p ? (
|
||||
<>
|
||||
<Text className={`text-center text-[11.5px] font-extrabold ${p.position === 'day' ? 'text-orange' : 'text-ink2'}`}>{p.position === 'day' ? '나' : (p.stem_ten_god ?? '')}</Text>
|
||||
<Char c={p.stem} ko={p.stem_ko} el={p.stem_element} me={p.position === 'day'} />
|
||||
<Char c={p.branch} ko={p.branch_ko} el={p.branch_element} />
|
||||
<Text className="text-center text-[11.5px] font-extrabold text-ink2">{p.branch_ten_god}</Text>
|
||||
{p.position === 'month' && <Text className="text-center text-[10.5px] font-extrabold text-ink3">월령</Text>}
|
||||
</>
|
||||
) : (
|
||||
<View className="flex-1 items-center justify-center rounded-xl px-1" style={{ backgroundColor: soft.soft }}>
|
||||
<Text className="text-center text-[12px] font-extrabold text-ink3">시각 모름</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
<View className="mt-3 border-t border-line pt-2.5">
|
||||
{!!strength && <Note term={strength} word={STRENGTH_WORD[strength] ?? ''} />}
|
||||
{gods.map((g) => (
|
||||
<Note key={g} term={g} word={TEN_GOD_WORD[g]} />
|
||||
))}
|
||||
<Note term="월령" word="태어난 달의 계절 기운. 명식에서 가장 크게 봐요" />
|
||||
</View>
|
||||
{(me.need?.length ?? 0) > 0 && <Text className="mt-2 text-[13px] font-bold text-ink">내 기운에 좋은 날씨: {me.need!.join(' · ')}</Text>}
|
||||
{me.jeol_warning && <Text className="mt-1 text-xs font-semibold text-warn">태어난 날에 절기가 바뀌어요. 태어난 시각을 넣어야 달 기둥이 정확해요.</Text>}
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user