Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 64 lines 1.7 kB view raw
1import { 2 type ImagePickerOptions, 3 launchImageLibraryAsync, 4 UIImagePickerPreferredAssetRepresentationMode, 5} from 'expo-image-picker' 6import {t} from '@lingui/core/macro' 7 8import {type ImageMeta} from '#/state/gallery' 9import * as Toast from '#/components/Toast' 10import {IS_IOS, IS_WEB} from '#/env' 11import {VIDEO_MAX_DURATION_MS} from '../constants' 12import {getDataUriSize} from './util' 13 14export type PickerImage = ImageMeta & { 15 size: number 16} 17 18export async function openPicker(opts?: ImagePickerOptions) { 19 const response = await launchImageLibraryAsync({ 20 exif: false, 21 mediaTypes: ['images'], 22 quality: 1, 23 selectionLimit: 1, 24 ...opts, 25 legacy: true, 26 preferredAssetRepresentationMode: 27 UIImagePickerPreferredAssetRepresentationMode.Automatic, 28 }) 29 30 return (response.assets ?? []) 31 .filter(asset => { 32 if (asset.mimeType?.startsWith('image/')) return true 33 Toast.show(t`Only image files are supported`, { 34 type: 'warning', 35 }) 36 return false 37 }) 38 .map(image => ({ 39 mime: image.mimeType || 'image/jpeg', 40 height: image.height, 41 width: image.width, 42 path: image.uri, 43 size: getDataUriSize(image.uri), 44 })) 45} 46 47export async function openUnifiedPicker({ 48 selectionCountRemaining, 49}: { 50 selectionCountRemaining: number 51}) { 52 return await launchImageLibraryAsync({ 53 exif: false, 54 mediaTypes: ['images', 'videos'], 55 quality: 1, 56 allowsMultipleSelection: true, 57 legacy: true, 58 base64: IS_WEB, 59 selectionLimit: IS_IOS ? selectionCountRemaining : undefined, 60 preferredAssetRepresentationMode: 61 UIImagePickerPreferredAssetRepresentationMode.Automatic, 62 videoMaxDuration: VIDEO_MAX_DURATION_MS / 1000, 63 }) 64}