feat: 앱 위치로 지역 찾기(expo-location), 게시물·주말 일정 이미지 공유(view-shot·expo-sharing)
This commit is contained in:
1 parent
f71dd2cebb
commit
26bb6a00d2
10 files changed
+231
-31
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import * as Sharing from 'expo-sharing';
|
||||
import type { RefObject } from 'react';
|
||||
import { Share, type View } from 'react-native';
|
||||
import { captureRef } from 'react-native-view-shot';
|
||||
|
||||
/** 보이는 화면 조각을 PNG로 찍어 공유. 이미지 공유가 안 되는 곳(웹 등)이면 글로 보낸다 */
|
||||
export async function shareView(ref: RefObject<View | null>, { title, message }: { title: string; message: string }) {
|
||||
try {
|
||||
if (ref.current && (await Sharing.isAvailableAsync())) {
|
||||
const uri = await captureRef(ref, { format: 'png', quality: 1, result: 'tmpfile' });
|
||||
await Sharing.shareAsync(uri, { mimeType: 'image/png', UTI: 'public.png', dialogTitle: title });
|
||||
return;
|
||||
}
|
||||
await Share.share({ message });
|
||||
} catch (e) {
|
||||
console.warn('공유 실패', e);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user