feat: 앱을 웹과 맞춤 — 좋아요 하트·토스트, 별똥별, 단풍잎, 고운바탕, 안내 높이 유지, 시트 배경 페이드
This commit is contained in:
1 parent
865c521ab8
commit
b5d9adf396
19 files changed
+247
-52
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import '@/lib/api';
|
||||
import { BagelFatOne_400Regular } from '@expo-google-fonts/bagel-fat-one';
|
||||
import { GowunBatang_400Regular } from '@expo-google-fonts/gowun-batang';
|
||||
import { Jua_400Regular, useFonts } from '@expo-google-fonts/jua';
|
||||
import { QueryClientProvider } from '@tanstack/react-query';
|
||||
import { Tabs } from 'expo-router/tabs';
|
||||
@@ -41,7 +42,7 @@ function Shell() {
|
||||
}
|
||||
|
||||
export default function RootLayout() {
|
||||
const [loaded, error] = useFonts({ Jua_400Regular, BagelFatOne_400Regular });
|
||||
const [loaded, error] = useFonts({ Jua_400Regular, BagelFatOne_400Regular, GowunBatang_400Regular });
|
||||
useEffect(() => {
|
||||
if (loaded || error) SplashScreen.hideAsync();
|
||||
}, [loaded, error]);
|
||||
|
||||
@@ -40,13 +40,13 @@ export default function GakScreen() {
|
||||
return (
|
||||
<ScrollView contentContainerClassName="pb-6" refreshControl={<RefreshControl refreshing={q.isRefetching && !q.isPlaceholderData} onRefresh={() => q.refetch()} />}>
|
||||
<Sec title="오늘 1~3위" sub={`${day ? `${day[1]}월 ${day[2]}일 기준 · ` : ''}${region.name}`} />
|
||||
{top.length === 3 ? <Podium top={top} dim={q.isPlaceholderData} /> : load === 'loading' ? <PodiumSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="오늘 1~3위를 아직 못 정했어요." />}
|
||||
{top.length === 3 ? <Podium top={top} dim={q.isPlaceholderData} /> : load === 'loading' ? <PodiumSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="오늘 1~3위를 아직 못 정했어요." hold={<PodiumSkel />} />}
|
||||
<Chips items={CATS} value={cat} onChange={setCat} />
|
||||
{load === 'loading' ? (
|
||||
<GridSkel />
|
||||
) : !items.length ? (
|
||||
// 실패 안내·다시 시도는 위 받침대 자리에 한 번만
|
||||
<StateBox load="ready" empty={load === 'ready' ? '이 분야는 오늘 계산된 각이 없어요.' : '각 목록을 불러오지 못했어요.'} />
|
||||
<StateBox load="ready" empty={load === 'ready' ? '이 분야는 오늘 계산된 각이 없어요.' : '각 목록을 불러오지 못했어요.'} hold={<GridSkel />} boxClassName="inset-3" />
|
||||
) : (
|
||||
<GakGrid items={items} dim={q.isPlaceholderData} />
|
||||
)}
|
||||
|
||||
@@ -38,14 +38,27 @@ export default function TodayScreen() {
|
||||
<ScrollView key={region.code} contentContainerClassName="pb-6" refreshControl={<RefreshControl refreshing={feed.isRefetching && !feed.isPlaceholderData} onRefresh={refresh} />} style={{ opacity: feed.isPlaceholderData ? 0.6 : 1 }}>
|
||||
<Hero hero={f?.hero} today={today.data} ranked={stories} feedLoad={load} todayLoad={loadOf(today)} />
|
||||
<Sec title="오늘의 각" sub="누르면 계산 근거를 보여 줘요" more="/gak" />
|
||||
{stories.length ? <Stories items={stories} /> : load === 'loading' ? <StoriesSkel /> : <StateBox load={load} onRetry={() => feed.refetch()} empty="오늘 계산된 각이 없어요." />}
|
||||
{stories.length ? <Stories items={stories} /> : load === 'loading' ? <StoriesSkel /> : <StateBox load={load} onRetry={() => feed.refetch()} empty="오늘 계산된 각이 없어요." hold={<StoriesSkel />} boxClassName="inset-x-3 top-3 bottom-1" />}
|
||||
{load === 'loading' && (
|
||||
<>
|
||||
<PostCardSkel />
|
||||
<PostCardSkel />
|
||||
</>
|
||||
)}
|
||||
{load !== 'loading' && !posts.length && <StateBox load={load === 'ready' ? 'ready' : load} onRetry={() => feed.refetch()} empty="오늘 올라온 글이 아직 없어요." />}
|
||||
{/* 글이 없거나 못 받아도 스켈레톤 두 장 자리는 그대로 둔다. 다시 시도는 위 각 줄에 한 번만 */}
|
||||
{load !== 'loading' && !posts.length && (
|
||||
<StateBox
|
||||
load="ready"
|
||||
empty={load === 'ready' ? '오늘 올라온 글이 아직 없어요.' : '글을 불러오지 못했어요.'}
|
||||
hold={
|
||||
<>
|
||||
<PostCardSkel />
|
||||
<PostCardSkel />
|
||||
</>
|
||||
}
|
||||
boxClassName="inset-x-3 top-3.5"
|
||||
/>
|
||||
)}
|
||||
{posts.map((p, i) => (
|
||||
<Fragment key={p.post_id}>
|
||||
<PostCard post={p} />
|
||||
|
||||
@@ -31,11 +31,11 @@ export default function SeasonScreen() {
|
||||
|
||||
return (
|
||||
<ScrollView contentContainerClassName="pb-6" refreshControl={<RefreshControl refreshing={(week.isRefetching || arts.isRefetching) && !arts.isPlaceholderData} onRefresh={refresh} />}>
|
||||
{w?.headline ? <SeasonHead week={w} onPress={() => open({ type: 'seasonWeek' })} /> : weekLoad === 'loading' ? <HeadSkel /> : <StateBox load={weekLoad} onRetry={() => week.refetch()} empty="이번 주 특집이 아직 없어요." />}
|
||||
{w?.headline ? <SeasonHead week={w} onPress={() => open({ type: 'seasonWeek' })} /> : weekLoad === 'loading' ? <HeadSkel /> : <StateBox load={weekLoad} onRetry={() => week.refetch()} empty="이번 주 특집이 아직 없어요." hold={<HeadSkel />} />}
|
||||
<Chips items={CATS} value={cat} onChange={setCat} />
|
||||
<View className="mt-1.5" style={{ opacity: arts.isPlaceholderData ? 0.6 : 1 }}>
|
||||
{artLoad === 'loading' && <RowsSkel />}
|
||||
{artLoad !== 'loading' && !list.length && <StateBox load={artLoad} onRetry={() => arts.refetch()} empty="읽을거리가 아직 없어요." />}
|
||||
{artLoad !== 'loading' && !list.length && <StateBox load={artLoad} onRetry={() => arts.refetch()} empty="읽을거리가 아직 없어요." hold={<RowsSkel />} boxClassName="inset-3" />}
|
||||
{list.map((a) => (
|
||||
<ArticleRow key={a.article_id} article={a} onPress={() => open({ type: 'article', articleId: a.article_id })} />
|
||||
))}
|
||||
|
||||
+25
-5
@@ -5,12 +5,32 @@ import { useState } from 'react';
|
||||
import { RefreshControl, ScrollView, View } from 'react-native';
|
||||
|
||||
import { DayTiles, Li, LiSkel, ScoreHelp, SkyHero, Timeline } from '@/components/sky/parts';
|
||||
import { Sec, StateBox } from '@/components/ui';
|
||||
import { Sec, Skel, StateBox } from '@/components/ui';
|
||||
import { useRegion } from '@/lib/region';
|
||||
|
||||
const THREE = [0, 1, 2];
|
||||
const RANK_SKELS = Array.from({ length: 8 }, (_, i) => i);
|
||||
|
||||
/** 히어로 글자 자리 (실패·빈 안내를 같은 높이로 띄우려고) */
|
||||
function HeroHold() {
|
||||
return (
|
||||
<View>
|
||||
<Skel className="h-7 w-[230px]" />
|
||||
<Skel className="mt-2 w-[180px]" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function LiSkels({ n }: { n: number[] }) {
|
||||
return (
|
||||
<View className="mx-3 mt-1.5">
|
||||
{n.map((i) => (
|
||||
<LiSkel key={i} last={i === n.length - 1} />
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default function SkyScreen() {
|
||||
const { region } = useRegion();
|
||||
const sky = useQuery(getSkyOptions({ query: { region: region.code } }));
|
||||
@@ -32,13 +52,13 @@ export default function SkyScreen() {
|
||||
<SkyHero plan={plan} />
|
||||
) : (
|
||||
<SkyHero>
|
||||
<StateBox load={load} onRetry={() => sky.refetch()} empty="오늘 노을 정보가 없어요." />
|
||||
<StateBox load={load} onRetry={() => sky.refetch()} empty="오늘 노을 정보가 없어요." hold={<HeroHold />} boxClassName="inset-x-0 top-1.5 bottom-0" />
|
||||
</SkyHero>
|
||||
)}
|
||||
{plans.length > 1 && <DayTiles plans={plans} day={plan?.day} onPick={setPicked} />}
|
||||
{plan && <ScoreHelp plan={plan} />}
|
||||
<Sec title="언제 보면 좋을까" />
|
||||
{plan?.timeline?.length || load === 'loading' ? <Timeline rows={plan?.timeline} kind={plan?.kind} /> : <StateBox load="ready" empty={load === 'ready' ? '노을 시간 정보가 없어요.' : '노을 시간을 불러오지 못했어요.'} />}
|
||||
{plan?.timeline?.length || load === 'loading' ? <Timeline rows={plan?.timeline} kind={plan?.kind} /> : <StateBox load="ready" empty={load === 'ready' ? '노을 시간 정보가 없어요.' : '노을 시간을 불러오지 못했어요.'} hold={<Timeline />} />}
|
||||
{!rise && <Sec title="가까운 노을 명소" sub="가까운 순 · 방향은 내 동네에서 본 쪽" />}
|
||||
{rise ? null : spots.length ? (
|
||||
<View className="mx-3 mt-1.5">
|
||||
@@ -58,7 +78,7 @@ export default function SkyScreen() {
|
||||
</View>
|
||||
) : (
|
||||
// 실패 안내·다시 시도는 위 히어로에 한 번만
|
||||
<StateBox load="ready" empty={load === 'ready' ? '근처에 등록된 노을 명소가 없어요.' : '명소 정보를 불러오지 못했어요.'} />
|
||||
<StateBox load="ready" empty={load === 'ready' ? '근처에 등록된 노을 명소가 없어요.' : '명소 정보를 불러오지 못했어요.'} hold={<LiSkels n={THREE} />} />
|
||||
)}
|
||||
<Sec title="전국 노을 순위" sub={ranking.data?.summary ?? '오늘 기준'} />
|
||||
{items.length ? (
|
||||
@@ -74,7 +94,7 @@ export default function SkyScreen() {
|
||||
))}
|
||||
</View>
|
||||
) : (
|
||||
<StateBox load={rankLoad} onRetry={() => ranking.refetch()} empty="순위가 아직 없어요." />
|
||||
<StateBox load={rankLoad} onRetry={() => ranking.refetch()} empty="순위가 아직 없어요." hold={<LiSkels n={RANK_SKELS} />} boxClassName="inset-x-3 top-1.5 bottom-0" />
|
||||
)}
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
+14
-4
@@ -66,7 +66,17 @@ export default function WeekScreen() {
|
||||
<PickSkel />
|
||||
</>
|
||||
) : (
|
||||
<StateBox load={weekLoad} onRetry={() => week.refetch()} empty="날씨가 아직 없어요." />
|
||||
<StateBox
|
||||
load={weekLoad}
|
||||
onRetry={() => week.refetch()}
|
||||
empty="날씨가 아직 없어요."
|
||||
hold={
|
||||
<>
|
||||
<DaysSkel />
|
||||
<PickSkel />
|
||||
</>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{sel && (
|
||||
<View ref={pickShot} collapsable={false}>
|
||||
@@ -97,7 +107,7 @@ export default function WeekScreen() {
|
||||
) : placeLoad === 'loading' ? (
|
||||
<PlacesSkel />
|
||||
) : (
|
||||
<StateBox load={placeLoad} onRetry={() => places.refetch()} empty={sel ? '30km 안에 데이트 명소가 아직 없어요.' : '날씨를 불러오면 명소를 골라 드려요.'} />
|
||||
<StateBox load={placeLoad} onRetry={() => places.refetch()} empty={sel ? '30km 안에 데이트 명소가 아직 없어요.' : '날씨를 불러오면 명소를 골라 드려요.'} hold={<PlacesSkel />} />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
@@ -116,7 +126,7 @@ export default function WeekScreen() {
|
||||
) : rankLoad === 'loading' ? (
|
||||
<RankSkel />
|
||||
) : (
|
||||
<StateBox load={rankLoad} onRetry={() => ranking.refetch()} empty="주말 예보가 아직 없어요." />
|
||||
<StateBox load={rankLoad} onRetry={() => ranking.refetch()} empty="주말 예보가 아직 없어요." hold={<RankSkel />} boxClassName="inset-x-3 top-1.5 bottom-0" />
|
||||
)}
|
||||
<Sec title="가까운 축제·행사" sub="30km 안 · 앞으로 30일 · 그날 날씨까지 같이 봐요" />
|
||||
{eventList.length ? (
|
||||
@@ -128,7 +138,7 @@ export default function WeekScreen() {
|
||||
) : eventLoad === 'loading' ? (
|
||||
<EventsSkel />
|
||||
) : (
|
||||
<StateBox load={eventLoad} onRetry={() => events.refetch()} empty="30km 안에 열리는 행사가 아직 없어요. 다른 지역을 골라 보세요." />
|
||||
<StateBox load={eventLoad} onRetry={() => events.refetch()} empty="30km 안에 열리는 행사가 아직 없어요. 다른 지역을 골라 보세요." hold={<EventsSkel />} boxClassName="inset-x-3 top-2.5 bottom-0" />
|
||||
)}
|
||||
{/* 행사 수가 정해진 뒤에 붙여 목록이 늘어날 때 밀리지 않게 */}
|
||||
{eventLoad !== 'loading' && (
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import { useEffect } from 'react';
|
||||
import { View } from 'react-native';
|
||||
import Animated, { Easing, interpolate, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
|
||||
import Svg, { Path } from 'react-native-svg';
|
||||
|
||||
import { HEART } from '@/components/post/icons';
|
||||
|
||||
// 튀어 나가는 작은 하트: x·y 이동, 회전, 색 (웹 BURST)
|
||||
const BURST: [number, number, number, string][] = [
|
||||
[-86, -60, -24, '#ff3b5c'],
|
||||
[84, -66, 22, '#ff8e4e'],
|
||||
[-104, 18, -40, '#ffc86e'],
|
||||
[102, 24, 36, '#ff3b5c'],
|
||||
[-48, -104, -8, '#ff8aa0'],
|
||||
[52, -100, 12, '#ffc86e'],
|
||||
];
|
||||
|
||||
function Bit({ dx, dy, rot, color }: { dx: number; dy: number; rot: number; color: string }) {
|
||||
const p = useSharedValue(0);
|
||||
useEffect(() => {
|
||||
p.value = withDelay(80, withTiming(1, { duration: 900, easing: Easing.bezier(0.2, 0.8, 0.3, 1) }));
|
||||
}, [p]);
|
||||
const style = useAnimatedStyle(() => ({
|
||||
opacity: interpolate(p.value, [0, 0.25, 1], [0, 1, 0]),
|
||||
transform: [{ translateX: dx * p.value }, { translateY: dy * p.value }, { scale: interpolate(p.value, [0, 1], [0.4, 1.1]) }, { rotate: `${rot * p.value}deg` }],
|
||||
}));
|
||||
return (
|
||||
<Animated.View style={[{ position: 'absolute' }, style]}>
|
||||
<Svg viewBox="0 0 24 24" width={20} height={20} fill={color}>
|
||||
<Path d={HEART} />
|
||||
</Svg>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
function Toast() {
|
||||
const p = useSharedValue(0);
|
||||
useEffect(() => {
|
||||
p.value = withTiming(1, { duration: 1300, easing: Easing.bezier(0.2, 0.9, 0.3, 1) });
|
||||
}, [p]);
|
||||
const style = useAnimatedStyle(() => ({
|
||||
opacity: interpolate(p.value, [0, 0.18, 0.78, 1], [0, 1, 1, 0]),
|
||||
transform: [{ translateY: interpolate(p.value, [0, 0.18, 0.78, 1], [14, 0, 0, -8]) }, { scale: interpolate(p.value, [0, 0.18, 0.3, 1], [0.85, 1.06, 1, 1]) }],
|
||||
}));
|
||||
return (
|
||||
<Animated.View className="absolute top-[58%] rounded-full bg-white px-4 py-2" style={[{ boxShadow: '0 8px 18px rgb(40 48 74 / 0.18)' }, style]}>
|
||||
<Animated.Text className="font-jua text-[17px] text-heart">좋아요했어요!</Animated.Text>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 좋아요 때 하트 조각이 튀어 나가고 '좋아요했어요!' 가 떴다 사라진다 */
|
||||
export function LikeBurst() {
|
||||
const reduce = useReducedMotion();
|
||||
if (reduce) return null;
|
||||
return (
|
||||
<View pointerEvents="none" className="absolute inset-0 items-center justify-center" accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
|
||||
{BURST.map(([dx, dy, rot, color], k) => (
|
||||
<Bit key={k} dx={dx} dy={dy} rot={rot} color={color} />
|
||||
))}
|
||||
<Toast />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import Svg, { Path } from 'react-native-svg';
|
||||
import { useCSSVariable } from 'uniwind';
|
||||
|
||||
import { CommentIcon, HEART, HeartIcon, SendIcon } from '@/components/post/icons';
|
||||
import { LikeBurst } from '@/components/post/like-burst';
|
||||
import { Dots, Pager } from '@/components/post/pager';
|
||||
import { slideBg, SlideView } from '@/components/post/slides';
|
||||
import { Ic, Skel } from '@/components/ui';
|
||||
@@ -197,6 +198,7 @@ function FullCard({ post }: PostProps) {
|
||||
</View>
|
||||
)}
|
||||
{pop > 0 && <HeartPop key={pop} />}
|
||||
{pop > 0 && <LikeBurst key={`b${pop}`} />}
|
||||
{likeFailed > 0 && (
|
||||
<View pointerEvents="none" className="absolute inset-x-0 bottom-4 items-center px-4" accessibilityRole="alert">
|
||||
<Text className="overflow-hidden rounded-full bg-[rgb(30_36_56/0.82)] px-3.5 py-2 text-[13px] font-bold text-white">{liked ? '좋아요를 취소하지 못했어요' : '좋아요를 반영하지 못했어요'}. 다시 해 주세요.</Text>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ARTICLE_LABEL, cardBg, dateRange, shortDay } from '@nalssigak/shared/li
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
|
||||
import { Fall } from '@/components/fall';
|
||||
import { Credit, Ic, Skel, Thumb } from '@/components/ui';
|
||||
import { CARD_BG } from '@/lib/colors';
|
||||
import { useSky } from '@/lib/sky';
|
||||
@@ -54,10 +55,12 @@ export function SeasonHead({ week: w, onPress }: { week: ResSeasonWeek; onPress:
|
||||
return (
|
||||
<Pressable onPress={onPress} className={HEAD_BOX}>
|
||||
<LinearGradient colors={CARD_BG[night ? 'night' : 'day'].peach} style={{ position: 'absolute', inset: 0 }} />
|
||||
<Ic name="maple" size={140} style={{ position: 'absolute', top: '18%', right: 14, width: '38%' }} />
|
||||
<Fall d={100} f={4800} style={{ position: 'absolute', top: '18%', right: 14, width: '38%', alignItems: 'center' }}>
|
||||
<Ic name="maple" size={140} />
|
||||
</Fall>
|
||||
<Text className="text-[13px] font-extrabold text-ink opacity-75">이번 주 특집{w.start && w.end ? ` · ${dateRange(w.start, w.end)}` : ''}</Text>
|
||||
<Text className="mt-1 max-w-[62%] font-jua text-[29px] leading-tight text-ink">{w.headline}</Text>
|
||||
{poem.length > 0 && <Text className="mt-auto max-w-[72%] pt-3 text-[22px] leading-[37px] text-ink">{poem.join('\n')}</Text>}
|
||||
{poem.length > 0 && <Text className="mt-auto max-w-[72%] pt-3 font-batang text-[22px] leading-[37px] text-ink">{poem.join('\n')}</Text>}
|
||||
{w.term_now && w.term_next && (
|
||||
<View className={`max-w-[70%] ${poem.length ? 'mt-2.5' : 'mt-auto'}`}>
|
||||
<View className="flex-row justify-between">
|
||||
|
||||
@@ -22,7 +22,7 @@ export function ArticleSheet({ articleId, onTitle }: { articleId: number; onTitl
|
||||
}, [a, onTitle]);
|
||||
|
||||
const load = loadOf(q);
|
||||
if (!a) return <Body>{load === 'loading' ? <ArticleSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="글을 찾지 못했어요." />}</Body>;
|
||||
if (!a) return <Body>{load === 'loading' ? <ArticleSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="글을 찾지 못했어요." hold={<ArticleSkel />} boxClassName="inset-0" />}</Body>;
|
||||
return (
|
||||
<Body>
|
||||
<Thumb image={a.image} icon={a.icon} iconSize={96} className="mb-3.5 h-[150px] rounded-[20px]">
|
||||
@@ -46,7 +46,7 @@ export function SeasonWeekSheet() {
|
||||
const q = useQuery(getSeasonWeekOptions());
|
||||
const w = q.data;
|
||||
const load = loadOf(q);
|
||||
if (!w?.headline) return <Body>{load === 'loading' ? <ArticleSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="이번 주 특집이 아직 없어요." />}</Body>;
|
||||
if (!w?.headline) return <Body>{load === 'loading' ? <ArticleSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="이번 주 특집이 아직 없어요." hold={<ArticleSkel />} boxClassName="inset-0" />}</Body>;
|
||||
return (
|
||||
<Body>
|
||||
<View className="mb-3.5 h-[150px] items-center justify-center overflow-hidden rounded-[20px]">
|
||||
@@ -57,7 +57,7 @@ export function SeasonWeekSheet() {
|
||||
<Text className="mt-1.5 mb-2.5 font-jua text-2xl leading-tight text-ink">{w.headline}</Text>
|
||||
{(w.poem_lines ?? []).length > 0 && (
|
||||
<View className="mb-2.5">
|
||||
<Text className="text-[17px] leading-[1.7] text-ink" style={{ fontFamily: 'serif' }}>
|
||||
<Text className="font-batang text-[17px] leading-[29px] text-ink">
|
||||
{w.poem_lines?.join(' ')}
|
||||
</Text>
|
||||
{w.author && <Text className="text-xs font-semibold text-ink3">{w.author}</Text>}
|
||||
|
||||
@@ -190,7 +190,7 @@ export function CommentsSheet({ postId, draft }: { postId: number; draft?: strin
|
||||
) : loadOf(list) === 'loading' ? (
|
||||
<CommentsSkel />
|
||||
) : (
|
||||
<StateBox load={loadOf(list)} onRetry={() => list.refetch()} empty="아직 댓글이 없어요. 첫 댓글을 남겨 보세요." />
|
||||
<StateBox load={loadOf(list)} onRetry={() => list.refetch()} empty="아직 댓글이 없어요. 첫 댓글을 남겨 보세요." hold={<CommentsSkel />} boxClassName="inset-0" />
|
||||
)}
|
||||
</Body>
|
||||
<View className="flex-row justify-around pt-1" accessibilityLabel="빠른 이모지">
|
||||
|
||||
@@ -110,7 +110,7 @@ export function GakSheet({ indexId, onTitle }: { indexId: number; onTitle: (t: s
|
||||
}, [g, onTitle]);
|
||||
|
||||
const load = loadOf(q);
|
||||
if (!g) return <Body>{load === 'loading' ? <GakSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="이 각의 계산 근거가 아직 없어요." />}</Body>;
|
||||
if (!g) return <Body>{load === 'loading' ? <GakSkel /> : <StateBox load={load} onRetry={() => q.refetch()} empty="이 각의 계산 근거가 아직 없어요." hold={<GakSkel />} boxClassName="inset-0" />}</Body>;
|
||||
const factors = d.factors ?? [];
|
||||
const bands = d.bands ?? [];
|
||||
const now = bands.find((b) => b.current);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { subscribeAuth } from '@nalssigak/shared/api/auth';
|
||||
import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react';
|
||||
import { KeyboardAvoidingView, Modal, Platform, Pressable, Text, View } from 'react-native';
|
||||
import Animated, { Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from 'react-native-reanimated';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
|
||||
import { SheetContext, useSheet, type SheetState } from '@/lib/sheet';
|
||||
@@ -31,8 +32,29 @@ export function SheetProvider({ children }: { children: ReactNode }) {
|
||||
|
||||
const TITLES = { article: '읽을거리', seasonWeek: '이번 주 특집', comments: '댓글', login: '로그인', me: '내 정보', region: '지역 바꾸기' } as const;
|
||||
|
||||
/** 아래에서 올라오는 창. 바깥을 누르거나 뒤로 가기(안드로이드)로 닫는다 */
|
||||
function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void }) {
|
||||
/** 판만 아래에서 올라온다 (웹 b-sheet: 0.26초, 40px 아래·흐릿하게에서) */
|
||||
function Rise({ children }: { children: ReactNode }) {
|
||||
const reduce = useReducedMotion();
|
||||
const p = useSharedValue(reduce ? 1 : 0);
|
||||
useEffect(() => {
|
||||
p.value = withTiming(1, { duration: 260, easing: Easing.bezier(0.2, 0.9, 0.3, 1) });
|
||||
}, [p]);
|
||||
const anim = useAnimatedStyle(() => ({ opacity: 0.4 + 0.6 * p.value, transform: [{ translateY: 40 * (1 - p.value) }] }));
|
||||
return <Animated.View style={[{ width: '100%', maxHeight: '86%', alignItems: 'center' }, anim]}>{children}</Animated.View>;
|
||||
}
|
||||
|
||||
/** 아래에서 올라오는 창. 배경은 제자리에서 서서히. 바깥을 누르거나 뒤로 가기(안드로이드)로 닫는다 */
|
||||
function SheetHost({ state: next, onClose }: { state: SheetState; onClose: () => void }) {
|
||||
// 닫는 동안(배경이 사라지는 동안)에도 마지막 내용을 그대로 보여 준다. 열 때마다 판을 새로 올린다
|
||||
const [last, setLast] = useState<SheetState>(next);
|
||||
const [isOpen, setIsOpen] = useState(next != null);
|
||||
const [opens, setOpens] = useState(0);
|
||||
if (next && next !== last) setLast(next);
|
||||
if ((next != null) !== isOpen) {
|
||||
setIsOpen(next != null);
|
||||
if (next) setOpens((n) => n + 1);
|
||||
}
|
||||
const state = next ?? last;
|
||||
const { open } = useSheet();
|
||||
const { bottom } = useSafeAreaInsets();
|
||||
const [gakTitle, setGakTitle] = useState('');
|
||||
@@ -42,28 +64,30 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
|
||||
const title = !state ? '' : state.type === 'gak' ? gakTitle : state.type === 'article' ? articleTitle || TITLES.article : TITLES[state.type];
|
||||
|
||||
return (
|
||||
<Modal visible={state != null} transparent animationType="slide" onRequestClose={onClose} statusBarTranslucent>
|
||||
<Modal visible={next != null} transparent animationType="fade" onRequestClose={onClose} statusBarTranslucent>
|
||||
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} className="flex-1 justify-end">
|
||||
<Pressable onPress={onClose} accessibilityLabel="닫기" className="absolute inset-0 bg-[rgb(20_26_45/0.45)]" />
|
||||
{state && (
|
||||
<View accessibilityViewIsModal accessibilityLabel={title} className="max-h-[86%] w-full max-w-[440px] self-center rounded-t-[22px] bg-card" style={{ paddingBottom: bottom }}>
|
||||
<View className="border-b border-line px-4 pt-2 pb-2.5">
|
||||
<View className="mb-2.5 h-1 w-10 self-center rounded-full bg-line" />
|
||||
<Text numberOfLines={1} className="px-10 text-center text-[15px] font-extrabold text-ink">
|
||||
{title}
|
||||
</Text>
|
||||
<Pressable onPress={onClose} hitSlop={10} accessibilityRole="button" accessibilityLabel="닫기" className="absolute right-3 bottom-2 size-[30px] items-center justify-center">
|
||||
<Text className="text-xl text-ink2">×</Text>
|
||||
</Pressable>
|
||||
<Rise key={opens}>
|
||||
<View accessibilityViewIsModal accessibilityLabel={title} className="w-full max-w-[440px] rounded-t-[22px] bg-card" style={{ paddingBottom: bottom }}>
|
||||
<View className="border-b border-line px-4 pt-2 pb-2.5">
|
||||
<View className="mb-2.5 h-1 w-10 self-center rounded-full bg-line" />
|
||||
<Text numberOfLines={1} className="px-10 text-center text-[15px] font-extrabold text-ink">
|
||||
{title}
|
||||
</Text>
|
||||
<Pressable onPress={onClose} hitSlop={10} accessibilityRole="button" accessibilityLabel="닫기" className="absolute right-3 bottom-2 size-[30px] items-center justify-center">
|
||||
<Text className="text-xl text-ink2">×</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
{state.type === 'gak' && <GakSheet indexId={state.indexId} onTitle={setGakTitle} />}
|
||||
{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 === 'me' && <MeSheet onDone={onClose} />}
|
||||
{state.type === 'region' && <RegionSheet onDone={onClose} />}
|
||||
</View>
|
||||
{state.type === 'gak' && <GakSheet indexId={state.indexId} onTitle={setGakTitle} />}
|
||||
{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 === 'me' && <MeSheet onDone={onClose} />}
|
||||
{state.type === 'region' && <RegionSheet onDone={onClose} />}
|
||||
</View>
|
||||
</Rise>
|
||||
)}
|
||||
</KeyboardAvoidingView>
|
||||
</Modal>
|
||||
|
||||
@@ -55,7 +55,7 @@ export function RegionSheet({ onDone }: { onDone: () => void }) {
|
||||
</Text>
|
||||
<Field round value={q} onChangeText={setQ} placeholder="구 이름으로 찾기 (예: 마포)" accessibilityLabel="구 이름으로 찾기" />
|
||||
{listLoad === 'loading' && <RegionsSkel />}
|
||||
{listLoad !== 'loading' && !regions.length && <StateBox load={listLoad} onRetry={() => list.refetch()} empty="찾는 구가 없어요." />}
|
||||
{listLoad !== 'loading' && !regions.length && (listLoad === 'ready' ? <StateBox load={listLoad} empty="찾는 구가 없어요." /> : <StateBox load={listLoad} onRetry={() => list.refetch()} hold={<RegionsSkel />} boxClassName="inset-x-0 top-2 bottom-0" />)}
|
||||
<View className={`mt-2 ${list.isPlaceholderData ? 'opacity-60' : ''}`}>
|
||||
{regions.map((r) => {
|
||||
const here = r.code === region.code;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { TimeKind } from '@nalssigak/shared/lib';
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import { useEffect } from 'react';
|
||||
import { StyleSheet, View } from 'react-native';
|
||||
import Animated, { cancelAnimation, Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated';
|
||||
import { StyleSheet, View, type DimensionValue } from 'react-native';
|
||||
import Animated, { cancelAnimation, Easing, interpolate, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated';
|
||||
|
||||
import { useSky } from '@/lib/sky';
|
||||
|
||||
@@ -43,7 +43,40 @@ function Star({ star, reduce }: { star: (typeof STARS)[number]; reduce: boolean
|
||||
return <Animated.View style={[{ position: 'absolute', left: star.left, top: star.top, width: star.size, height: star.size, borderRadius: star.size, backgroundColor: '#fff', boxShadow: '0 0 6px rgb(255 255 255 / 0.8)' }, style]} />;
|
||||
}
|
||||
|
||||
/** 화면 전체 하늘: 시간대별 색이 서서히 바뀌고, 밤에는 별이 반짝인다 */
|
||||
export type ShootSpec = { top: DimensionValue; left: DimensionValue; len: number; dur: number; dl: number };
|
||||
|
||||
// 별똥별: 위치·길이·주기를 엇갈려 몇 초마다 하나씩 떨어지게 (웹 BLayout SHOOTS, 밀리초)
|
||||
const SHOOTS: ShootSpec[] = [
|
||||
{ top: '8%', left: '78%', len: 110, dur: 7000, dl: 1000 },
|
||||
{ top: '22%', left: '46%', len: 80, dur: 9000, dl: 3500 },
|
||||
{ top: '5%', left: '30%', len: 95, dur: 8000, dl: 5500 },
|
||||
{ top: '36%', left: '88%', len: 70, dur: 10000, dl: 2200 },
|
||||
{ top: '52%', left: '62%', len: 90, dur: 11000, dl: 7000 },
|
||||
{ top: '14%', left: '96%', len: 120, dur: 12000, dl: 9000 },
|
||||
];
|
||||
|
||||
/** 별똥별 하나: 주기 끝 14% 동안만 비스듬히 240px 미끄러지며 반짝 (웹 .b-shoot). 동작 줄이기면 그리지 않는다 */
|
||||
export function Shoot({ top, left, len, dur, dl }: ShootSpec) {
|
||||
const reduce = useReducedMotion();
|
||||
const p = useSharedValue(0);
|
||||
useEffect(() => {
|
||||
if (reduce) return;
|
||||
p.value = withDelay(dl, withRepeat(withTiming(1, { duration: dur, easing: Easing.in(Easing.ease) }), -1, false));
|
||||
return () => cancelAnimation(p);
|
||||
}, [reduce, dur, dl, p]);
|
||||
const style = useAnimatedStyle(() => ({
|
||||
opacity: interpolate(p.value, [0, 0.86, 0.89, 1], [0, 0, 1, 0]),
|
||||
transform: [{ rotate: '-24deg' }, { translateX: interpolate(p.value, [0, 0.86, 1], [0, 0, -240]) }],
|
||||
}));
|
||||
if (reduce) return null;
|
||||
return (
|
||||
<Animated.View style={[{ position: 'absolute', top, left, width: len, height: 1.5 }, style]}>
|
||||
<LinearGradient colors={['rgba(255,255,255,0)', '#ffffff']} start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }} style={{ flex: 1, borderRadius: 2 }} />
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 화면 전체 하늘: 시간대별 색이 서서히 바뀌고, 밤에는 별이 반짝이고 별똥별이 떨어진다 */
|
||||
export function SkyBg() {
|
||||
const { kind } = useSky();
|
||||
const reduce = useReducedMotion();
|
||||
@@ -53,6 +86,7 @@ export function SkyBg() {
|
||||
<Layer key={k} kind={k} on={k === kind} reduce={reduce} />
|
||||
))}
|
||||
{kind === 'night' && STARS.map((s, i) => <Star key={i} star={s} reduce={reduce} />)}
|
||||
{kind === 'night' && SHOOTS.map((s, i) => <Shoot key={i} {...s} />)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { LinearGradient } from 'expo-linear-gradient';
|
||||
import Svg, { Defs, Path, RadialGradient, Rect, Stop } from 'react-native-svg';
|
||||
|
||||
import { Fall } from '@/components/fall';
|
||||
import { Shoot, type ShootSpec } from '@/components/sky-bg';
|
||||
import { Ic, Skel } from '@/components/ui';
|
||||
import { useSheet } from '@/lib/sheet';
|
||||
import { useSky } from '@/lib/sky';
|
||||
@@ -31,6 +32,13 @@ const ORB: Record<'sun' | 'sunset' | 'night', { stops: [string, string, string,
|
||||
const STARS = Array.from({ length: 26 }, (_, i) => ({ left: `${(i * 37) % 100}%`, top: `${(i * 53) % 60}%`, opacity: 0.4 + ((i * 7) % 6) / 10 }) as const);
|
||||
|
||||
// 구름 자리·떨어지는 지연·둥둥 주기 (웹 CLOUDS). 구름 수: 구름 많음 둘, 흐림·비·눈 셋
|
||||
// 별똥별 셋: 위치·길이·주기를 엇갈려 하나씩 떨어지게 (웹 TodayPage SHOOTS, 밀리초)
|
||||
const SHOOTS: ShootSpec[] = [
|
||||
{ top: '6%', left: '80%', len: 90, dur: 7000, dl: 1500 },
|
||||
{ top: '20%', left: '52%', len: 70, dur: 9000, dl: 4000 },
|
||||
{ top: '34%', left: '94%', len: 80, dur: 11000, dl: 6500 },
|
||||
];
|
||||
|
||||
const CLOUDS = [
|
||||
{ top: 36, left: '5%', w: 84, h: 32, d: 100, f: 6000 },
|
||||
{ top: 96, left: '63%', w: 96, h: 36, d: 250, f: 6400 },
|
||||
@@ -136,6 +144,7 @@ export function Hero({ hero, today, ranked, feedLoad, todayLoad }: Props) {
|
||||
<View className="mx-3 mt-1 overflow-hidden rounded-[28px] px-4 pt-3 pb-3">
|
||||
<LinearGradient colors={HERO_BG[gray ? 'gray' : kind]} locations={kind === 'night' ? [0, 0.6, 1] : [0, 0.5, 1]} style={{ position: 'absolute', inset: 0 }} />
|
||||
{kind === 'night' && STARS.map((s, i) => <View key={i} className="absolute size-[3px] rounded-full bg-white" style={{ left: s.left, top: s.top, opacity: s.opacity }} />)}
|
||||
{kind === 'night' && SHOOTS.map((s, i) => <Shoot key={i} {...s} />)}
|
||||
{(rain || snow) && (
|
||||
<View pointerEvents="none" style={{ position: 'absolute', inset: 0 }}>
|
||||
{rain && DROPS.map((p, i) => <Particle key={`r${i}`} {...p} snow={false} light={dark} />)}
|
||||
|
||||
@@ -81,13 +81,17 @@ export function Rail({ children }: { children: ReactNode }) {
|
||||
);
|
||||
}
|
||||
|
||||
/** 실패·빈 목록 안내. 불러오는 중엔 그리지 않는다(그 자리는 스켈레톤) */
|
||||
export function StateBox({ load, onRetry, empty }: { load: Load; onRetry?: () => void; empty?: string }) {
|
||||
/**
|
||||
* 실패·빈 목록 안내. 불러오는 중엔 그리지 않는다(그 자리는 스켈레톤).
|
||||
* hold 에 스켈레톤을 주면 그 크기를 보이지 않게 깔고 안내를 그 위에 띄운다 — 로딩·실패·빈 상태의 자리 크기가 같다.
|
||||
* 이때 boxClassName 은 안내 상자의 위치(스켈레톤 바깥 여백만큼 inset).
|
||||
*/
|
||||
export function StateBox({ load, onRetry, empty, hold, boxClassName = 'inset-x-3 top-3 bottom-0' }: { load: Load; onRetry?: () => void; empty?: string; hold?: ReactNode; boxClassName?: string }) {
|
||||
const failed = load === 'error' || load === 'retrying';
|
||||
const text = failed ? '정보를 불러오지 못했어요.' : load === 'ready' ? empty : undefined;
|
||||
if (!text) return null;
|
||||
return (
|
||||
<View className="mx-3 mt-3 items-center gap-2 rounded-[22px] border-b-[5px] border-shade bg-card px-4 py-6">
|
||||
const box = (
|
||||
<View className={`items-center justify-center gap-2 rounded-[22px] border-b-[5px] border-shade bg-card px-4 py-6 ${hold ? `absolute ${boxClassName}` : 'mx-3 mt-3'}`}>
|
||||
<Text className="text-center text-[13.5px] font-semibold text-ink2">{text}</Text>
|
||||
{failed && onRetry && (
|
||||
<Pressable onPress={onRetry} disabled={load === 'retrying'} className="rounded-full bg-ink-btn px-4 py-1.5 disabled:opacity-60">
|
||||
@@ -96,6 +100,15 @@ export function StateBox({ load, onRetry, empty }: { load: Load; onRetry?: () =>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
if (!hold) return box;
|
||||
return (
|
||||
<View>
|
||||
<View style={{ opacity: 0 }} pointerEvents="none" accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
|
||||
{hold}
|
||||
</View>
|
||||
{box}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 사진 출처 표기 (공공누리 조건). 위치는 className 으로 */
|
||||
|
||||
@@ -44,4 +44,5 @@
|
||||
@theme {
|
||||
--font-jua: 'Jua_400Regular';
|
||||
--font-bagel: 'BagelFatOne_400Regular';
|
||||
--font-batang: 'GowunBatang_400Regular';
|
||||
}
|
||||
Reference in new issue
Block a user