feat: 앱 시트·로그인 상태·지역 저장 틀, 공통 UI(Avatar·Chips·Rows·Credit)

This commit is contained in:
minaChoi committed 2026-10-14 14:29:20 +09:00
1 parent e52f93fdbb
commit 28ff032160
8 files changed
+202 -15

No files matched your search

+81 -2
View File
@@ -1,9 +1,9 @@
import type { Load } from '@nalssigak/shared/lib';
import { AVATAR_COLORS, moodEmoji, naverMap, type Load } from '@nalssigak/shared/lib';
import { Image, type ImageStyle } from 'expo-image';
import { LinearGradient } from 'expo-linear-gradient';
import { Link, type Href } from 'expo-router';
import { useState, type ReactNode } from 'react';
import { Pressable, ScrollView, Text, View, type StyleProp, type ViewStyle } from 'react-native';
import { Linking, Pressable, ScrollView, Text, View, type StyleProp, type ViewStyle } from 'react-native';
import { ICONS } from '@/lib/icons';
import { imageUri } from '@/lib/site';
@@ -84,3 +84,82 @@ export function StateBox({ load, onRetry, empty }: { load: Load; onRetry?: () =>
</View>
);
}
/** 사진 출처 표기 (공공누리 조건). 위치는 className 으로 */
export function Credit({ text, className = 'right-1 bottom-1' }: { text: string; className?: string }) {
return (
<View pointerEvents="none" className={`absolute z-[1] rounded-[5px] bg-[rgb(16_20_34/0.5)] px-1 py-px ${className}`}>
<Text numberOfLines={1} className="text-[9px] leading-tight font-semibold text-white">
{text}
</Text>
</View>
);
}
/** 프로필 동그라미: 고른 배경색 위에 캐릭터, 오른쪽 위에 오늘 기분 */
export function Avatar({ character, color, mood, size = 34 }: { character: string; color?: string | null; mood?: string | null; size?: number }) {
const emoji = moodEmoji(mood);
return (
<View className="items-center justify-center rounded-full" style={{ width: size, height: size, backgroundColor: AVATAR_COLORS[color ?? ''] ?? AVATAR_COLORS.orange }}>
<Ic name={character} size={size * 0.7} />
{emoji && (
<View className="absolute -top-1 -right-1 items-center justify-center rounded-full bg-white" style={{ width: size * 0.48, height: size * 0.48 }}>
<Text style={{ fontSize: size * 0.3 }}>{emoji}</Text>
</View>
)}
</View>
);
}
type ChipsProps<K extends string> = { items: readonly (readonly [K, string])[]; value: K; onChange: (k: K) => void; disabled?: boolean };
/** 가로로 넘기는 고르기 칩 */
export function Chips<K extends string>({ items, value, onChange, disabled }: ChipsProps<K>) {
return (
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerClassName="gap-2 px-4 pt-3 pb-0.5">
{items.map(([k, l]) => (
<Pressable key={k} accessibilityState={{ selected: value === k }} disabled={disabled} onPress={() => onChange(k)} className={`rounded-full px-3.5 py-[7px] ${value === k ? 'bg-ink-btn' : 'border-b-[3px] border-shade bg-chip'}`}>
<Text className={`text-[13.5px] font-bold ${value === k ? 'text-white' : 'text-ink2'}`}>{l}</Text>
</Pressable>
))}
</ScrollView>
);
}
/** 장소 이름. 누르면 네이버 지도가 열린다 */
export function MapLink({ place, children }: { place: string; children: ReactNode }) {
return (
<Text onPress={() => Linking.openURL(naverMap(place))} accessibilityRole="link" accessibilityLabel={`${place}, 네이버 지도에서 보기`} className="underline">
{children}
</Text>
);
}
/** 자외선 단계(1 낮음 ~ 5 위험) 칩 색 */
const LEVEL_CHIP = [
['#1f9d62', '#fff'],
['#ffc21a', '#3a2a00'],
['#f0700a', '#fff'],
['#e03131', '#fff'],
['#8e3bc4', '#fff'],
] as const;
/** 줄 목록 (라벨 · 값) */
export function Rows({ rows, dark = false }: { rows: { label: string; value: string; place?: string | null; level?: number | null }[]; dark?: boolean }) {
return (
<View className="mt-auto">
{rows.map((r, i) => (
<View key={r.label} className="flex-row items-center justify-between gap-2.5 py-2.5" style={i < rows.length - 1 ? { borderBottomWidth: 2, borderColor: dark ? 'rgb(255 255 255 / 0.18)' : 'rgb(40 48 74 / 0.08)' } : undefined}>
<Text className={`font-bold ${dark ? 'text-white' : 'text-ink'}`}>{r.label}</Text>
{r.level ? (
<Text className="overflow-hidden rounded-full px-2.5 py-[3px] font-jua text-[15px]" style={{ backgroundColor: LEVEL_CHIP[r.level - 1][0], color: LEVEL_CHIP[r.level - 1][1] }}>
{r.value}
</Text>
) : (
<Text className={`text-right font-jua text-[17px] ${dark ? 'text-white' : 'text-ink'}`}>{r.place ? <MapLink place={r.place}>{r.value}</MapLink> : r.value}</Text>
)}
</View>
))}
</View>
);
}