feat: 앱 위치로 지역 찾기(expo-location), 게시물·주말 일정 이미지 공유(view-shot·expo-sharing)

This commit is contained in:
minaChoi committed 2026-10-14 14:49:37 +09:00
1 parent f71dd2cebb
commit 26bb6a00d2
10 files changed
+231 -31

No files matched your search

+14 -11
View File
@@ -3,7 +3,7 @@ import { PostType, type PostData, type ResFeed } from '@nalssigak/shared/api/cli
import { useMutation, useQueryClient, type QueryClient } from '@tanstack/react-query';
import { LinearGradient } from 'expo-linear-gradient';
import { useEffect, useRef, useState } from 'react';
import { Animated, Pressable, Share, Text, View } from 'react-native';
import { Animated, Pressable, Text, View } from 'react-native';
import Svg, { Path } from 'react-native-svg';
import { useCSSVariable } from 'uniwind';
@@ -13,6 +13,7 @@ import { slideBg, SlideView } from '@/components/post/slides';
import { Ic, Skel } from '@/components/ui';
import { useAuth } from '@/lib/auth';
import { useSheet } from '@/lib/sheet';
import { shareView } from '@/lib/share-image';
import { SITE_URL } from '@/lib/site';
const ACCOUNTS: Record<PostType, readonly [string, string]> = {
@@ -125,9 +126,9 @@ function FullCard({ post }: PostProps) {
const n = post.slides.length;
const patch = (values: Partial<PostData>) => patchFeed(queryClient, post.post_id, values);
const comments = () => open({ type: 'comments', postId: post.post_id });
const share = () => {
Share.share({ message: `${post.title} · 날씨각 ${SITE_URL}` }).catch((e: unknown) => console.warn('공유 실패', e));
};
const shot = useRef<View>(null);
// 지금 보고 있는 슬라이드를 이미지로
const share = () => void shareView(shot, { title: post.title, message: `${post.title} · 날씨각 ${SITE_URL}` });
useEffect(() => {
if (!likeFailed) return;
@@ -179,13 +180,15 @@ function FullCard({ post }: PostProps) {
</View>
</View>
<Pressable onPress={onTap} onLayout={(e) => setWidth(e.nativeEvent.layout.width)} className="aspect-[4/5] overflow-hidden" accessibilityLabel={n > 1 ? `슬라이드 ${n}장, 옆으로 넘겨 보세요` : undefined}>
{width > 0 && (
<Pager width={width} height={(width * 5) / 4} onIndex={setIndex}>
{post.slides.map((s, i) => (
<SlideView key={i} slide={s} bg={slideBg(post, s)} />
))}
</Pager>
)}
<View ref={shot} collapsable={false}>
{width > 0 && (
<Pager width={width} height={(width * 5) / 4} onIndex={setIndex}>
{post.slides.map((s, i) => (
<SlideView key={i} slide={s} bg={slideBg(post, s)} />
))}
</Pager>
)}
</View>
{n > 1 && (
<View pointerEvents="none" className="absolute top-3 right-3 z-[2] rounded-full bg-[rgb(30_36_56/0.55)] px-[9px] py-[3px]">
<Text className="text-xs font-extrabold text-white">
+18 -3
View File
@@ -1,7 +1,7 @@
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 { useDeferredValue, useEffect, useRef, useState } from 'react';
import { Pressable, Text, View } from 'react-native';
import { Skel, StateBox } from '@/components/ui';
@@ -11,6 +11,8 @@ import { useSheet } from '@/lib/sheet';
import { Body, Field } from './parts';
const LOCATE_TEXT = { idle: '', locating: '위치를 찾는 중이에요…', denied: '위치 권한이 꺼져 있어요. 아래 목록에서 골라 주세요.', error: '위치를 찾지 못했어요. 아래 목록에서 골라 주세요.' } as const;
const N14 = Array.from({ length: 14 }, (_, i) => i);
function RegionsSkel() {
@@ -25,9 +27,16 @@ function RegionsSkel() {
);
}
/** 지역 바꾸기: 구 이름으로 찾기 + 목록 */
/** 지역 바꾸기: 지금 위치로 찾기 + 구 이름으로 찾기 + 목록 */
export function RegionSheet({ onDone }: { onDone: () => void }) {
const { region, setRegion } = useRegion();
const { region, setRegion, locate, locateStatus } = useRegion();
const alive = useRef(true);
useEffect(() => {
alive.current = true;
return () => {
alive.current = false;
};
}, []);
const { me, logout } = useAuth();
const { open } = useSheet();
const [q, setQ] = useState('');
@@ -38,6 +47,12 @@ export function RegionSheet({ onDone }: { onDone: () => void }) {
return (
<Body>
<Pressable onPress={() => locate(() => alive.current && onDone())} disabled={locateStatus === 'locating'} className="items-center rounded-full border-b-[5px] border-orange-deep bg-orange p-3 disabled:opacity-60">
<Text className="font-jua text-[17px] text-white">지금 위치로 찾기</Text>
</Pressable>
<Text className="mt-2 min-h-5 text-center text-[13px] font-bold text-ink2" accessibilityLiveRegion="polite">
{LOCATE_TEXT[locateStatus]}
</Text>
<Field round value={q} onChangeText={setQ} placeholder="구 이름으로 찾기 (예: 마포)" accessibilityLabel="구 이름으로 찾기" />
{listLoad === 'loading' && <RegionsSkel />}
{listLoad !== 'loading' && !regions.length && <StateBox load={listLoad} onRetry={() => list.refetch()} empty="찾는 구가 없어요." />}
+9 -5
View File
@@ -8,7 +8,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useCSSVariable } from 'uniwind';
import { PinIcon } from '@/components/svg';
import { Avatar, Ic } from '@/components/ui';
import { Avatar, Ic, Skel } from '@/components/ui';
import { useAuth } from '@/lib/auth';
import { useRegion } from '@/lib/region';
import { useSheet } from '@/lib/sheet';
@@ -54,7 +54,7 @@ function Account() {
export function TopBar() {
const pathname = usePathname();
const { region } = useRegion();
const { region, locateStatus } = useRegion();
const { open } = useSheet();
const { kind } = useSky();
const { top } = useSafeAreaInsets();
@@ -67,9 +67,13 @@ export function TopBar() {
<SeasonChip />
<Pressable onPress={() => open({ type: 'region' })} accessibilityLabel={`위치 바꾸기, 지금 ${region.name}`} className="ml-auto shrink-0 flex-row items-center gap-1 rounded-full border-b-4 border-shade bg-card px-3 pt-1 pb-1.5">
<PinIcon size={14} color={ink} />
<Text numberOfLines={1} className="text-[13.5px] font-bold text-ink">
{region.name.split(' ').at(-1)}
</Text>
{locateStatus === 'locating' ? (
<Skel className="w-[52px]" />
) : (
<Text numberOfLines={1} className="text-[13.5px] font-bold text-ink">
{region.name.split(' ').at(-1)}
</Text>
)}
</Pressable>
<Account />
</View>