diff --git a/mobile/src/components/moon.tsx b/mobile/src/components/moon.tsx new file mode 100644 index 0000000..439e4b6 --- /dev/null +++ b/mobile/src/components/moon.tsx @@ -0,0 +1,79 @@ +import { moonPath } from '@nalssigak/shared/lib/today'; +import { useId } from 'react'; +import Svg, { Circle, ClipPath, Defs, Ellipse, FeGaussianBlur, Filter, G, Path, RadialGradient, Stop } from 'react-native-svg'; + +// 앞면 바다(어두운 무늬) 자리: [x, y, 가로 반지름, 세로 반지름]. 실제 달 앞면 배치를 대강 따른다 (웹 frontend/src/b/moon.tsx 와 같다) +const MARIA: [number, number, number, number][] = [ + [-0.32, -0.36, 0.3, 0.26], + [0.12, -0.36, 0.17, 0.15], + [0.3, -0.06, 0.2, 0.17], + [-0.56, 0.06, 0.26, 0.42], + [0.66, -0.26, 0.1, 0.12], + [0.52, 0.22, 0.13, 0.15], + [-0.14, 0.44, 0.18, 0.13], + [-0.46, 0.5, 0.1, 0.09], +]; +// 작은 크레이터: [x, y, 반지름] +const CRATERS: [number, number, number][] = [ + [0.1, 0.72, 0.07], + [0.42, 0.52, 0.05], + [-0.66, -0.5, 0.05], + [0.62, 0.52, 0.04], + [-0.2, 0.08, 0.04], +]; +// 저녁(노을)엔 노을빛이 도는 달, 밤엔 하얀 달 +const TONES = { + night: { body: ['#fffcf2', '#f6ebcb', '#e0cc98'], shade: '#1a2050' }, + dusk: { body: ['#fff8ee', '#ffe2cc', '#f2b9a2'], shade: '#4a2a63' }, +}; + +/** 오늘 밤 실제 모양대로 그린 달. pct 는 빛나는 면의 비율 0~100, 기우는 달은 왼쪽이 밝다. 빛 번짐까지 그려서 달 지름은 size 의 2/3 */ +export function MoonArt({ pct, waxing, tone = 'night', size }: { pct: number; waxing: boolean; tone?: keyof typeof TONES; size: number }) { + const id = useId().replace(/[^a-zA-Z0-9]/g, ''); + const t = TONES[tone]; + const k = pct / 100; + const full = pct >= 99; + const hidden = pct <= 1; + return ( + + + + + + + + + + + + + + + + + + + + + + + + {!hidden && } + + + + {MARIA.map(([x, y, rx, ry]) => ( + + ))} + + {CRATERS.map(([x, y, r]) => ( + + ))} + + {/* 안 보이는 쪽: 흐릿한 경계로 덮고, 땅빛(지구조) 정도만 비치게 */} + {!full && } + + {hidden && } + + ); +} diff --git a/mobile/src/components/post/slides.tsx b/mobile/src/components/post/slides.tsx index fc0a3fd..375efd6 100644 --- a/mobile/src/components/post/slides.tsx +++ b/mobile/src/components/post/slides.tsx @@ -5,11 +5,12 @@ 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 { useState, type ReactNode } from 'react'; import { Pressable, StyleSheet, View } from 'react-native'; import { Text } from '@/components/text'; import Svg, { Polygon } from 'react-native-svg'; +import { MoonArt } from '@/components/moon'; import { Credit, Ic, Rows, Thumb } from '@/components/ui'; import { CARD_BG } from '@/lib/colors'; import { useSheet } from '@/lib/sheet'; @@ -54,7 +55,7 @@ export function slideBg(post: PostData, slide: Slide): SlideBg { 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.EVENT || post.post_type === PostType.MOON) 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'; @@ -86,6 +87,28 @@ function Pic({ name, widthPct = 42 }: { name: string; widthPct?: number }) { ); } +// 달 포스트 밤하늘 별: [left %, top %, 크기] +const STARS: [number, number, number][] = [ + [8, 34, 2], [18, 52, 1.5], [30, 40, 2.5], [44, 30, 1.5], [52, 58, 2], [62, 22, 1.5], [90, 18, 2], [94, 44, 1.5], [12, 70, 1.5], [38, 66, 2], [76, 74, 1.5], [86, 64, 2], [24, 12, 1.5], [70, 10, 2.5], +]; + +/** 달 포스트 그림: 아이콘 대신 오늘 밤 실제 모양의 달과 별 */ +function MoonPic({ pct, waxing }: { pct: number; waxing: boolean }) { + const [w, setW] = useState(0); + return ( + setW(e.nativeEvent.layout.width)}> + {STARS.map(([x, y, s]) => ( + + ))} + {w > 0 && ( + + + + )} + + ); +} + export function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) { const { open } = useSheet(); const { kind } = useSky(); @@ -246,13 +269,14 @@ export function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) { ); return ( + {slide.moon_pct != null && } {slide.eyebrow} {slide.line} - + {slide.moon_pct == null && } ); diff --git a/mobile/src/components/sheets/comments.tsx b/mobile/src/components/sheets/comments.tsx index 00fb10f..b3ae57c 100644 --- a/mobile/src/components/sheets/comments.tsx +++ b/mobile/src/components/sheets/comments.tsx @@ -200,6 +200,11 @@ function CommentRow({ c, postId, onNotice }: { c: CommentData; postId: number; o {c.nickname} + {c.official && ( + <> + {' 날씨각 '}{' '} + + )} {c.body} @@ -214,7 +219,8 @@ function CommentRow({ c, postId, onNotice }: { c: CommentData; postId: number; o )} - {!c.mine && } + {/* 날씨각 캐릭터 댓글은 운영 문구라 신고·차단 메뉴가 없다 */} + {!c.mine && !c.official && } diff --git a/mobile/src/components/today/hero.tsx b/mobile/src/components/today/hero.tsx index a6b03d5..30cbcd3 100644 --- a/mobile/src/components/today/hero.tsx +++ b/mobile/src/components/today/hero.tsx @@ -1,15 +1,16 @@ import type { Hero as HeroData, ResWeatherToday, TopIndex } from '@nalssigak/shared/api/client/types.gen'; import { kindOfHour, kst, type Load, type TimeKind, WEEKDAYS } from '@nalssigak/shared/lib'; -import { KINDS, moonPath, PREVIEW, SLOT_KEY, WANING, type Weather, WEATHER_ICON, weatherOf } from '@nalssigak/shared/lib/today'; +import { KINDS, PREVIEW, SLOT_KEY, WANING, type Weather, WEATHER_ICON, weatherOf } from '@nalssigak/shared/lib/today'; import { deg, slotAt } from '@nalssigak/shared/lib/weatherText'; import { useEffect, useState, type ReactNode } from 'react'; import { Pressable, View, type DimensionValue, type ViewStyle } from 'react-native'; import { Text } from '@/components/text'; import Animated, { cancelAnimation, Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated'; import { LinearGradient } from 'expo-linear-gradient'; -import Svg, { Defs, Path, RadialGradient, Rect, Stop } from 'react-native-svg'; +import Svg, { Defs, RadialGradient, Rect, Stop } from 'react-native-svg'; import { Fall } from '@/components/fall'; +import { MoonArt } from '@/components/moon'; import { Shoot, type ShootSpec } from '@/components/sky-bg'; import { Ic, Skel } from '@/components/ui'; import { useSheet } from '@/lib/sheet'; @@ -140,6 +141,12 @@ export function Hero({ hero, today, ranked, feedLoad, todayLoad }: Props) { const snow = weather === 'snow' || weather === 'sleet'; const orb = ORB[kind === 'sunset' ? 'sunset' : kind === 'night' ? 'night' : 'sun']; const text = dark ? 'text-white' : 'text-[#28304a]'; + // 가운데가 밝은 달이면 진한 글씨에 흰 번짐, 가운데가 어두운 달(초승·그믐·삭)이면 흰 글씨 + const orbText: { color: string; textShadowColor?: string; textShadowRadius?: number } = !moon + ? { color: orb.text } + : moon.pct >= 50 + ? { color: orb.text, textShadowColor: '#fff', textShadowRadius: 8 } + : { color: '#fff', textShadowColor: 'rgba(10,14,40,0.6)', textShadowRadius: 8 }; return ( @@ -157,7 +164,13 @@ export function Hero({ hero, today, ranked, feedLoad, todayLoad }: Props) { - + + {/* 저녁·밤엔 오늘 밤 실제 모양의 달 (빛 번짐까지 그려서 공보다 크게) */} + {moon ? ( + + + + ) : ( @@ -168,13 +181,12 @@ export function Hero({ hero, today, ranked, feedLoad, todayLoad }: Props) { - {/* 안 보이는 쪽을 덮어 오늘 밤 달 모양으로 */} - {moon && } - + )} + {failed(feedLoad) ? '점수를 못 불러왔어요' : `${slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`} - + {heroVal(feedLoad, score, 'w-[84px] h-10')}