feat: 앱 나머지 화면 이전 — 게시물 카드·시트·각/노을/주말/계절 탭·움직임
- 게시물 카드 슬라이드 7종, 좋아요·댓글, 텍스트 공유 - 시트 7종(RN Modal), 위 막대 지역·계절·로그인/아바타 - 각·노을·주말·행사·계절·상식 탭, 당겨서 새로고침 - 히어로 해·구름·비·눈 움직임, 스켈레톤 깜빡임, 첫 로딩 덮개, 하늘색 전환
This commit is contained in:
1 parent
28ff032160
commit
f71dd2cebb
33 files changed
+2786
-75
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import Svg, { Path } from 'react-native-svg';
|
||||
|
||||
export const HEART = 'M12 20.5s-8-4.9-8-11A4.6 4.6 0 0 1 12 6.8a4.6 4.6 0 0 1 8 2.7c0 6.1-8 11-8 11z';
|
||||
|
||||
type P = { size: number; color: string };
|
||||
|
||||
export function HeartIcon({ size, color, filled }: P & { filled: boolean }) {
|
||||
return (
|
||||
<Svg viewBox="0 0 24 24" width={size} height={size} fill={filled ? color : 'none'} stroke={color} strokeWidth={1.9}>
|
||||
<Path d={HEART} />
|
||||
</Svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function CommentIcon({ size, color }: P) {
|
||||
return (
|
||||
<Svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke={color} strokeWidth={1.9} strokeLinejoin="round">
|
||||
<Path d="M20.5 12a8.5 8.5 0 0 1-12.6 7.4L3.5 20.5l1.2-4.2A8.5 8.5 0 1 1 20.5 12z" />
|
||||
</Svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function SendIcon({ size, color }: P) {
|
||||
return (
|
||||
<Svg viewBox="0 0 24 24" width={size} height={size} fill="none" stroke={color} strokeWidth={1.9} strokeLinecap="round" strokeLinejoin="round">
|
||||
<Path d="M21 3 10 14M21 3l-6.5 18-4-7.5L3 9.5z" />
|
||||
</Svg>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { ScrollView, View, type NativeScrollEvent, type NativeSyntheticEvent } from 'react-native';
|
||||
|
||||
/** 옆으로 한 장씩 넘기는 슬라이드 (웹 Embla 캐러셀 대신 가로 paging ScrollView) */
|
||||
export function Pager({ width, height, onIndex, children }: { width: number; height: number; onIndex: (i: number) => void; children: ReactNode[] }) {
|
||||
const onEnd = (e: NativeSyntheticEvent<NativeScrollEvent>) => onIndex(Math.round(e.nativeEvent.contentOffset.x / width));
|
||||
return (
|
||||
<ScrollView horizontal pagingEnabled showsHorizontalScrollIndicator={false} scrollEnabled={children.length > 1} onMomentumScrollEnd={onEnd} style={{ width, height }}>
|
||||
{children.map((c, i) => (
|
||||
<View key={i} style={{ width, height }}>
|
||||
{c}
|
||||
</View>
|
||||
))}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
/** 슬라이드 위치 점 */
|
||||
export function Dots({ n, index }: { n: number; index: number }) {
|
||||
if (n < 2) return null;
|
||||
const items = Array.from({ length: n }, (_, i) => i);
|
||||
return (
|
||||
<View className="flex-row justify-center gap-1.5 pt-2" accessibilityElementsHidden>
|
||||
{items.map((i) => (
|
||||
<View key={i} className={`h-1.5 rounded-full ${i === index ? 'w-4 bg-orange' : 'w-1.5 bg-ink3/40'}`} />
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
import { likePostMutation, unlikePostMutation } from '@nalssigak/shared/api/client/@tanstack/react-query.gen';
|
||||
import { PostType, type PostData, type ResFeed } from '@nalssigak/shared/api/client/types.gen';
|
||||
import { useMutation, useQueryClient, type QueryClient } from '@tanstack/react-query';
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { Animated, Pressable, Share, Text, View } from 'react-native';
|
||||
import Svg, { Path } from 'react-native-svg';
|
||||
import { useCSSVariable } from 'uniwind';
|
||||
|
||||
import { CommentIcon, HEART, HeartIcon, SendIcon } from '@/components/post/icons';
|
||||
import { Dots, Pager } from '@/components/post/pager';
|
||||
import { slideBg, SlideView } from '@/components/post/slides';
|
||||
import { Ic, Skel } from '@/components/ui';
|
||||
import { useAuth } from '@/lib/auth';
|
||||
import { useSheet } from '@/lib/sheet';
|
||||
import { SITE_URL } from '@/lib/site';
|
||||
|
||||
const ACCOUNTS: Record<PostType, readonly [string, string]> = {
|
||||
[PostType.WEATHER]: ['오늘 날씨', 'sun'],
|
||||
[PostType.GAK]: ['오늘의 각', 'rabbit'],
|
||||
[PostType.SUNSET]: ['노을', 'sunset'],
|
||||
[PostType.SEASON]: ['계절 소식', 'maple'],
|
||||
[PostType.EVENT]: ['가까운 행사', 'fireworks'],
|
||||
[PostType.TIP]: ['날씨 상식', 'bulb'],
|
||||
[PostType.WEEK]: ['주말 예보', 'calendar'],
|
||||
[PostType.ALERT]: ['생활 알림', 'umbrella'],
|
||||
[PostType.TOMORROW]: ['내일 미리보기', 'moon'],
|
||||
[PostType.QUOTE]: ['오늘의 한 문장', 'letter'],
|
||||
[PostType.WEEKEND_PLAN]: ['주말 플랜', 'calendar'],
|
||||
[PostType.AIR]: ['미세먼지', 'vent'],
|
||||
[PostType.DAY_TRIP]: ['당일치기', 'picnic'],
|
||||
[PostType.MOON]: ['오늘 밤 달', 'moon'],
|
||||
[PostType.UV]: ['자외선', 'glasses'],
|
||||
};
|
||||
|
||||
type PostProps = { post: PostData };
|
||||
|
||||
/** 받아 둔 피드 데이터에도 좋아요를 반영한다. 안 하면 다른 탭에 다녀왔을 때 예전 값으로 다시 그려진다 */
|
||||
function patchFeed(queryClient: QueryClient, postId: number, patch: Partial<PostData>) {
|
||||
queryClient.setQueriesData<ResFeed>({ predicate: (q) => (q.queryKey[0] as { _id?: string } | undefined)?._id === 'getFeed' }, (feed) =>
|
||||
feed?.posts ? { ...feed, posts: feed.posts.map((p) => (p.post_id === postId ? { ...p, ...patch } : p)) } : feed,
|
||||
);
|
||||
}
|
||||
|
||||
/** 한 줄 카드 (흐린 날 노을처럼 큰 그림이 필요 없는 소식) */
|
||||
function LineCard({ post }: PostProps) {
|
||||
const [account, avatar] = ACCOUNTS[post.post_type];
|
||||
return (
|
||||
<View className="mx-3 mt-3.5 flex-row items-center gap-3 rounded-[22px] border-b-4 border-shade bg-card px-4 py-3" accessibilityLabel={post.title}>
|
||||
<Ic name={post.icon || avatar} size={40} />
|
||||
<View className="flex-1">
|
||||
<Text className="text-xs font-bold text-ink3">{account}</Text>
|
||||
<Text className="text-sm text-ink2">
|
||||
<Text className="font-jua text-base text-ink">{post.title}</Text> {post.caption}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 인스타식 게시물: 옆으로 넘기는 슬라이드, 두 번 눌러 좋아요 */
|
||||
export function PostCard({ post }: PostProps) {
|
||||
return post.size === 'line' ? <LineCard post={post} /> : <FullCard post={post} />;
|
||||
}
|
||||
|
||||
/** FullCard 와 같은 틀(머리줄·4:5 그림·버튼줄·글 한 줄)의 스켈레톤 */
|
||||
export function PostCardSkel() {
|
||||
return (
|
||||
<View className="mt-3.5 border-y border-line bg-card" accessibilityElementsHidden>
|
||||
<View className="flex-row items-center gap-2.5 px-3 py-2.5">
|
||||
<View className="size-[34px] rounded-full bg-skel" />
|
||||
<View className="gap-1.5">
|
||||
<Skel className="w-12" />
|
||||
<Skel className="w-16" />
|
||||
</View>
|
||||
</View>
|
||||
<View className="aspect-[4/5] bg-skel" />
|
||||
<View className="flex-row gap-3.5 px-3 pt-2.5 pb-1">
|
||||
<View className="size-7 rounded-full bg-skel" />
|
||||
<View className="size-7 rounded-full bg-skel" />
|
||||
<View className="size-7 rounded-full bg-skel" />
|
||||
</View>
|
||||
<View className="gap-2 px-3 pt-1 pb-3">
|
||||
<Skel className="w-20" />
|
||||
<Skel className="w-4/5" />
|
||||
<Skel className="w-32" />
|
||||
<Skel className="w-8" />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 좋아요 때 가운데에 커졌다 사라지는 하트 */
|
||||
function HeartPop() {
|
||||
const [v] = useState(() => new Animated.Value(0));
|
||||
useEffect(() => {
|
||||
Animated.timing(v, { toValue: 1, duration: 800, useNativeDriver: true }).start();
|
||||
}, [v]);
|
||||
const opacity = v.interpolate({ inputRange: [0, 0.25, 0.6, 1], outputRange: [0, 1, 1, 0] });
|
||||
const scale = v.interpolate({ inputRange: [0, 0.25, 0.6, 1], outputRange: [0.3, 1.1, 1, 1] });
|
||||
return (
|
||||
<Animated.View pointerEvents="none" className="absolute inset-0 items-center justify-center" style={{ opacity, transform: [{ scale }] }}>
|
||||
<Svg viewBox="0 0 24 24" width={112} height={112} fill="#ff3b5c">
|
||||
<Path d={HEART} />
|
||||
</Svg>
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
|
||||
function FullCard({ post }: PostProps) {
|
||||
const { open } = useSheet();
|
||||
const { loggedIn } = useAuth();
|
||||
const [ink, heart] = useCSSVariable(['--color-ink', '--color-heart']).map(String);
|
||||
const liked = !!post.liked;
|
||||
const likeCount = post.like_count;
|
||||
const queryClient = useQueryClient();
|
||||
const like = useMutation(likePostMutation());
|
||||
const unlike = useMutation(unlikePostMutation());
|
||||
const [width, setWidth] = useState(0);
|
||||
const [index, setIndex] = useState(0);
|
||||
const [pop, setPop] = useState(0);
|
||||
const [likeFailed, setLikeFailed] = useState(0);
|
||||
const lastTap = useRef(0);
|
||||
const [account, avatar] = ACCOUNTS[post.post_type];
|
||||
const n = post.slides.length;
|
||||
const patch = (values: Partial<PostData>) => patchFeed(queryClient, post.post_id, values);
|
||||
const comments = () => open({ type: 'comments', postId: post.post_id });
|
||||
const share = () => {
|
||||
Share.share({ message: `${post.title} · 날씨각 ${SITE_URL}` }).catch((e: unknown) => console.warn('공유 실패', e));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!likeFailed) return;
|
||||
const t = setTimeout(() => setLikeFailed(0), 2500);
|
||||
return () => clearTimeout(t);
|
||||
}, [likeFailed]);
|
||||
|
||||
// 화면을 먼저 바꾸고, 실패하면 되돌린다 (서버는 실패도 200 + result.success=false 로 준다)
|
||||
const setLike = (on: boolean) => {
|
||||
if (!loggedIn) return open({ type: 'login' });
|
||||
if (on === liked || like.isPending || unlike.isPending) return;
|
||||
if (on) setPop((p) => p + 1);
|
||||
setLikeFailed(0);
|
||||
patch({ liked: on, like_count: likeCount + (on ? 1 : -1) });
|
||||
const revert = () => {
|
||||
patch({ liked, like_count: likeCount });
|
||||
setLikeFailed(Date.now());
|
||||
};
|
||||
(on ? like : unlike).mutate(
|
||||
{ path: { post_id: post.post_id } },
|
||||
{
|
||||
onSuccess: (res) => (res.result?.success ? patch({ liked: res.liked ?? on, ...(res.like_count != null ? { like_count: res.like_count } : {}) }) : revert()),
|
||||
onError: revert,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const onTap = () => {
|
||||
const now = Date.now();
|
||||
if (now - lastTap.current < 320) {
|
||||
if (liked && loggedIn) setPop((p) => p + 1);
|
||||
else setLike(true);
|
||||
}
|
||||
lastTap.current = now;
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="mt-3.5 border-y border-line bg-card" accessibilityLabel={post.title}>
|
||||
<View className="flex-row items-center gap-2.5 px-3 py-2.5">
|
||||
<View className="size-[34px] rounded-full p-0.5">
|
||||
<LinearGradient colors={['#ff7a45', '#ffc86e', '#8fcaff']} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={{ position: 'absolute', inset: 0, borderRadius: 17 }} />
|
||||
<View className="flex-1 items-center justify-center rounded-full bg-card">
|
||||
<Ic name={avatar} size={22} />
|
||||
</View>
|
||||
</View>
|
||||
<View>
|
||||
<Text className="text-sm leading-tight font-extrabold text-ink">날씨각</Text>
|
||||
<Text className="text-xs font-semibold text-ink2">{account}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<Pressable onPress={onTap} onLayout={(e) => setWidth(e.nativeEvent.layout.width)} className="aspect-[4/5] overflow-hidden" accessibilityLabel={n > 1 ? `슬라이드 ${n}장, 옆으로 넘겨 보세요` : undefined}>
|
||||
{width > 0 && (
|
||||
<Pager width={width} height={(width * 5) / 4} onIndex={setIndex}>
|
||||
{post.slides.map((s, i) => (
|
||||
<SlideView key={i} slide={s} bg={slideBg(post, s)} />
|
||||
))}
|
||||
</Pager>
|
||||
)}
|
||||
{n > 1 && (
|
||||
<View pointerEvents="none" className="absolute top-3 right-3 z-[2] rounded-full bg-[rgb(30_36_56/0.55)] px-[9px] py-[3px]">
|
||||
<Text className="text-xs font-extrabold text-white">
|
||||
{index + 1}/{n}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
{pop > 0 && <HeartPop key={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>
|
||||
</View>
|
||||
)}
|
||||
</Pressable>
|
||||
<Dots n={n} index={index} />
|
||||
<View className="flex-row items-center gap-3.5 px-3 pt-2.5 pb-1">
|
||||
<Pressable onPress={() => setLike(!liked)} hitSlop={8} accessibilityRole="button" accessibilityState={{ selected: liked }} accessibilityLabel="좋아요">
|
||||
<HeartIcon size={26} color={liked ? heart : ink} filled={liked} />
|
||||
</Pressable>
|
||||
<Pressable onPress={comments} hitSlop={8} accessibilityRole="button" accessibilityLabel="댓글 보기">
|
||||
<CommentIcon size={26} color={ink} />
|
||||
</Pressable>
|
||||
<Pressable onPress={share} hitSlop={8} accessibilityRole="button" accessibilityLabel="보내기">
|
||||
<SendIcon size={26} color={ink} />
|
||||
</Pressable>
|
||||
</View>
|
||||
<Text className="px-3 py-0.5 text-sm font-extrabold text-ink">좋아요 {likeCount.toLocaleString()}개</Text>
|
||||
<Text className="px-3 py-0.5 text-sm text-ink">
|
||||
<Text className="font-extrabold">날씨각 </Text>
|
||||
{post.caption}
|
||||
</Text>
|
||||
<Pressable onPress={comments}>
|
||||
<Text className="px-3 pt-[3px] text-sm font-semibold text-ink3">{post.comment_count ? `댓글 ${post.comment_count}개 모두 보기` : '첫 댓글 남기기'}</Text>
|
||||
</Pressable>
|
||||
<Text className="px-3 pt-1 pb-3 text-[11.5px] font-semibold text-ink3">오늘</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
import type { GakSlide, HoursSlide, PlanSlide, PostData, RowsSlide, SunsetSlide, WeekSlide } from '@nalssigak/shared/api/client/types.gen';
|
||||
import { PostType, SlotTone } from '@nalssigak/shared/api/client/types.gen';
|
||||
import { cardBg, clockShort } from '@nalssigak/shared/lib';
|
||||
import type { SlideBg } from '@nalssigak/shared/lib/types';
|
||||
import { deg } from '@nalssigak/shared/lib/weatherText';
|
||||
import { Image } from 'expo-image';
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import type { ReactNode } from 'react';
|
||||
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
||||
import Svg, { Polygon } from 'react-native-svg';
|
||||
|
||||
import { Credit, Ic, Rows, Thumb } from '@/components/ui';
|
||||
import { CARD_BG } from '@/lib/colors';
|
||||
import { useSheet } from '@/lib/sheet';
|
||||
import { imageUri } from '@/lib/site';
|
||||
import { useSky } from '@/lib/sky';
|
||||
|
||||
export type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide | PlanSlide;
|
||||
|
||||
type Stops = readonly [string, string, ...string[]];
|
||||
|
||||
const GAK_BG: SlideBg[] = ['butter', 'peach', 'lilac'];
|
||||
const ROW_ICON_BG: Record<string, SlideBg> = { umbrella: 'lilac', vent: 'mint', sunset: 'peach', thermo: 'sky', maple: 'peach', moon: 'lilac', glasses: 'butter' };
|
||||
const DARK = new Set<SlideBg>(['dusk', 'night']);
|
||||
|
||||
// 노을 하늘 상황(1 가려짐 2 낮은 구름 3 물들 구름 적음 4 넓게 물듦 5 두꺼움)별 하늘, 시간 칸 색 (웹 .b-sit-*, .b-cut-*)
|
||||
const SIT_BG: Record<number, { colors: Stops; locations: readonly [number, number, ...number[]] }> = {
|
||||
1: { colors: ['#6f7690', '#9aa0b4', '#b9b4c0'], locations: [0, 0.55, 1] },
|
||||
2: { colors: ['#7a7f9c', '#a7a3bb', '#c9b8b8'], locations: [0, 0.55, 1] },
|
||||
3: { colors: ['#4b5aa8', '#7f86c6', '#e9b9a8', '#ffb27a', '#ff8a4c'], locations: [0, 0.38, 0.68, 0.86, 1] },
|
||||
4: { colors: ['#5b3f9e', '#c2559a', '#ff7a6a', '#ffb35c'], locations: [0, 0.4, 0.68, 1] },
|
||||
5: { colors: ['#6a6aa0', '#a98fb4', '#e3b1a0'], locations: [0, 0.55, 1] },
|
||||
};
|
||||
const CUT_BG: Stops[] = [
|
||||
['#9fd0ff', '#ffd79a', '#ff9a5c'],
|
||||
['#8f7cf0', '#ff6f8e', '#ff8a4c'],
|
||||
['#34306e', '#7a5cc8'],
|
||||
];
|
||||
// 건물 실루엣 (웹 .b-skyline clip-path)
|
||||
const SKYLINE = '0,55 8,55 8,30 15,30 15,50 22,50 22,10 28,10 28,45 36,45 36,25 44,25 44,55 52,55 52,35 60,35 60,5 66,5 66,40 74,40 74,20 82,20 82,50 90,50 90,30 100,30 100,100 0,100';
|
||||
|
||||
const HOUR_TONE: Record<string, { bg: string; edge: string }> = {
|
||||
[SlotTone.NIGHT]: { bg: '#e3e7ff', edge: '#c7cff5' },
|
||||
[SlotTone.SUNSET]: { bg: '#ffe3d2', edge: '#ffc19f' },
|
||||
};
|
||||
|
||||
/** 배경색은 API에 없어 글 종류·아이콘으로 고른다 */
|
||||
export function slideBg(post: PostData, slide: Slide): SlideBg {
|
||||
if (slide.kind === 'hours') return 'sky';
|
||||
if (slide.kind === 'sunset') return 'dusk';
|
||||
if (slide.kind === 'week') return 'mint';
|
||||
if (slide.kind === 'plan') return slide.eyebrow.startsWith('일') ? 'peach' : 'butter';
|
||||
if (slide.kind === 'gak') return GAK_BG[post.post_id % GAK_BG.length];
|
||||
if (post.post_type === PostType.EVENT) return 'night';
|
||||
if (post.post_type === PostType.TIP) return 'sky';
|
||||
if (post.post_type === PostType.AIR) return slide.icon === 'vent' ? 'mint' : 'lilac';
|
||||
if (post.post_type === PostType.DAY_TRIP) return slide.image ? 'night' : 'mint';
|
||||
return (ROW_ICON_BG[slide.icon] ?? cardBg(slide.icon, post.post_id)) as SlideBg;
|
||||
}
|
||||
|
||||
function Base({ colors, locations, children }: { colors: Stops; locations?: readonly [number, number, ...number[]]; children: ReactNode }) {
|
||||
return (
|
||||
<View className="flex-1 px-5 py-[22px]">
|
||||
<LinearGradient colors={colors} locations={locations} style={StyleSheet.absoluteFill} />
|
||||
{children}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function Eyebrow({ children, light, className }: { children: ReactNode; light?: boolean; className?: string }) {
|
||||
return <Text className={`text-[13px] font-extrabold opacity-75 ${light ? 'text-white' : 'text-ink'} ${className ?? ''}`}>{children}</Text>;
|
||||
}
|
||||
|
||||
function Big({ children, light, className }: { children: ReactNode; light?: boolean; className?: string }) {
|
||||
return <Text className={`mt-1.5 font-jua text-[29px] leading-tight ${light ? 'text-white' : 'text-ink'} ${className ?? ''}`}>{children}</Text>;
|
||||
}
|
||||
|
||||
function Pic({ name, widthPct = 42 }: { name: string; widthPct?: number }) {
|
||||
return (
|
||||
<View pointerEvents="none" className="absolute top-[30%] right-3.5 aspect-square" style={{ width: `${widthPct}%` }}>
|
||||
<Ic name={name} size={0} style={{ width: '100%', height: '100%' }} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
|
||||
const { open } = useSheet();
|
||||
const { kind } = useSky();
|
||||
const palette = CARD_BG[kind === 'night' ? 'night' : 'day'];
|
||||
const colors = palette[bg] ?? palette.sky;
|
||||
const light = DARK.has(bg);
|
||||
|
||||
if (slide.kind === 'hours') {
|
||||
const temps = slide.hours.flatMap((h) => (h.temp_c == null ? [] : [h.temp_c]));
|
||||
const lo = Math.min(...temps);
|
||||
const span = Math.max(...temps) - lo || 1;
|
||||
return (
|
||||
<Base colors={palette.sky}>
|
||||
<Eyebrow>{slide.eyebrow}</Eyebrow>
|
||||
<Big>{slide.line}</Big>
|
||||
<View className="mt-3.5 flex-1 flex-row gap-2">
|
||||
{slide.hours.map((h) => {
|
||||
const tone = HOUR_TONE[h.tone ?? ''];
|
||||
return (
|
||||
<View key={h.label} className={`flex-1 items-center justify-between overflow-hidden rounded-[18px] px-1 pt-2.5 pb-[9px] ${tone ? '' : 'border-b-[5px] border-shade bg-card'}`} style={tone ? { backgroundColor: tone.bg, borderBottomWidth: 5, borderColor: tone.edge } : undefined}>
|
||||
{h.temp_c != null && <LinearGradient colors={['rgba(255,122,69,0.1)', 'rgba(255,122,69,0.34)']} style={{ position: 'absolute', left: 0, right: 0, bottom: 0, height: `${20 + ((h.temp_c - lo) / span) * 70}%` }} />}
|
||||
<Text className={`text-xs font-bold ${tone ? 'text-[#5a6380]' : 'text-ink2'}`}>{h.label}</Text>
|
||||
<Ic name={h.icon} size={34} />
|
||||
<Text className={`font-bagel text-[21px] ${tone ? 'text-[#28304a]' : 'text-ink'}`}>{deg(h.temp_c)}</Text>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</Base>
|
||||
);
|
||||
}
|
||||
if (slide.kind === 'gak')
|
||||
return (
|
||||
<Base colors={colors}>
|
||||
<Eyebrow>오늘의 각 · {slide.rank}위</Eyebrow>
|
||||
<Big>{slide.line}</Big>
|
||||
<Pic name={slide.code} />
|
||||
<Text className="mt-auto font-bagel text-[82px] leading-[82px] text-orange">{slide.score}</Text>
|
||||
<Text className="font-jua text-[29px] leading-tight text-ink">{slide.name}</Text>
|
||||
<Eyebrow className="mt-1">{slide.summary}</Eyebrow>
|
||||
<Pressable onPress={() => open({ type: 'gak', indexId: slide.index_id })} className="mt-3 self-start rounded-full border-b-[5px] border-orange-deep bg-orange px-4 py-[9px]">
|
||||
<Text className="font-jua text-[15px] text-white">계산 근거 보기</Text>
|
||||
</Pressable>
|
||||
</Base>
|
||||
);
|
||||
if (slide.kind === 'sunset') {
|
||||
const sit = slide.situation ? SIT_BG[slide.situation] : undefined;
|
||||
return (
|
||||
<Base colors={sit?.colors ?? palette.dusk} locations={sit?.locations}>
|
||||
<Eyebrow light>{slide.eyebrow}</Eyebrow>
|
||||
{/* 노을 탭 히어로와 같은 순서: 결론 → 가장 붉을 때 → 쉬운 이유 */}
|
||||
<Big light>{slide.headline ?? slide.grade_label}</Big>
|
||||
{slide.line && <Text className="mt-0.5 font-jua text-[18px] text-white">{slide.line}</Text>}
|
||||
<View className="mt-3 flex-1 gap-2">
|
||||
{slide.cuts.map((c, i) => (
|
||||
<View key={c.kind} className="flex-1 overflow-hidden rounded-2xl px-3 py-2">
|
||||
<LinearGradient colors={CUT_BG[Math.min(i, 2)]} style={StyleSheet.absoluteFill} />
|
||||
<Svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: 'absolute', left: 0, right: 0, bottom: 0, height: '32%' }}>
|
||||
<Polygon points={SKYLINE} fill="#2d2440" />
|
||||
</Svg>
|
||||
<Text className="font-bagel text-[21px] text-white">
|
||||
{clockShort(c.at)}
|
||||
<Text className="font-jua text-sm"> {c.label}</Text>
|
||||
</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</Base>
|
||||
);
|
||||
}
|
||||
if (slide.kind === 'week')
|
||||
return (
|
||||
<Base colors={palette.mint}>
|
||||
<Eyebrow>{slide.eyebrow}</Eyebrow>
|
||||
<Big>{slide.line}</Big>
|
||||
{/* 칸은 제목 바로 아래, 팁만 맨 아래로 */}
|
||||
<View className="mt-4 flex-row flex-wrap gap-2.5">
|
||||
{slide.days.map((d) => (
|
||||
<View key={d.day} className="grow basis-[45%] gap-0.5 rounded-[18px] border-b-[5px] border-shade bg-card/85 px-3 py-2.5">
|
||||
<Ic name={d.icon} size={34} />
|
||||
<Text className="font-jua text-lg text-ink">
|
||||
{d.weekday} {d.day.split('-').slice(1).map(Number).join('.')}
|
||||
</Text>
|
||||
<Text className="font-jua text-[22px] text-ink">
|
||||
<Text className="text-rain">{deg(d.temp_min_c)}</Text> → <Text className="text-orange">{deg(d.temp_max_c)}</Text>
|
||||
</Text>
|
||||
<Text className="text-xs font-bold text-ink2">
|
||||
비 {d.rain_prob ?? '?'}%{d.temp_min_c != null && d.temp_max_c != null && ` · 일교차 ${Math.round(d.temp_max_c - d.temp_min_c)}°`}
|
||||
</Text>
|
||||
{d.gaks && d.gaks.length > 0 && (
|
||||
<View className="mt-2 gap-1.5 border-t border-shade pt-2" accessibilityLabel={`${d.weekday}요일 대표 각`}>
|
||||
<Text className="text-[11px] font-extrabold text-ink2">이날 할 만한 각</Text>
|
||||
{d.gaks.map((g) => (
|
||||
<View key={g.index_id} className="flex-row items-center gap-1.5">
|
||||
<Ic name={g.icon} size={26} />
|
||||
<Text numberOfLines={1} className="flex-1 text-[14px] font-bold text-ink">
|
||||
{g.name}
|
||||
</Text>
|
||||
<Text className="font-bagel text-[16px] text-orange">{g.score}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
{slide.tip && <Text className="mt-auto overflow-hidden rounded-[14px] bg-ink-btn px-3 py-2.5 text-[13px] leading-snug font-bold text-white">{slide.tip}</Text>}
|
||||
</Base>
|
||||
);
|
||||
if (slide.kind === 'plan') {
|
||||
const credits = [...new Set(slide.steps.flatMap((st) => (st.image && st.image_credit ? [st.image_credit] : [])))];
|
||||
return (
|
||||
<Base colors={colors}>
|
||||
<Eyebrow>{slide.eyebrow}</Eyebrow>
|
||||
<Big className="text-[24px]">{slide.line}</Big>
|
||||
<View className="mt-auto gap-2">
|
||||
{slide.steps.map((st, i) => (
|
||||
<View key={i} className="flex-row items-center gap-1.5 rounded-[14px] bg-card/80 px-2 py-1.5">
|
||||
<Text className="w-[52px] font-jua text-sm text-ink2">{st.time}</Text>
|
||||
<Ic name={st.icon} size={22} />
|
||||
<View className="ml-1 flex-1">
|
||||
<Text numberOfLines={1} className="text-[13.5px] font-bold text-ink">
|
||||
{st.title}
|
||||
</Text>
|
||||
<Text numberOfLines={1} className="text-[11.5px] font-semibold text-ink2">
|
||||
{st.sub}
|
||||
</Text>
|
||||
</View>
|
||||
{st.image && <Thumb image={st.image} icon={st.icon} iconSize={26} className="size-[46px] rounded-[10px]" />}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
{credits.length > 0 && <Text className="mt-1.5 text-right text-[10px] font-semibold text-ink2">사진 {credits.join(' · ')}</Text>}
|
||||
</Base>
|
||||
);
|
||||
}
|
||||
if (slide.kind === 'rows' && slide.image)
|
||||
return (
|
||||
<View className="flex-1 justify-end">
|
||||
<Image source={{ uri: imageUri(slide.image) }} style={StyleSheet.absoluteFill} contentFit="cover" />
|
||||
{slide.image_credit && <Credit text={slide.image_credit} className="top-2.5 right-2.5" />}
|
||||
<View className="px-5 pt-20 pb-3.5">
|
||||
<LinearGradient colors={['rgba(16,20,34,0)', 'rgba(16,20,34,0.55)', 'rgba(16,20,34,0.85)']} locations={[0, 0.35, 1]} style={StyleSheet.absoluteFill} />
|
||||
<Eyebrow light>{slide.eyebrow}</Eyebrow>
|
||||
<Big light>{slide.line}</Big>
|
||||
<Rows rows={slide.rows ?? []} dark />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
return (
|
||||
<Base colors={colors}>
|
||||
<Eyebrow light={light} className={light ? 'opacity-85' : undefined}>
|
||||
{slide.eyebrow}
|
||||
</Eyebrow>
|
||||
<Big light={light} className="z-[1]">
|
||||
{slide.line}
|
||||
</Big>
|
||||
<Pic name={slide.icon} widthPct={36} />
|
||||
<Rows rows={slide.rows ?? []} dark={light} />
|
||||
</Base>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user