- 게시물 카드 슬라이드 7종, 좋아요·댓글, 텍스트 공유 - 시트 7종(RN Modal), 위 막대 지역·계절·로그인/아바타 - 각·노을·주말·행사·계절·상식 탭, 당겨서 새로고침 - 히어로 해·구름·비·눈 움직임, 스켈레톤 깜빡임, 첫 로딩 덮개, 하늘색 전환
72 lines
2.9 KiB
TypeScript
72 lines
2.9 KiB
TypeScript
import { listRegionsOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen';
|
|
import { loadOf } from '@nalssigak/shared/lib';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { useDeferredValue, useState } from 'react';
|
|
import { Pressable, Text, View } from 'react-native';
|
|
|
|
import { Skel, StateBox } from '@/components/ui';
|
|
import { useAuth } from '@/lib/auth';
|
|
import { useRegion } from '@/lib/region';
|
|
import { useSheet } from '@/lib/sheet';
|
|
|
|
import { Body, Field } from './parts';
|
|
|
|
const N14 = Array.from({ length: 14 }, (_, i) => i);
|
|
|
|
function RegionsSkel() {
|
|
return (
|
|
<View className="mt-2">
|
|
{N14.map((i) => (
|
|
<View key={i} className="border-b-[1.5px] border-line px-1 py-3.5">
|
|
<Skel className="w-28" />
|
|
</View>
|
|
))}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
/** 지역 바꾸기: 구 이름으로 찾기 + 목록 */
|
|
export function RegionSheet({ onDone }: { onDone: () => void }) {
|
|
const { region, setRegion } = useRegion();
|
|
const { me, logout } = useAuth();
|
|
const { open } = useSheet();
|
|
const [q, setQ] = useState('');
|
|
const deferred = useDeferredValue(q.trim());
|
|
const list = useQuery(listRegionsOptions(deferred ? { query: { q: deferred } } : undefined));
|
|
const regions = list.data?.regions ?? [];
|
|
const listLoad = loadOf(list);
|
|
|
|
return (
|
|
<Body>
|
|
<Field round value={q} onChangeText={setQ} placeholder="구 이름으로 찾기 (예: 마포)" accessibilityLabel="구 이름으로 찾기" />
|
|
{listLoad === 'loading' && <RegionsSkel />}
|
|
{listLoad !== 'loading' && !regions.length && <StateBox load={listLoad} onRetry={() => list.refetch()} empty="찾는 구가 없어요." />}
|
|
<View className={`mt-2 ${list.isPlaceholderData ? 'opacity-60' : ''}`}>
|
|
{regions.map((r) => {
|
|
const here = r.code === region.code;
|
|
return (
|
|
<Pressable
|
|
key={r.code}
|
|
accessibilityState={{ selected: here }}
|
|
onPress={() => {
|
|
setRegion(r);
|
|
onDone();
|
|
}}
|
|
className="flex-row items-center justify-between border-b-[1.5px] border-line px-1 py-3"
|
|
>
|
|
<Text className={`font-jua text-[17px] ${here ? 'text-orange' : 'text-ink'}`}>{r.name}</Text>
|
|
{here && <Text className="text-xs font-extrabold text-orange">지금 보는 곳</Text>}
|
|
</Pressable>
|
|
);
|
|
})}
|
|
</View>
|
|
<View className="mt-4 flex-row items-center justify-center gap-2">
|
|
<Text className="text-[13px] font-bold text-ink2">{me ? `${me.nickname}(으)로 로그인했어요` : '로그인하면 좋아요·댓글을 쓸 수 있어요'}</Text>
|
|
<Pressable onPress={me ? logout : () => open({ type: 'login' })} hitSlop={8}>
|
|
<Text className="text-[13px] font-extrabold text-rain">{me ? '로그아웃' : '로그인'}</Text>
|
|
</Pressable>
|
|
</View>
|
|
</Body>
|
|
);
|
|
}
|