feat: 앱 기념일 꾸밈 — 할로윈·빼빼로데이·크리스마스·추석 기간에만 하늘 네 귀퉁이 소품 (이야기 주제·게임 그림은 앞 커밋에서)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
697c4bfb20
commit
47526c1cef
1 file changed
+29
-2
@@ -1,7 +1,9 @@
|
|||||||
import type { TimeKind } from '@nalssigak/shared/lib';
|
import type { TimeKind } from '@nalssigak/shared/lib';
|
||||||
|
import { holidayOn, type Holiday } from '@nalssigak/shared/lib/holiday';
|
||||||
|
import { Image } from 'expo-image';
|
||||||
import { LinearGradient } from 'expo-linear-gradient';
|
import { LinearGradient } from 'expo-linear-gradient';
|
||||||
import { useEffect } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { StyleSheet, View, type DimensionValue } from 'react-native';
|
import { StyleSheet, useWindowDimensions, View, type DimensionValue } from 'react-native';
|
||||||
import Animated, { cancelAnimation, Easing, interpolate, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated';
|
import Animated, { cancelAnimation, Easing, interpolate, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withRepeat, withTiming } from 'react-native-reanimated';
|
||||||
|
|
||||||
import { useSky } from '@/lib/sky';
|
import { useSky } from '@/lib/sky';
|
||||||
@@ -77,6 +79,30 @@ export function Shoot({ top, left, len, dur, dl }: ShootSpec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 화면 전체 하늘: 시간대별 색이 서서히 바뀌고, 밤에는 별이 반짝이고 별똥별이 떨어진다 */
|
/** 화면 전체 하늘: 시간대별 색이 서서히 바뀌고, 밤에는 별이 반짝이고 별똥별이 떨어진다 */
|
||||||
|
// 기념일 소품: 투명 배경 그림을 화면 네 귀퉁이에 (웹 b.css .b-sky-holiday, frontend/public/b/holiday, 4:5 그림)
|
||||||
|
const PROPS: Record<Holiday['key'], [number, number, number, number]> = {
|
||||||
|
halloween: [require('../../../frontend/public/b/holiday/halloween-tl.webp'), require('../../../frontend/public/b/holiday/halloween-tr.webp'), require('../../../frontend/public/b/holiday/halloween-bl.webp'), require('../../../frontend/public/b/holiday/halloween-br.webp')],
|
||||||
|
pepero: [require('../../../frontend/public/b/holiday/pepero-tl.webp'), require('../../../frontend/public/b/holiday/pepero-tr.webp'), require('../../../frontend/public/b/holiday/pepero-bl.webp'), require('../../../frontend/public/b/holiday/pepero-br.webp')],
|
||||||
|
christmas: [require('../../../frontend/public/b/holiday/christmas-tl.webp'), require('../../../frontend/public/b/holiday/christmas-tr.webp'), require('../../../frontend/public/b/holiday/christmas-bl.webp'), require('../../../frontend/public/b/holiday/christmas-br.webp')],
|
||||||
|
chuseok: [require('../../../frontend/public/b/holiday/chuseok-tl.webp'), require('../../../frontend/public/b/holiday/chuseok-tr.webp'), require('../../../frontend/public/b/holiday/chuseok-bl.webp'), require('../../../frontend/public/b/holiday/chuseok-br.webp')],
|
||||||
|
};
|
||||||
|
const CORNERS = [{ top: 0, left: 0 }, { top: 0, right: 0 }, { bottom: 0, left: 0 }, { bottom: 0, right: 0 }] as const;
|
||||||
|
|
||||||
|
/** 기념일 기간에만 네 귀퉁이 소품. 폰은 반씩 나눠 폭을 채우고 넓은 화면은 300 으로. 밤엔 조금 어둡게 */
|
||||||
|
function HolidayProps({ night }: { night: boolean }) {
|
||||||
|
const [holiday] = useState(holidayOn);
|
||||||
|
const { width } = useWindowDimensions();
|
||||||
|
if (!holiday) return null;
|
||||||
|
const w = Math.min(width / 2, 300);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{PROPS[holiday.key].map((src, i) => (
|
||||||
|
<Image key={i} source={src} style={{ position: 'absolute', ...CORNERS[i], width: w, aspectRatio: 4 / 5, opacity: night ? 0.8 : 1 }} contentFit="contain" />
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function SkyBg() {
|
export function SkyBg() {
|
||||||
const { kind } = useSky();
|
const { kind } = useSky();
|
||||||
const reduce = useReducedMotion();
|
const reduce = useReducedMotion();
|
||||||
@@ -85,6 +111,7 @@ export function SkyBg() {
|
|||||||
{KINDS.map((k) => (
|
{KINDS.map((k) => (
|
||||||
<Layer key={k} kind={k} on={k === kind} reduce={reduce} />
|
<Layer key={k} kind={k} on={k === kind} reduce={reduce} />
|
||||||
))}
|
))}
|
||||||
|
<HolidayProps night={kind === 'night'} />
|
||||||
{kind === 'night' && STARS.map((s, i) => <Star key={i} star={s} 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} />)}
|
{kind === 'night' && SHOOTS.map((s, i) => <Shoot key={i} {...s} />)}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in new issue
Block a user