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,128 @@
|
||||
import { meQueryKey, updateMeMutation } from '@nalssigak/shared/api/client/@tanstack/react-query.gen';
|
||||
import { AVATAR_COLORS, CHARACTERS, MOODS } from '@nalssigak/shared/lib';
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { useState } from 'react';
|
||||
import { Pressable, Text, View } from 'react-native';
|
||||
|
||||
import { Avatar, Ic } from '@/components/ui';
|
||||
import { useAuth } from '@/lib/auth';
|
||||
|
||||
import { Body, Field, useSoft } from './parts';
|
||||
|
||||
/** 내 정보: 캐릭터·배경색·기분·닉네임·로그아웃 */
|
||||
export function MeSheet({ onDone }: { onDone: () => void }) {
|
||||
const { me, logout } = useAuth();
|
||||
const s = useSoft();
|
||||
const queryClient = useQueryClient();
|
||||
const update = useMutation(updateMeMutation());
|
||||
const [nickname, setNickname] = useState(me?.nickname ?? '');
|
||||
const [error, setError] = useState('');
|
||||
if (!me) return null;
|
||||
|
||||
const save = (body: { nickname?: string; character?: string; color?: string; mood?: string }) => {
|
||||
setError('');
|
||||
update.mutate(
|
||||
{ body },
|
||||
{
|
||||
onSuccess: (res) => {
|
||||
if (!res.result?.success) return setError(res.result?.desc === 'INVALID_INPUT' ? '닉네임은 2~12자로 써 주세요.' : '잠시 뒤에 다시 해 주세요.');
|
||||
queryClient.setQueryData(meQueryKey(), res);
|
||||
// 댓글에 보이는 내 캐릭터·닉네임도 바뀐다
|
||||
queryClient.invalidateQueries({ predicate: (q) => (q.queryKey[0] as { _id?: string } | undefined)?._id === 'listComments' });
|
||||
},
|
||||
onError: () => setError('서버에 닿지 못했어요. 잠시 뒤에 다시 해 주세요.'),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
// 저장하는 동안은 고른 값을 바로 선택으로 보여 준다. 실패하면 me 값으로 돌아간다
|
||||
const saving = update.isPending ? update.variables?.body : undefined;
|
||||
const character = saving?.character ?? me.character;
|
||||
const color = saving?.color ?? me.color;
|
||||
const mood = saving?.mood ?? me.mood;
|
||||
const nick = nickname.trim();
|
||||
|
||||
return (
|
||||
<Body className="gap-3">
|
||||
<View className="items-center gap-1.5">
|
||||
<Avatar character={me.character} color={me.color} mood={me.mood} size={64} />
|
||||
<Text className="text-center text-sm font-semibold text-ink2">{me.login_id}(으)로 로그인했어요</Text>
|
||||
</View>
|
||||
<View accessibilityLabel="내 캐릭터">
|
||||
<Text className="mb-2 text-sm font-extrabold text-ink">내 캐릭터</Text>
|
||||
<View className="flex-row flex-wrap gap-2">
|
||||
{CHARACTERS.map(([key, label]) => (
|
||||
<Pressable
|
||||
key={key}
|
||||
accessibilityRole="radio"
|
||||
accessibilityState={{ checked: character === key }}
|
||||
disabled={update.isPending}
|
||||
onPress={() => save({ character: key })}
|
||||
className={`items-center gap-1 rounded-[18px] border-2 py-2.5 ${character === key ? 'border-orange' : 'border-transparent'}`}
|
||||
style={{ width: '31.5%', backgroundColor: s.field }}
|
||||
>
|
||||
<Ic name={key} size={48} />
|
||||
<Text className={`font-jua text-[15px] ${character === key ? 'text-orange' : 'text-ink'}`}>{label}</Text>
|
||||
</Pressable>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
<View accessibilityLabel="배경색">
|
||||
<Text className="mb-2 text-sm font-extrabold text-ink">배경색</Text>
|
||||
<View className="flex-row flex-wrap gap-2.5">
|
||||
{Object.entries(AVATAR_COLORS).map(([key, hex]) => (
|
||||
<Pressable
|
||||
key={key}
|
||||
accessibilityRole="radio"
|
||||
accessibilityState={{ checked: color === key }}
|
||||
accessibilityLabel={key}
|
||||
disabled={update.isPending}
|
||||
onPress={() => save({ color: key })}
|
||||
className={`size-9 rounded-full border-[3px] ${color === key ? 'border-ink' : 'border-white'}`}
|
||||
style={{ backgroundColor: hex }}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
<View accessibilityLabel="오늘 기분">
|
||||
<Text className="mb-2 text-sm font-extrabold text-ink">오늘 기분</Text>
|
||||
<View className="flex-row flex-wrap gap-2">
|
||||
{MOODS.map(([key, emoji, label]) => (
|
||||
<Pressable
|
||||
key={key}
|
||||
accessibilityRole="radio"
|
||||
accessibilityState={{ checked: mood === key }}
|
||||
disabled={update.isPending}
|
||||
onPress={() => save({ mood: mood === key ? '' : key })}
|
||||
className={`items-center gap-0.5 rounded-[14px] border-2 py-2 ${mood === key ? 'border-orange' : 'border-transparent'}`}
|
||||
style={{ width: '23%', backgroundColor: s.field }}
|
||||
>
|
||||
<Text className="text-[22px] leading-[26px]">{emoji}</Text>
|
||||
<Text className={`text-xs font-bold ${mood === key ? 'text-orange' : 'text-ink2'}`}>{label}</Text>
|
||||
</Pressable>
|
||||
))}
|
||||
</View>
|
||||
<Text className="mt-1.5 text-xs font-semibold text-ink3">한 번 더 누르면 지워져요</Text>
|
||||
</View>
|
||||
<View className="flex-row items-center gap-2">
|
||||
<View className="flex-1">
|
||||
<Field value={nickname} onChangeText={setNickname} maxLength={12} accessibilityLabel="닉네임" placeholder="닉네임 (2~12자)" onSubmitEditing={() => nick.length >= 2 && save({ nickname: nick })} />
|
||||
</View>
|
||||
<Pressable onPress={() => save({ nickname: nick })} disabled={update.isPending || nick === me.nickname || nick.length < 2} className="rounded-[14px] bg-ink-btn px-4 py-3 disabled:opacity-40">
|
||||
<Text className="text-sm font-extrabold text-white">{saving?.nickname != null ? '저장 중…' : '바꾸기'}</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
<Text className={`min-h-5 text-center text-[13px] font-bold ${saving ? 'text-ink2' : 'text-heart'}`}>{saving ? (saving.nickname == null ? '저장 중…' : '') : error}</Text>
|
||||
<Pressable
|
||||
onPress={() => {
|
||||
logout();
|
||||
onDone();
|
||||
}}
|
||||
className="rounded-[14px] p-[13px]"
|
||||
style={{ backgroundColor: s.soft }}
|
||||
>
|
||||
<Text className="text-center text-[15px] font-extrabold text-ink">로그아웃</Text>
|
||||
</Pressable>
|
||||
</Body>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user