Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(mobile): add share intent support for document uploads (#1343)

Corentin Thomassetcc56fbae56c3
diff --git a/apps/mobile/app.json b/apps/mobile/app.json
index efce4d63..956ca929 100644
--- a/apps/mobile/app.json
+++ b/apps/mobile/app.json
@@ -49,7 +49,18 @@
],
"expo-secure-store",
"expo-font",
- "expo-web-browser"
+ "expo-web-browser",
+ [
+ "expo-share-intent",
+ {
+ "iosActivationRules": {
+ "NSExtensionActivationSupportsFileWithMaxCount": 10,
+ "NSExtensionActivationSupportsImageWithMaxCount": 10
+ },
+ "androidIntentFilters": ["*/*"],
+ "androidMultiIntentFilters": ["*/*"]
+ }
+ ]
],
"experiments": {
"typedRoutes": true,
diff --git a/apps/mobile/app/(app)/(with-organizations)/_layout.tsx b/apps/mobile/app/(app)/(with-organizations)/_layout.tsx
index 2d8e86e8..95c908d7 100644
--- a/apps/mobile/app/(app)/(with-organizations)/_layout.tsx
+++ b/apps/mobile/app/(app)/(with-organizations)/_layout.tsx
@@ -15,6 +15,14 @@ export default function WithOrganizationsLayout() {
animation: 'slide_from_bottom',
}}
/>
+ <Stack.Screen
+ name="share"
+ options={{
+ headerShown: false,
+ presentation: 'modal',
+ animation: 'slide_from_bottom',
+ }}
+ />
</Stack>
</OrganizationsProvider>
);
diff --git a/apps/mobile/app/(app)/(with-organizations)/share.tsx b/apps/mobile/app/(app)/(with-organizations)/share.tsx
new file mode 100644
index 00000000..4629cccd
--- /dev/null
+++ b/apps/mobile/app/(app)/(with-organizations)/share.tsx
@@ -0,0 +1,3 @@
+import { DocumentShareScreen } from '@/modules/documents/screens/document-share.screen';
+
+export default DocumentShareScreen;
diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx
index 301b0644..a05ddda0 100644
--- a/apps/mobile/app/_layout.tsx
+++ b/apps/mobile/app/_layout.tsx
@@ -1,7 +1,9 @@
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
import { Stack } from 'expo-router';
+import { ShareIntentProvider } from 'expo-share-intent';
import { StatusBar } from 'expo-status-bar';
import { AppProviders } from '@/modules/app/providers/app-providers';
+import { ShareIntentHandler } from '@/modules/documents/components/share-intent-handler';
import { useColorScheme } from '@/modules/ui/providers/use-color-scheme';
import 'react-native-reanimated';
@@ -10,16 +12,19 @@ export default function RootLayout() {
const colorScheme = useColorScheme();
return (
- <AppProviders>
- <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
- <Stack>
- <Stack.Screen name="index" options={{ headerShown: false }} />
- <Stack.Screen name="config/server-selection" options={{ headerShown: false }} />
- <Stack.Screen name="(app)" options={{ headerShown: false }} />
- <Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
- </Stack>
- <StatusBar style="auto" />
- </ThemeProvider>
- </AppProviders>
+ <ShareIntentProvider>
+ <AppProviders>
+ <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
+ <Stack>
+ <Stack.Screen name="index" options={{ headerShown: false }} />
+ <Stack.Screen name="config/server-selection" options={{ headerShown: false }} />
+ <Stack.Screen name="(app)" options={{ headerShown: false }} />
+ <Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
+ </Stack>
+ <ShareIntentHandler />
+ <StatusBar style="auto" />
+ </ThemeProvider>
+ </AppProviders>
+ </ShareIntentProvider>
);
}
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index 2ddeafc2..1ad2a9ca 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -37,6 +37,7 @@
"expo-print": "^15.0.7",
"expo-router": "~6.0.24",
"expo-secure-store": "^15.0.8",
+ "expo-share-intent": "^5.1.1",
"expo-sharing": "^14.0.8",
"expo-splash-screen": "~31.0.13",
"expo-status-bar": "~3.0.9",
diff --git a/apps/mobile/src/modules/documents/components/share-intent-handler.tsx b/apps/mobile/src/modules/documents/components/share-intent-handler.tsx
new file mode 100644
index 00000000..198bf4d1
--- /dev/null
+++ b/apps/mobile/src/modules/documents/components/share-intent-handler.tsx
@@ -0,0 +1,31 @@
+import { usePathname, useRouter } from 'expo-router';
+import { useShareIntentContext } from 'expo-share-intent';
+import { useEffect } from 'react';
+
+// While the user is on one of these screens, a pending share intent is kept
+// on hold instead of redirecting: they first need to select a server, sign in,
+// or create their first organization. Once they land back on a regular app
+// screen, the pending share resumes.
+const holdPathPrefixes = ['/auth', '/config', '/organizations/create'];
+
+const sharePath = '/share';
+
+export function ShareIntentHandler() {
+ const router = useRouter();
+ const pathname = usePathname();
+ const { hasShareIntent } = useShareIntentContext();
+
+ useEffect(() => {
+ if (!hasShareIntent) {
+ return;
+ }
+
+ if (pathname === sharePath || holdPathPrefixes.some((prefix) => pathname.startsWith(prefix))) {
+ return;
+ }
+
+ router.push('/(app)/(with-organizations)/share');
+ }, [hasShareIntent, pathname, router]);
+
+ return null;
+}
diff --git a/apps/mobile/src/modules/documents/screens/document-share.screen.tsx b/apps/mobile/src/modules/documents/screens/document-share.screen.tsx
new file mode 100644
index 00000000..68c87e9b
--- /dev/null
+++ b/apps/mobile/src/modules/documents/screens/document-share.screen.tsx
@@ -0,0 +1,447 @@
+import type { ShareIntentFile } from 'expo-share-intent';
+import type { ThemeColors } from '@/modules/ui/theme.constants';
+import { formatBytes } from '@corentinth/chisels';
+import { useRouter } from 'expo-router';
+import { useShareIntentContext } from 'expo-share-intent';
+import { useEffect, useState } from 'react';
+import {
+ ActivityIndicator,
+ KeyboardAvoidingView,
+ Platform,
+ ScrollView,
+ StyleSheet,
+ Text,
+ TextInput,
+ TouchableOpacity,
+ View,
+} from 'react-native';
+import { useSafeAreaInsets } from 'react-native-safe-area-context';
+import { useApiClient } from '@/modules/api/providers/api.provider';
+import { queryClient } from '@/modules/api/providers/query.provider';
+import { joinFileName, splitFileName } from '@/modules/lib/path/path.models';
+import { OrganizationPickerDrawer } from '@/modules/organizations/components/organization-picker-drawer';
+import { useOrganizations } from '@/modules/organizations/organizations.provider';
+import { Icon } from '@/modules/ui/components/icon';
+import { useAlert } from '@/modules/ui/providers/alert-provider';
+import { useThemeColor } from '@/modules/ui/providers/use-theme-color';
+import { uploadDocument } from '../documents.services';
+
+type UploadStatus =
+ | { state: 'idle' }
+ | { state: 'uploading'; current: number; total: number }
+ | { state: 'success'; count: number };
+
+export function DocumentShareScreen() {
+ const router = useRouter();
+ const themeColors = useThemeColor();
+ const insets = useSafeAreaInsets();
+ const apiClient = useApiClient();
+ const { showAlert } = useAlert();
+ const { shareIntent, resetShareIntent } = useShareIntentContext();
+ const { organizations, currentOrganizationId } = useOrganizations();
+
+ const [files, setFiles] = useState<ShareIntentFile[]>(shareIntent.files ?? []);
+ const [baseName, setBaseName] = useState(() => splitFileName(files[0]?.fileName ?? '').baseName);
+ const [selectedOrganizationId, setSelectedOrganizationId] = useState<string | null>(
+ currentOrganizationId,
+ );
+ const [isOrgPickerVisible, setIsOrgPickerVisible] = useState(false);
+ const [status, setStatus] = useState<UploadStatus>({ state: 'idle' });
+
+ const styles = createStyles({ themeColors });
+
+ // A new share can arrive while the screen is already mounted (the user
+ // shares another file without closing the app), refresh the form with it
+ useEffect(() => {
+ if (shareIntent.files && shareIntent.files.length > 0) {
+ setFiles(shareIntent.files);
+ setBaseName(splitFileName(shareIntent.files[0]?.fileName ?? '').baseName);
+ setStatus({ state: 'idle' });
+ }
+ }, [shareIntent.files]);
+
+ // The current organization may not be loaded yet when the screen mounts
+ useEffect(() => {
+ if (selectedOrganizationId == null && currentOrganizationId != null) {
+ setSelectedOrganizationId(currentOrganizationId);
+ }
+ }, [selectedOrganizationId, currentOrganizationId]);
+
+ const isSingleFile = files.length === 1;
+ const singleFileExtension = isSingleFile
+ ? splitFileName(files[0]?.fileName ?? '').extension
+ : undefined;
+
+ const selectedOrganization = organizations.find((org) => org.id === selectedOrganizationId);
+
+ const leaveScreen = () => {
+ resetShareIntent();
+
+ if (router.canGoBack()) {
+ router.back();
+ } else {
+ router.replace('/(app)/(with-organizations)/(tabs)/list');
+ }
+ };
+
+ const getUploadName = (file: ShareIntentFile) => {
+ if (!isSingleFile) {
+ return file.fileName;
+ }
+
+ return joinFileName({ baseName: baseName.trim(), extension: singleFileExtension });
+ };
+
+ const handleSave = async () => {
+ if (selectedOrganizationId == null) {
+ showAlert({
+ title: 'No Organization Selected',
+ message: 'Please select an organization to save the document to.',
+ });
+ return;
+ }
+
+ const totalCount = files.length;
+
+ for (const [index, file] of files.entries()) {
+ setStatus({ state: 'uploading', current: index + 1, total: totalCount });
+
+ try {
+ await uploadDocument({
+ file: {
+ uri: file.path,
+ name: getUploadName(file),
+ type: file.mimeType,
+ },
+ apiClient,
+ organizationId: selectedOrganizationId,
+ });
+ } catch (error) {
+ // Keep the files that were not uploaded yet so the user can retry
+ // without duplicating the ones that already went through
+ setFiles(files.slice(index));
+ setStatus({ state: 'idle' });
+ showAlert({
+ title: 'Upload Failed',
+ message: `Failed to upload ${file.fileName}: ${error instanceof Error ? error.message : 'unknown error'}`,
+ });
+ return;
+ }
+ }
+
+ await queryClient.invalidateQueries({
+ queryKey: ['organizations', selectedOrganizationId, 'documents'],
+ });
+
+ setStatus({ state: 'success', count: totalCount });
+ };
+
+ const isSaveDisabled =
+ files.length === 0 ||
+ selectedOrganizationId == null ||
+ (isSingleFile && baseName.trim().length === 0);
+
+ if (status.state === 'success') {
+ const firstFile = files[0];
+ const destinationName = selectedOrganization?.name ?? 'your organization';
+ const successMessage =
+ status.count === 1 && firstFile
+ ? `${getUploadName(firstFile)} has been saved to ${destinationName}.`
+ : `${status.count} documents have been saved to ${destinationName}.`;
+
+ return (
+ <View style={[styles.container, { paddingTop: insets.top, paddingBottom: insets.bottom }]}>
+ <View style={styles.successContainer}>
+ <View style={styles.successIconContainer}>
+ <Icon name="check" size={40} color={themeColors.primary} />
+ </View>
+ <Text style={styles.successTitle}>Saved to Papra</Text>
+ <Text style={styles.successMessage}>{successMessage}</Text>
+ <TouchableOpacity
+ style={[styles.primaryButton, styles.successButton]}
+ onPress={leaveScreen}
+ >
+ <Text style={styles.primaryButtonText}>Done</Text>
+ </TouchableOpacity>
+ </View>
+ </View>
+ );
+ }
+
+ return (
+ <KeyboardAvoidingView
+ style={styles.container}
+ behavior={Platform.OS === 'ios' ? 'padding' : undefined}
+ >
+ <View style={[styles.header, { paddingTop: insets.top + 12 }]}>
+ <Text style={styles.headerTitle}>Save to Papra</Text>
+ <TouchableOpacity
+ onPress={leaveScreen}
+ hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
+ disabled={status.state === 'uploading'}
+ >
+ <Icon name="x" size={24} color={themeColors.mutedForeground} />
+ </TouchableOpacity>
+ </View>
+
+ <ScrollView style={styles.content} keyboardShouldPersistTaps="handled">
+ {files.length === 0 ? (
+ <View style={styles.emptyContainer}>
+ <Text style={styles.emptyText}>No shared file to save.</Text>
+ </View>
+ ) : (
+ <>
+ {files.map((file) => (
+ <View key={file.path} style={styles.fileCard}>
+ <View style={styles.fileIconContainer}>
+ <Icon name="file-text" size={24} color={themeColors.primary} />
+ </View>
+ <View style={styles.fileInfo}>
+ <Text style={styles.fileName} numberOfLines={1}>
+ {file.fileName}
+ </Text>
+ {file.size != null && (
+ <Text style={styles.fileMeta}>{formatBytes({ bytes: file.size })}</Text>
+ )}
+ </View>
+ </View>
+ ))}
+
+ {isSingleFile && (
+ <View style={styles.fieldContainer}>
+ <Text style={styles.fieldLabel}>Name</Text>
+ <View style={styles.nameInputContainer}>
+ <TextInput
+ style={styles.nameInput}
+ value={baseName}
+ onChangeText={setBaseName}
+ placeholder="Document name"
+ placeholderTextColor={themeColors.mutedForeground}
+ editable={status.state !== 'uploading'}
+ />
+ {singleFileExtension && (
+ <Text style={styles.nameExtension}>.{singleFileExtension}</Text>
+ )}
+ </View>
+ </View>
+ )}
+
+ <View style={styles.fieldContainer}>
+ <Text style={styles.fieldLabel}>Organization</Text>
+ <TouchableOpacity
+ style={styles.orgSelector}
+ onPress={() => setIsOrgPickerVisible(true)}
+ disabled={status.state === 'uploading'}
+ >
+ <Text style={styles.orgSelectorText} numberOfLines={1}>
+ {selectedOrganization?.name ?? 'Select an organization'}
+ </Text>
+ <Icon name="chevron-down" size={20} color={themeColors.mutedForeground} />
+ </TouchableOpacity>
+ </View>
+ </>
+ )}
+ </ScrollView>
+
+ <View style={[styles.footer, { paddingBottom: insets.bottom + 12 }]}>
+ <TouchableOpacity
+ style={[styles.primaryButton, isSaveDisabled && styles.primaryButtonDisabled]}
+ onPress={() => {
+ void handleSave();
+ }}
+ disabled={isSaveDisabled || status.state === 'uploading'}
+ >
+ {status.state === 'uploading' ? (
+ <View style={styles.uploadingRow}>
+ <ActivityIndicator size="small" color={themeColors.primaryForeground} />
+ <Text style={styles.primaryButtonText}>
+ {status.total === 1
+ ? 'Uploading…'
+ : `Uploading ${status.current} of ${status.total}…`}
+ </Text>
+ </View>
+ ) : (
+ <Text style={styles.primaryButtonText}>
+ {files.length > 1 ? `Save ${files.length} documents` : 'Save to Papra'}
+ </Text>
+ )}
+ </TouchableOpacity>
+ </View>
+
+ <OrganizationPickerDrawer
+ visible={isOrgPickerVisible}
+ onClose={() => setIsOrgPickerVisible(false)}
+ selectedOrganizationId={selectedOrganizationId}
+ onSelectOrganization={setSelectedOrganizationId}
+ />
+ </KeyboardAvoidingView>
+ );
+}
+
+function createStyles({ themeColors }: { themeColors: ThemeColors }) {
+ return StyleSheet.create({
+ container: {
+ flex: 1,
+ backgroundColor: themeColors.background,
+ },
+ header: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ paddingHorizontal: 20,
+ paddingBottom: 16,
+ borderBottomWidth: 1,
+ borderBottomColor: themeColors.border,
+ },
+ headerTitle: {
+ fontSize: 20,
+ fontWeight: 'bold',
+ color: themeColors.foreground,
+ },
+ content: {
+ flex: 1,
+ paddingHorizontal: 20,
+ },
+ emptyContainer: {
+ padding: 40,
+ alignItems: 'center',
+ },
+ emptyText: {
+ fontSize: 16,
+ color: themeColors.mutedForeground,
+ },
+ fileCard: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ marginTop: 16,
+ padding: 16,
+ backgroundColor: themeColors.secondaryBackground,
+ borderRadius: 8,
+ borderWidth: 1,
+ borderColor: themeColors.border,
+ },
+ fileIconContainer: {
+ width: 48,
+ height: 48,
+ borderRadius: 24,
+ backgroundColor: themeColors.background,
+ justifyContent: 'center',
+ alignItems: 'center',
+ marginRight: 16,
+ },
+ fileInfo: {
+ flex: 1,
+ },
+ fileName: {
+ fontSize: 16,
+ fontWeight: '600',
+ color: themeColors.foreground,
+ marginBottom: 4,
+ },
+ fileMeta: {
+ fontSize: 14,
+ color: themeColors.mutedForeground,
+ },
+ fieldContainer: {
+ marginTop: 20,
+ },
+ fieldLabel: {
+ fontSize: 14,
+ fontWeight: '600',
+ color: themeColors.mutedForeground,
+ marginBottom: 8,
+ },
+ nameInputContainer: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ borderWidth: 1,
+ borderColor: themeColors.border,
+ borderRadius: 8,
+ paddingHorizontal: 16,
+ },
+ nameInput: {
+ flex: 1,
+ paddingVertical: 12,
+ fontSize: 16,
+ color: themeColors.foreground,
+ },
+ nameExtension: {
+ fontSize: 16,
+ color: themeColors.mutedForeground,
+ marginLeft: 4,
+ },
+ orgSelector: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ paddingVertical: 12,
+ paddingHorizontal: 16,
+ backgroundColor: themeColors.secondaryBackground,
+ borderRadius: 8,
+ borderWidth: 1,
+ borderColor: themeColors.border,
+ },
+ orgSelectorText: {
+ flex: 1,
+ fontSize: 16,
+ fontWeight: '600',
+ color: themeColors.foreground,
+ marginRight: 8,
+ },
+ footer: {
+ paddingHorizontal: 20,
+ paddingTop: 12,
+ borderTopWidth: 1,
+ borderTopColor: themeColors.border,
+ },
+ primaryButton: {
+ paddingVertical: 14,
+ borderRadius: 8,
+ backgroundColor: themeColors.primary,
+ alignItems: 'center',
+ },
+ primaryButtonDisabled: {
+ opacity: 0.5,
+ },
+ primaryButtonText: {
+ fontSize: 16,
+ fontWeight: '600',
+ color: themeColors.primaryForeground,
+ },
+ uploadingRow: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ gap: 8,
+ },
+ successContainer: {
+ flex: 1,
+ justifyContent: 'center',
+ alignItems: 'center',
+ padding: 40,
+ },
+ successIconContainer: {
+ width: 80,
+ height: 80,
+ borderRadius: 40,
+ backgroundColor: themeColors.secondaryBackground,
+ justifyContent: 'center',
+ alignItems: 'center',
+ marginBottom: 20,
+ },
+ successTitle: {
+ fontSize: 22,
+ fontWeight: 'bold',
+ color: themeColors.foreground,
+ marginBottom: 8,
+ },
+ successMessage: {
+ fontSize: 15,
+ color: themeColors.mutedForeground,
+ textAlign: 'center',
+ marginBottom: 32,
+ },
+ successButton: {
+ alignSelf: 'stretch',
+ },
+ });
+}
diff --git a/apps/mobile/src/modules/lib/path/path.models.test.ts b/apps/mobile/src/modules/lib/path/path.models.test.ts
index 0a77f391..7bee84bc 100644
--- a/apps/mobile/src/modules/lib/path/path.models.test.ts
+++ b/apps/mobile/src/modules/lib/path/path.models.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest';
-import { getExtension } from './path.models';
+import { getExtension, joinFileName, splitFileName } from './path.models';
describe('path models', () => {
describe('getExtension', () => {
@@ -20,4 +20,33 @@ describe('path models', () => {
expect(getExtension('file.Test.TxT')).to.eql('txt');
});
});
+
+ describe('splitFileName', () => {
+ test('splits a file name into base name and extension', () => {
+ expect(splitFileName('invoice.pdf')).to.eql({ baseName: 'invoice', extension: 'pdf' });
+ expect(splitFileName('report.final.pdf')).to.eql({
+ baseName: 'report.final',
+ extension: 'pdf',
+ });
+ });
+
+ test('file name without extension has no extension part', () => {
+ expect(splitFileName('invoice')).to.eql({ baseName: 'invoice', extension: undefined });
+ expect(splitFileName('invoice.')).to.eql({ baseName: 'invoice.', extension: undefined });
+ });
+
+ test('the extension is lowercased, the base name casing is preserved', () => {
+ expect(splitFileName('Invoice.PDF')).to.eql({ baseName: 'Invoice', extension: 'pdf' });
+ });
+ });
+
+ describe('joinFileName', () => {
+ test('joins a base name and an extension', () => {
+ expect(joinFileName({ baseName: 'invoice', extension: 'pdf' })).to.eql('invoice.pdf');
+ });
+
+ test('without extension the base name is returned as-is', () => {
+ expect(joinFileName({ baseName: 'invoice', extension: undefined })).to.eql('invoice');
+ });
+ });
});
diff --git a/apps/mobile/src/modules/lib/path/path.models.ts b/apps/mobile/src/modules/lib/path/path.models.ts
index 98e336e3..de2539f3 100644
--- a/apps/mobile/src/modules/lib/path/path.models.ts
+++ b/apps/mobile/src/modules/lib/path/path.models.ts
@@ -1,3 +1,33 @@
+export function splitFileName(fileName: string): {
+ baseName: string;
+ extension: string | undefined;
+} {
+ const extension = getExtension(fileName);
+
+ if (extension === undefined) {
+ return { baseName: fileName, extension: undefined };
+ }
+
+ return {
+ baseName: fileName.slice(0, fileName.length - extension.length - 1),
+ extension,
+ };
+}
+
+export function joinFileName({
+ baseName,
+ extension,
+}: {
+ baseName: string;
+ extension: string | undefined;
+}): string {
+ if (extension === undefined) {
+ return baseName;
+ }
+
+ return `${baseName}.${extension}`;
+}
+
export function getExtension(path: string): string | undefined {
const parts = path.split('.');
if (parts.length <= 1) {
diff --git a/apps/mobile/src/modules/organizations/components/organization-picker-drawer.tsx b/apps/mobile/src/modules/organizations/components/organization-picker-drawer.tsx
index 08c52b84..b83cec2b 100644
--- a/apps/mobile/src/modules/organizations/components/organization-picker-drawer.tsx
+++ b/apps/mobile/src/modules/organizations/components/organization-picker-drawer.tsx
@@ -16,9 +16,18 @@ import { useOrganizations } from '../organizations.provider';
type OrganizationPickerDrawerProps = {
visible: boolean;
onClose: () => void;
+ // When provided, the drawer acts as a controlled picker and does not
+ // change the app-wide current organization
+ selectedOrganizationId?: string | null;
+ onSelectOrganization?: (organizationId: string) => void;
};
-export function OrganizationPickerDrawer({ visible, onClose }: OrganizationPickerDrawerProps) {
+export function OrganizationPickerDrawer({
+ visible,
+ onClose,
+ selectedOrganizationId,
+ onSelectOrganization,
+}: OrganizationPickerDrawerProps) {
const themeColors = useThemeColor();
const router = useRouter();
const { organizations, currentOrganizationId, setCurrentOrganizationId, isLoading } =
@@ -26,8 +35,15 @@ export function OrganizationPickerDrawer({ visible, onClose }: OrganizationPicke
const styles = createStyles({ themeColors });
+ const highlightedOrganizationId =
+ onSelectOrganization === undefined ? currentOrganizationId : selectedOrganizationId;
+
const handleSelectOrganization = async (organizationId: string) => {
- await setCurrentOrganizationId(organizationId);
+ if (onSelectOrganization) {
+ onSelectOrganization(organizationId);
+ } else {
+ await setCurrentOrganizationId(organizationId);
+ }
onClose();
};
@@ -56,7 +72,7 @@ export function OrganizationPickerDrawer({ visible, onClose }: OrganizationPicke
<TouchableOpacity
style={[
styles.orgItem,
- item.id === currentOrganizationId && styles.orgItemSelected,
+ item.id === highlightedOrganizationId && styles.orgItemSelected,
]}
onPress={() => {
void handleSelectOrganization(item.id);
@@ -65,12 +81,12 @@ export function OrganizationPickerDrawer({ visible, onClose }: OrganizationPicke
<Text
style={[
styles.orgName,
- item.id === currentOrganizationId && styles.orgNameSelected,
+ item.id === highlightedOrganizationId && styles.orgNameSelected,
]}
>
{item.name}
</Text>
- {item.id === currentOrganizationId && (
+ {item.id === highlightedOrganizationId && (
<Icon name="check" style={styles.checkmark} />
)}
</TouchableOpacity>
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b1cc99ad..e7a8c15e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -222,6 +222,9 @@ importers:
expo-secure-store:
specifier: ^15.0.8
version: 15.0.8([email protected])
+ expo-share-intent:
+ specifier: ^5.1.1
expo-sharing:
specifier: ^14.0.8
version: 14.0.8([email protected])
@@ -2787,6 +2790,9 @@ packages:
resolution: {integrity: sha512-iNe0puxwBNEcuua9gmTGzq+SuMDa0iATai1FlFTMHJ/vUmKvN/V//drXoLJkVb5i5H3iE/n/qIJxyoBnXouD0w==}
+ resolution: {integrity: sha512-IMYCxBOcnuFStuK0Ay+FzEIBKrwW8OVUMc65+v0+i7YFIIe8aL342l7T4F8lR4oCfhXn7d6M5QPgXvjtc/gAcw==}
+
resolution: {integrity: sha512-g2yXGICdoOw5i3LkQSDxl2Q5AlQCrG7oniu0pCPPO+UxGb7He4AFqSvPSy8HpRUj55io17hT62FTjYRD+d6j3Q==}
@@ -2796,6 +2802,9 @@ packages:
resolution: {integrity: sha512-AMDeuDLHXXqd8W+0zSjIt7f37vUd/BP8p43k68NHpyAvQO+z8mbQZm3cNQVAMySeayK2XoPigAFB1JF2NFajaA==}
+ resolution: {integrity: sha512-kqZ0w44E+HEGBjy+Lpyn0BVL5UANg/tmNixxaRMLS6nf37YsDrLk2VMAmeKMMk5CKG0NmOdVv3ngeUjRQMsy9g==}
+
resolution: {integrity: sha512-/J16SC2an1LdtCZ67xhSkGXpALYUVUNyZws7v+PVsFZxClYehDSoKLqyRaGkpHlYrCc08bS0RF5E0JV6g50psA==}
@@ -2911,6 +2920,9 @@ packages:
resolution: {integrity: sha512-F/IZJQaf8OIVnVA6XWUeMPC3OH6MV00Wxf0WC0JhTQht2QgjyHUa3U5Gs3vRtDq8tXNsZneOQRDVwpaOnd4zTQ==}
+ resolution: {integrity: sha512-9RYVU1iGyCJ7vWfg3e7c/NVyMFs8wbl+dMWZphtFtsqyN9zppGREU3ctlD3i8KUE0sCUTVnLjCWr+VeUIDep2g==}
+
resolution: {integrity: sha512-MPVpmKGfnQEnrCzgxuXcmPP/y/t6AVm+DcSb2Myp21LKWv1N3l8uFxMggesfF4ixAxkRlGmMMx9GyDC9M+XklQ==}
@@ -6552,6 +6564,15 @@ packages:
resolution: {integrity: sha512-mcmyML3oXcqFUXUxtdtCL1O00ztNI2v76d+MdniXRUgHNxIcHZ05zo+DqBaOOT6LQnPk4vA4YHqQl7iGUfRb3g==}
engines: {node: '>=20.16.0'}
+ resolution: {integrity: sha512-0sEf34+4w/ySQd7xZmnog/oOm1q+PUBHFoGU97mxTXIGijY4LNmSX806efrDkYMwCxgRA1iHxG/zBib4zBPmYw==}
+ peerDependencies:
+ expo: ^54
+ expo-constants: '>=18.0.8'
+ expo-linking: '>=8.0.8'
+ react: '*'
+ react-native: '*'
+
resolution: {integrity: sha512-A1pPr2iBrxypFDCWVAESk532HK+db7MFXbvO2sCV9ienaFXAk7lIBm6bkqgE6vzRd9O3RGdEGzYx80cYlc089Q==}
peerDependencies:
@@ -12756,6 +12777,25 @@ snapshots:
dependencies:
node-forge: 1.4.0
+ dependencies:
+ '@expo/config-types': 53.0.5
+ '@expo/json-file': 9.1.5
+ '@expo/plist': 0.3.5
+ '@expo/sdk-runtime-versions': 1.0.0
+ chalk: 4.1.2
+ debug: 4.4.3([email protected])
+ getenv: 2.0.0
+ glob: 10.5.0
+ resolve-from: 5.0.0
+ semver: 7.8.5
+ slash: 3.0.0
+ slugify: 1.6.6
+ xcode: 3.0.1
+ xml2js: 0.6.0
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
'@expo/config-types': 54.0.10
@@ -12796,6 +12836,8 @@ snapshots:
'@expo/[email protected]': {}
+ '@expo/[email protected]': {}
+
'@expo/[email protected]': {}
@@ -13106,6 +13148,12 @@ snapshots:
base64-js: 1.5.1
xmlbuilder: 14.0.0
+ dependencies:
+ '@xmldom/xmldom': 0.8.11
+ base64-js: 1.5.1
+ xmlbuilder: 15.1.1
+
dependencies:
'@xmldom/xmldom': 0.8.11
@@ -17670,6 +17718,17 @@ snapshots:
+ dependencies:
+ '@expo/config-plugins': 10.1.2
+ react: 19.1.0
+ react-native: 0.81.5(@babel/[email protected])(@types/[email protected])([email protected])
+ transitivePeerDependencies:
+ - supports-color
+
dependencies: