feat: 앱 계정 레벨 — 하루 출석 각, 아바타 Lv 표시, 내 정보 레벨 카드, 내 레벨·레벨업 창, 공유하면 하루 한 번 각, 각을 주는 일 뒤 레벨 다시 받기. 아이콘 목록을 웹 아이콘 전부로 (GA sheet_open level·levelUp)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
skkimandClaude committed 2026-11-04 17:26:21 +09:00
1 parent 01b5f917b9
commit e40a9a0539
16 files changed
+360 -19

No files matched your search

+2 -1
View File
@@ -15,7 +15,7 @@ import { slideBg, SlideView, type Slide } from '@/components/post/slides';
import { Ic, Skel } from '@/components/ui';
import { track } from '@/lib/analytics';
import { useSheet } from '@/lib/sheet';
import { shareView } from '@/lib/share-image';
import { useShare } from '@/lib/share-image';
import { SITE_URL } from '@/lib/site';
const ACCOUNTS: Partial<Record<PostType, readonly [string, string]>> = {
@@ -133,6 +133,7 @@ function FullCard({ post }: PostProps) {
const comments = () => open({ type: 'comments', postId: post.post_id });
const shot = useRef<View>(null);
// 지금 보고 있는 슬라이드를 이미지로
const shareView = useShare();
const share = () => void shareView(shot, { title: post.title, message: `${post.title} · 날씨각 ${SITE_URL}` });
useEffect(() => {
+2 -1
View File
@@ -10,7 +10,7 @@ import { Text } from '@/components/text';
import { Ic } from '@/components/ui';
import { usePinnedLike } from '@/lib/pinned-like';
import { useSheet } from '@/lib/sheet';
import { shareView } from '@/lib/share-image';
import { useShare } from '@/lib/share-image';
import { SITE_URL } from '@/lib/site';
type Props = { title: string; account: string; avatar: string; caption?: string; more?: ReactNode; pinned?: { key: PinnedKey; post?: PostReaction | null }; children: ReactNode };
@@ -22,6 +22,7 @@ export function PostFrame({ title, account, avatar, caption, more, pinned, child
const like = usePinnedLike(pinned?.key ?? 'gak_post', pinned?.post);
const postId = pinned?.post?.post_id;
const shot = useRef<View>(null);
const shareView = useShare();
const share = () => void shareView(shot, { title, message: `${title} · 날씨각 ${SITE_URL}` });
return (
+5 -2
View File
@@ -13,6 +13,7 @@ import { CommentsSheet } from './comments';
import { GakSheet } from './gak';
import { LoginSheet } from './login';
import { MeSheet } from './me';
import { LevelSheet, LevelUpSheet } from './level';
import { RegionSheet } from './region';
import { WeatherWhySheet } from './weather-why';
@@ -36,7 +37,7 @@ export function SheetProvider({ children }: { children: ReactNode }) {
);
}
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', weatherWhy: '날씨 점수는 이렇게 나와요' } as const;
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기', weatherWhy: '날씨 점수는 이렇게 나와요', level: '내 레벨', levelUp: '레벨이 올랐어요' } as const;
/** 판만 아래에서 올라온다 (웹 b-sheet: 0.26초, 40px 아래·흐릿하게에서) */
function Rise({ children }: { children: ReactNode }) {
@@ -90,10 +91,12 @@ function SheetHost({ state: next, onClose }: { state: SheetState; onClose: () =>
{state.type === 'article' && <ArticleSheet articleId={state.articleId} onTitle={setArticleTitle} />}
{state.type === 'seasonWeek' && <SeasonWeekSheet />}
{state.type === 'comments' && <CommentsSheet postId={state.postId} draft={state.draft} />}
{state.type === 'login' && <LoginSheet onDone={onClose} onLoggedIn={then ? () => open(then) : onClose} />}
{state.type === 'login' && <LoginSheet onDone={onClose} onLoggedIn={then ? () => open(then) : onClose} why={state.why} />}
{state.type === 'me' && <MeSheet onDone={onClose} />}
{state.type === 'region' && <RegionSheet onDone={onClose} />}
{state.type === 'weatherWhy' && <WeatherWhySheet d={state.why} />}
{state.type === 'level' && <LevelSheet />}
{state.type === 'levelUp' && <LevelUpSheet level={state.level} />}
</View>
</Rise>
)}
+138
View File
@@ -0,0 +1,138 @@
import { LinearGradient } from 'expo-linear-gradient';
import { Pressable, View } from 'react-native';
import { Text } from '@/components/text';
import { Ic } from '@/components/ui';
import { HIDDEN, josa, levelIcon, nextUnlock, progress, useCloseAndGo, useLevel } from '@/lib/level';
import { useSheet } from '@/lib/sheet';
import { Body, useSoft } from './parts';
// 각을 주는 일 → 그 일을 하러 가는 곳, 숨긴 기능에 딸린 일 (서버 ACTIONS 키, 웹 level.tsx)
const ACTION_TO: Record<string, string> = { saju: '/saju', react: '/', talk: '/talk' };
const ACTION_FEATURE: Record<string, string> = { tarot: 'tarot', checkin: 'tarot' };
function Bar({ value }: { value: number }) {
const s = useSoft();
return (
<View className="h-2 overflow-hidden rounded-full" style={{ backgroundColor: s.bar }}>
<LinearGradient colors={['#ffb27a', '#ff7a45']} start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }} style={{ height: '100%', width: `${Math.round(value * 100)}%`, borderRadius: 999 }} />
</View>
);
}
/** 내 정보 위쪽: 레벨·모은 각·다음 레벨에서 열리는 것. link 가 있으면 '각 모으는 법'으로 내 레벨 창을 연다 */
export function LevelCard({ link = true }: { link?: boolean }) {
const level = useLevel().data;
const { open } = useSheet();
const s = useSoft();
if (!level) return null;
const unlock = nextUnlock(level);
return (
<View accessibilityLabel="내 레벨" className="rounded-2xl px-3.5 py-3" style={{ backgroundColor: s.warm }}>
<View className="flex-row items-center gap-2">
<Ic name={levelIcon(level.level)} size={28} />
<Text className="font-jua text-[16px] text-ink">
Lv.{level.level} {level.name}
</Text>
<Text className="ml-auto font-bagel text-[15px] text-ink">{level.points}각</Text>
</View>
<View className="mt-2">
<Bar value={progress(level)} />
</View>
<View className="mt-1.5 flex-row items-center justify-between gap-2">
<Text className="shrink text-xs font-bold text-ink2">
{level.next_points == null
? '가장 높은 레벨이에요'
: unlock.length > 0
? `${level.next_points - level.points}각 더 모으면 ${josa(unlock.join(', '), '이', '가')} 열려요`
: `${level.next_points - level.points}각 더 모으면 Lv.${level.level + 1} ${level.next_name}`}
</Text>
{link && (
<Pressable onPress={() => open({ type: 'level' })} hitSlop={8} accessibilityRole="button">
<Text className="text-xs font-bold text-orange">각 모으는 법 ›</Text>
</Pressable>
)}
</View>
</View>
);
}
/** 내 레벨 창: 오늘 받을 수 있는 각, 레벨마다 열리는 것 */
export function LevelSheet() {
const level = useLevel().data;
const go = useCloseAndGo();
const s = useSoft();
if (!level) return null;
const steps = (level.unlocks ?? []).reduce<Record<number, string[]>>((m, u) => ({ ...m, [u.level]: [...(m[u.level] ?? []), u.name] }), {});
const actions = (level.today ?? []).filter((a) => !HIDDEN.has(ACTION_FEATURE[a.action] ?? a.action));
return (
<Body className="gap-4">
<LevelCard link={false} />
<View>
<Text className="mb-2 text-sm font-extrabold text-ink">오늘 받을 수 있는 각</Text>
<View className="rounded-2xl border-b-4 border-shade bg-card">
{actions.map((a, i) => {
const done = a.earned >= a.cap;
const to = ACTION_TO[a.action];
return (
<Pressable key={a.action} disabled={!to || done} onPress={() => to && go(to)} className={`flex-row items-center gap-2.5 px-3.5 py-2.5 ${i < actions.length - 1 ? 'border-b border-line' : ''}`}>
<View className={`size-5 items-center justify-center rounded-full ${done ? 'bg-[#1f9d62]' : 'bg-[#dfe5ef]'}`}>{done && <Text className="text-[11px] text-white">✓</Text>}</View>
<Text className={`text-[13.5px] font-bold ${done ? 'text-ink3 line-through' : 'text-ink'}`}>{a.name}</Text>
<Text className="ml-auto font-bagel text-[13px] text-orange">{done ? `오늘 ${a.earned}각 받음` : a.earned > 0 ? `${a.earned}/${a.cap}각` : `+${a.points}각`}</Text>
{!!to && !done && <Text className="text-ink3">›</Text>}
</Pressable>
);
})}
</View>
<Text className="mt-1.5 text-xs font-semibold text-ink3">{level.streak > 0 ? `${level.streak}일째 연속 출석 중 · 7일 연속이면 +50각` : '7일 연속 출석하면 +50각을 더 받아요'}</Text>
</View>
<View>
<Text className="mb-2 text-sm font-extrabold text-ink">레벨이 오르면 열려요</Text>
<View className="gap-1.5">
{(level.levels ?? []).map(({ level: lv, name, points }) => {
const reached = level.level >= lv;
return (
<View key={lv} className="flex-row items-center gap-2.5 rounded-xl px-2.5 py-2" style={lv === level.level ? { backgroundColor: s.warm } : undefined}>
<Ic name={levelIcon(lv)} size={28} style={reached ? undefined : { opacity: 0.4 }} />
<View className="min-w-0 flex-1">
<Text className="text-[13.5px] font-extrabold text-ink">
Lv.{lv} {name} <Text className="font-semibold text-ink3">· {points}각</Text>
</Text>
<Text className="text-xs font-semibold text-ink2">{lv === 1 ? '날씨각의 기본 기능 모두' : (steps[lv] ?? []).join(', ')}</Text>
</View>
</View>
);
})}
</View>
</View>
</Body>
);
}
/** 레벨이 오른 순간 */
export function LevelUpSheet({ level: lv }: { level: number }) {
const level = useLevel().data;
const { open } = useSheet();
const go = useCloseAndGo();
const unlocks = (level?.unlocks ?? []).filter((u) => u.level === lv);
const opened = unlocks.map((u) => u.name);
const name = level?.levels?.find((l) => l.level === lv)?.name;
return (
<Body className="items-center gap-2 px-6 pb-6">
<Ic name={levelIcon(lv)} size={96} />
<Text className="font-jua text-[28px] text-ink">
Lv.{lv} {name}
</Text>
{opened.length > 0 && <Text className="text-center text-[15px] font-bold text-ink2">이제 {josa(opened.join(', '), '을', '를')} 볼 수 있어요</Text>}
{unlocks.length > 0 && (
<Pressable onPress={() => go(`/saju?open=${unlocks[0].key}`)} className="mt-3 w-full rounded-full bg-orange py-3">
<Text className="text-center text-[15px] font-extrabold text-white">{opened[0]} 보러 가기</Text>
</Pressable>
)}
<Pressable onPress={() => open({ type: 'level' })} className={`w-full py-2 ${unlocks.length ? '' : 'mt-3 rounded-full bg-orange py-3'}`}>
<Text className={`text-center text-[14px] font-extrabold ${unlocks.length ? 'text-ink2' : 'text-white'}`}>내 레벨 보기</Text>
</Pressable>
</Body>
);
}
+2 -2
View File
@@ -11,7 +11,7 @@ import { GoogleButton } from './google';
import { MeSheet } from './me';
import { Body, ErrorLine } from './parts';
export function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLoggedIn: () => void }) {
export function LoginSheet({ onDone, onLoggedIn, why }: { onDone: () => void; onLoggedIn: () => void; why?: 'level' }) {
const { me } = useAuth();
const [error, setError] = useState('');
@@ -30,7 +30,7 @@ export function LoginSheet({ onDone, onLoggedIn }: { onDone: () => void; onLogge
return (
<Body className="gap-2.5">
<Text className="text-center text-sm font-semibold text-ink2">글쓰기는 로그인한 뒤에 할 수 있어요.</Text>
<Text className="text-center text-sm font-semibold text-ink2">{why === 'level' ? '로그인하면 출석·사주·좋아요로 각이 쌓여 레벨이 올라요.' : '글쓰기는 로그인한 뒤에 할 수 있어요.'}</Text>
<GoogleButton
onResult={(res) => {
setError('');
+4 -1
View File
@@ -1,5 +1,6 @@
import { clearTokens } from '@nalssigak/shared/api/auth';
import { listBlockedOptions, listBlockedQueryKey, meQueryKey, unblockMutation, updateMeMutation, withdrawMutation } from '@nalssigak/shared/api/client/@tanstack/react-query.gen';
import { AuthProvider } from '@nalssigak/shared/api/client/types.gen';
import { AVATAR_COLORS, CHARACTERS, MOODS } from '@nalssigak/shared/lib';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useState } from 'react';
@@ -10,6 +11,7 @@ import { Avatar, Ic } from '@/components/ui';
import { useAuth } from '@/lib/auth';
import { isCommentList } from './comments';
import { LevelCard } from './level';
import { Body, Field, useSoft } from './parts';
/** 탈퇴: 한 번 더 묻고 지운다. 계정이 없어지니 이 기기 토큰도 지운다 */
@@ -132,8 +134,9 @@ export function MeSheet({ onDone }: { onDone: () => void }) {
<Body className="gap-3">
<View className="items-center gap-1.5">
<Avatar character={me.character} color={me.color} mood={me.mood} size={64} />
<Text className="text-center text-sm font-semibold text-ink2">{me.login_id}(으)로 로그인했어요</Text>
<Text className="text-center text-sm font-semibold text-ink2">{me.provider === AuthProvider.GOOGLE ? '구글 계정으로 로그인했어요' : `${me.login_id}(으)로 로그인했어요`}</Text>
</View>
<LevelCard />
<View accessibilityLabel="내 캐릭터">
<Text className="mb-2 text-sm font-extrabold text-ink">내 캐릭터</Text>
<View className="flex-row flex-wrap gap-2">
+2 -1
View File
@@ -19,7 +19,7 @@ import { Ic, Skel } from '@/components/ui';
import { track } from '@/lib/analytics';
import { usePinnedLike } from '@/lib/pinned-like';
import { useRegion } from '@/lib/region';
import { shareView } from '@/lib/share-image';
import { useShare } from '@/lib/share-image';
import { useSheet } from '@/lib/sheet';
import { SITE_URL } from '@/lib/site';
import { useSky } from '@/lib/sky';
@@ -198,6 +198,7 @@ export function Hero({ hero, post, today, ranked, feedLoad, todayLoad }: Props)
if (v !== tmr) track('hero_day_switch', { day: v ? 'tomorrow' : 'today' });
setTmr(v);
};
const shareView = useShare();
const share = () => {
const title = `${region.name} ${tmr ? '내일' : '오늘'} 날씨`;
void shareView(shot, { title, message: `${title} · 날씨각 ${SITE_URL}` });
+13
View File
@@ -11,6 +11,7 @@ import { useCSSVariable } from 'uniwind';
import { PinIcon } from '@/components/svg';
import { Avatar, Ic, Skel } from '@/components/ui';
import { useAuth } from '@/lib/auth';
import { useLevel } from '@/lib/level';
import { useRegion } from '@/lib/region';
import { useSheet } from '@/lib/sheet';
import { useSky } from '@/lib/sky';
@@ -35,6 +36,17 @@ function SeasonChip() {
);
}
/** 아바타 옆 작은 레벨 표시 */
function LevelBadge() {
const level = useLevel().data;
if (!level) return null;
return (
<View pointerEvents="none" className="absolute -right-1.5 -bottom-1.5 rounded-full border-2 border-white bg-ink-btn px-1.5">
<Text className="text-[9.5px] leading-4 font-extrabold text-white">Lv.{level.level}</Text>
</View>
);
}
/** 오른쪽 끝: 내 정보(아바타) 또는 로그인 버튼 */
function Account() {
const { open } = useSheet();
@@ -44,6 +56,7 @@ function Account() {
return (
<Pressable onPress={() => open({ type: 'me' })} accessibilityLabel={`내 정보, ${me.nickname}`} className="shrink-0 rounded-full" style={{ boxShadow: '0 6px 12px rgb(40 48 74 / 0.12)' }}>
<Avatar character={me.character} color={me.color} mood={me.mood} size={36} />
<LevelBadge />
</Pressable>
);
return (