Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update mobile app family sharing UI

Leendert de Borstd405d758f9cf
diff --git a/apps/mobile-app/app/(tabs)/items/folder/[manifestId]/[id].tsx b/apps/mobile-app/app/(tabs)/items/folder/[manifestId]/[id].tsx
index c616daf4b..e859353b6 100644
--- a/apps/mobile-app/app/(tabs)/items/folder/[manifestId]/[id].tsx
+++ b/apps/mobile-app/app/(tabs)/items/folder/[manifestId]/[id].tsx
@@ -26,6 +26,7 @@ import { useVaultSync } from '@/hooks/useVaultSync';
import { DeleteFolderModal } from '@/components/folders/DeleteFolderModal';
import { FolderBreadcrumb } from '@/components/folders/FolderBreadcrumb';
+import { FolderHeaderTitle } from '@/components/folders/FolderHeaderTitle';
import { FolderModal } from '@/components/folders/FolderModal';
import { FolderPill } from '@/components/folders/FolderPill';
import { AddItemFab } from '@/components/items/AddItemFab';
@@ -302,6 +303,7 @@ export default function FolderViewScreen(): React.ReactNode {
// A virtual folder (e.g. shared manifest) is not editable or deletable here.
const isVirtualFolder = multiManifestRendering.isVirtualFolder(folderRef);
+ const isShared = isSharedFolder(folderRef, personalManifestId);
/**
* Set up header with folder name and edit/delete buttons.
@@ -309,6 +311,10 @@ export default function FolderViewScreen(): React.ReactNode {
useEffect(() => {
navigation.setOptions({
title: folder?.Name || t('items.folders.folder'),
+ /**
+ * Folder icon and name, marked as shared for a shared vault folder.
+ */
+ headerTitle: (): React.ReactNode => <FolderHeaderTitle name={folder?.Name || t('items.folders.folder')} isShared={isShared} />,
/**
* Header right buttons for edit and delete.
*/
@@ -337,7 +343,7 @@ export default function FolderViewScreen(): React.ReactNode {
</View>
)),
});
- }, [navigation, folder?.Name, isVirtualFolder, colors.primary, colors.destructive, t]);
+ }, [navigation, folder?.Name, isVirtualFolder, isShared, colors.primary, colors.destructive, t]);
/**
* Delete an item (move to trash).
diff --git a/apps/mobile-app/app/(tabs)/settings/family-sharing.tsx b/apps/mobile-app/app/(tabs)/settings/family-sharing.tsx
index 46d7c3b4e..5eaec070f 100644
--- a/apps/mobile-app/app/(tabs)/settings/family-sharing.tsx
+++ b/apps/mobile-app/app/(tabs)/settings/family-sharing.tsx
@@ -4,11 +4,14 @@ import { multiManifestRendering } from '@aliasvault/client/sharing/MultiManifest
import { SharingService } from '@aliasvault/client/sharing/SharingService';
import { CapabilityKeys } from '@aliasvault/models/webapi';
import { Ionicons } from '@expo/vector-icons';
-import { Redirect } from 'expo-router';
+import MaterialIcons from '@expo/vector-icons/MaterialIcons';
+import { Redirect, useRouter } from 'expo-router';
import { useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { RefreshControl, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native';
+import { Platform, RefreshControl, StyleSheet, TouchableOpacity, View } from 'react-native';
+import ContextMenu from 'react-native-context-menu-view';
+import { folderRoute } from '@/utils/FolderRoute';
import { HapticsUtility } from '@/utils/HapticsUtility';
import { VaultUnlockHelper } from '@/utils/VaultUnlockHelper';
@@ -17,7 +20,7 @@ import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';
import { useVaultSync } from '@/hooks/useVaultSync';
import { FolderIcon } from '@/components/folders/FolderIcon';
-import { FolderModal } from '@/components/folders/FolderModal';
+import { SharedVaultModal } from '@/components/sharing/SharedVaultModal';
import { ThemedContainer } from '@/components/themed/ThemedContainer';
import { ThemedScrollView } from '@/components/themed/ThemedScrollView';
import { ThemedText } from '@/components/themed/ThemedText';
@@ -42,6 +45,7 @@ export default function FamilySharingScreen(): React.ReactNode {
const colors = useColors();
const webApi = useWebApi();
const { t } = useTranslation();
+ const router = useRouter();
const { username } = useApp();
const { sqliteClient } = useDb();
const { isEnabled, isLoaded } = useCapabilityContext();
@@ -56,7 +60,7 @@ export default function FamilySharingScreen(): React.ReactNode {
const [isLoading, setIsLoading] = useMinDurationLoading(true, 200);
const [isRefreshing, setIsRefreshing] = useMinDurationLoading(false, 200);
const [expandedRosters, setExpandedRosters] = useState<Record<string, boolean>>({});
- const [newVaultNames, setNewVaultNames] = useState<Record<string, string>>({});
+ const [pendingVaultCreate, setPendingVaultCreate] = useState<GroupInfo | null>(null);
const [pendingVaultRename, setPendingVaultRename] = useState<{ group: GroupInfo; manifest: SharedManifestInfo } | null>(null);
const [invitationNames, setInvitationNames] = useState<Record<string, string>>({});
@@ -155,18 +159,17 @@ export default function FamilySharingScreen(): React.ReactNode {
};
/**
- * Create another shared manifest for the family. The sync that follows pushes it to the server.
- * @param group - the family to create it for.
+ * Create another shared manifest for the family picked in the create modal. The sync that follows pushes it to the server.
+ * @param name - the new vault's name.
*/
- const createSharedVault = (group: GroupInfo): Promise<void> => {
- const name = (newVaultNames[group.groupId] ?? '').trim();
- if (name.length === 0) {
+ const createSharedVault = (name: string): Promise<void> => {
+ const group = pendingVaultCreate;
+ if (!group) {
return Promise.resolve();
}
return run(async () => {
await runSharingOperation('createSharedManifest', { groupId: group.groupId, name }, familySharingText.errors.createVaultFailed);
- setNewVaultNames(previous => ({ ...previous, [group.groupId]: '' }));
await syncVault();
}, familySharingText.errors.createVaultFailed);
};
@@ -213,6 +216,14 @@ export default function FamilySharingScreen(): React.ReactNode {
*/
const vaultLabel = (manifest: SharedManifestInfo): string => vaultNames[manifest.manifestId.toLowerCase()] ?? familySharingText.sharedVault;
+ /**
+ * Open the shared manifest's folder in the items tab.
+ */
+ const openVault = (manifest: SharedManifestInfo): void => {
+ const folderId = manifest.manifestId.toLowerCase();
+ router.push(folderRoute({ Id: folderId, ManifestId: folderId }));
+ };
+
/**
* Ask before taking a member's access away, or before giving up one's own.
*/
@@ -285,6 +296,22 @@ export default function FamilySharingScreen(): React.ReactNode {
};
const styles = StyleSheet.create({
+ addButton: {
+ alignItems: 'center',
+ borderColor: colors.accentBorder,
+ borderRadius: 8,
+ borderStyle: 'dashed',
+ borderWidth: 2,
+ flexDirection: 'row',
+ gap: 8,
+ justifyContent: 'center',
+ paddingVertical: 12,
+ },
+ addButtonText: {
+ color: colors.textMuted,
+ fontSize: 14,
+ fontWeight: '600',
+ },
actionText: {
color: colors.primary,
fontSize: 14,
@@ -346,23 +373,6 @@ export default function FamilySharingScreen(): React.ReactNode {
fontSize: 16,
fontWeight: '600',
},
- createInput: {
- backgroundColor: colors.background,
- borderColor: colors.accentBorder,
- borderRadius: 8,
- borderWidth: 1,
- color: colors.text,
- flex: 1,
- fontSize: 14,
- paddingHorizontal: 12,
- paddingVertical: 8,
- },
- createRow: {
- alignItems: 'center',
- flexDirection: 'row',
- gap: 12,
- marginTop: 10,
- },
disabled: {
opacity: 0.5,
},
@@ -402,6 +412,14 @@ export default function FamilySharingScreen(): React.ReactNode {
memberText: {
flex: 1,
},
+ moreButton: {
+ alignItems: 'center',
+ height: 44,
+ justifyContent: 'center',
+ marginRight: -10,
+ marginVertical: -10,
+ width: 44,
+ },
mutedText: {
color: colors.textMuted,
fontSize: 13,
@@ -415,6 +433,12 @@ export default function FamilySharingScreen(): React.ReactNode {
fontWeight: '600',
marginBottom: 8,
},
+ vaultTitleRow: {
+ alignItems: 'center',
+ flex: 1,
+ flexDirection: 'row',
+ gap: 8,
+ },
});
// Nothing is known before the stored capabilities are read, and redirecting on a guess would throw out a deep link.
@@ -453,6 +477,28 @@ export default function FamilySharingScreen(): React.ReactNode {
</TouchableOpacity>
);
+ /**
+ * The vault's admin actions, behind a "more" button so the title row itself stays tappable.
+ */
+ const renderVaultMenu = (group: GroupInfo, manifest: SharedManifestInfo, canRename: boolean): React.ReactNode => {
+ const renameAction = { title: t('items.folders.editFolder'), systemIcon: Platform.select({ ios: 'pencil', default: 'baseline_edit' }) };
+ const deleteAction = { title: familySharingText.deleteVault, systemIcon: Platform.select({ ios: 'trash', default: 'baseline_delete' }), destructive: true };
+ const actions = canRename ? [renameAction, deleteAction] : [deleteAction];
+
+ return (
+ <ContextMenu
+ dropdownMenuMode
+ disabled={busy}
+ actions={actions}
+ onPress={(event) => (actions[event.nativeEvent.index] === renameAction ? setPendingVaultRename({ group, manifest }) : confirmVaultDelete(group, manifest))}
+ >
+ <View style={[styles.moreButton, busy && styles.disabled]} accessible accessibilityRole="button" accessibilityLabel={t('common.settings')}>
+ <Ionicons name={Platform.OS === 'ios' ? 'ellipsis-horizontal-circle' : 'ellipsis-vertical'} size={22} color={colors.textMuted} />
+ </View>
+ </ContextMenu>
+ );
+ };
+
return (
<ThemedContainer>
<ThemedScrollView refreshControl={<RefreshControl refreshing={isRefreshing} onRefresh={onRefresh} colors={[colors.primary]} tintColor={colors.primary} />}>
@@ -529,10 +575,21 @@ export default function FamilySharingScreen(): React.ReactNode {
{group.manifests.map(manifest => (
<View key={manifest.manifestId} style={styles.card}>
<View style={styles.cardHeader}>
- <ThemedText style={styles.cardTitle} numberOfLines={1}>{vaultLabel(manifest)}</ThemedText>
+ {/* The shared manifest's folder exists in this vault once the manifest itself does. */}
+ {vaultNames[manifest.manifestId.toLowerCase()] !== undefined ? (
+ <TouchableOpacity style={styles.vaultTitleRow} onPress={() => openVault(manifest)} activeOpacity={0.6} hitSlop={{ top: 10, bottom: 10 }} accessibilityRole="link">
+ <FolderIcon isShared size={20} color={colors.tint} />
+ <ThemedText style={styles.cardTitle} numberOfLines={1}>{vaultLabel(manifest)}</ThemedText>
+ <Ionicons name="chevron-forward" size={18} color={colors.textMuted} />
+ </TouchableOpacity>
+ ) : (
+ <View style={styles.vaultTitleRow}>
+ <FolderIcon isShared size={20} color={colors.tint} />
+ <ThemedText style={styles.cardTitle} numberOfLines={1}>{vaultLabel(manifest)}</ThemedText>
+ </View>
+ )}
{/* Renaming encrypts the name with the folder's key, so it takes a member who holds it. */}
- {canAdminister && holdsManifestKey(manifest, myUserId) && renderAction(t('items.folders.editFolder'), () => setPendingVaultRename({ group, manifest }))}
- {canAdminister && renderAction(familySharingText.deleteVault, () => confirmVaultDelete(group, manifest), true)}
+ {canAdminister && renderVaultMenu(group, manifest, holdsManifestKey(manifest, myUserId))}
</View>
{/* Inviting somebody encrypts this folder's key for them, which an admin who holds no grant on it cannot do. */}
@@ -558,21 +615,10 @@ export default function FamilySharingScreen(): React.ReactNode {
{/* Creating another shared manifest. */}
{canAdminister && (
- <View style={styles.card}>
- <ThemedText style={styles.cardTitle}>{familySharingText.createSharedVault}</ThemedText>
- <View style={styles.createRow}>
- <TextInput
- style={styles.createInput}
- value={newVaultNames[group.groupId] ?? ''}
- onChangeText={text => setNewVaultNames(previous => ({ ...previous, [group.groupId]: text }))}
- placeholder={familySharingText.vaultNamePlaceholder}
- placeholderTextColor={colors.textMuted}
- editable={!busy}
- onSubmitEditing={() => createSharedVault(group)}
- />
- {renderAction(familySharingText.create, () => createSharedVault(group))}
- </View>
- </View>
+ <TouchableOpacity style={[styles.addButton, busy && styles.disabled]} onPress={() => setPendingVaultCreate(group)} disabled={busy} activeOpacity={0.7}>
+ <MaterialIcons name="add" size={24} color={colors.textMuted} />
+ <ThemedText style={styles.addButtonText}>{familySharingText.createSharedVault}</ThemedText>
+ </TouchableOpacity>
)}
</View>
);
@@ -581,12 +627,18 @@ export default function FamilySharingScreen(): React.ReactNode {
)}
</ThemedScrollView>
- <FolderModal
+ <SharedVaultModal
+ isOpen={pendingVaultCreate !== null}
+ onClose={() => setPendingVaultCreate(null)}
+ onSave={createSharedVault}
+ mode="create"
+ />
+ <SharedVaultModal
isOpen={pendingVaultRename !== null}
onClose={() => setPendingVaultRename(null)}
onSave={renameSharedVault}
initialName={pendingVaultRename ? vaultLabel(pendingVaultRename.manifest) : ''}
- mode="edit"
+ mode="rename"
/>
</ThemedContainer>
);
diff --git a/apps/mobile-app/components/folders/FolderHeaderTitle.tsx b/apps/mobile-app/components/folders/FolderHeaderTitle.tsx
new file mode 100644
index 000000000..bb8110ccb
--- /dev/null
+++ b/apps/mobile-app/components/folders/FolderHeaderTitle.tsx
@@ -0,0 +1,45 @@
+import { familySharingText } from '@aliasvault/client/sharing/FamilySharingView';
+import React from 'react';
+import { Platform, StyleSheet, Text, View, useWindowDimensions } from 'react-native';
+
+import { useColors } from '@/hooks/useColorScheme';
+
+import { FolderIcon } from '@/components/folders/FolderIcon';
+
+type FolderHeaderTitleProps = {
+ name: string;
+ isShared: boolean;
+};
+
+/**
+ * Navigation header title of a folder screen: folder icon (with the people badge when shared) and name.
+ */
+export const FolderHeaderTitle: React.FC<FolderHeaderTitleProps> = ({ name, isShared }) => {
+ const colors = useColors();
+ const { width } = useWindowDimensions();
+ const maxWidth = Platform.OS === 'ios' ? width - 180 : width - 140;
+
+ const styles = StyleSheet.create({
+ container: {
+ alignItems: 'center',
+ flexDirection: 'row',
+ gap: 8,
+ maxWidth,
+ },
+ title: {
+ color: colors.text,
+ flexShrink: 1,
+ fontSize: Platform.OS === 'ios' ? 17 : 20,
+ fontWeight: Platform.OS === 'ios' ? '600' : '500',
+ },
+ });
+
+ return (
+ <View style={styles.container} accessible accessibilityRole="header" accessibilityLabel={isShared ? `${name}, ${familySharingText.sharedVault}` : name}>
+ <FolderIcon isShared={isShared} size={20} color={colors.tint} />
+ <Text style={styles.title} numberOfLines={1} ellipsizeMode="tail">{name}</Text>
+ </View>
+ );
+};
+
+export default FolderHeaderTitle;
diff --git a/apps/mobile-app/components/sharing/SharedVaultModal.tsx b/apps/mobile-app/components/sharing/SharedVaultModal.tsx
new file mode 100644
index 000000000..3f032eff5
--- /dev/null
+++ b/apps/mobile-app/components/sharing/SharedVaultModal.tsx
@@ -0,0 +1,164 @@
+import { familySharingText } from '@aliasvault/client/sharing/FamilySharingView';
+import * as Haptics from 'expo-haptics';
+import React, { useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { ActivityIndicator, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native';
+
+import { HapticsUtility } from '@/utils/HapticsUtility';
+
+import { useColors } from '@/hooks/useColorScheme';
+
+import { ModalWrapper } from '@/components/common/ModalWrapper';
+
+interface ISharedVaultModalProps {
+ isOpen: boolean;
+ onClose: () => void;
+ onSave: (name: string) => Promise<void>;
+ initialName?: string;
+ mode: 'create' | 'rename';
+}
+
+/**
+ * Modal for creating or renaming a shared vault.
+ */
+export const SharedVaultModal: React.FC<ISharedVaultModalProps> = ({ isOpen, onClose, onSave, initialName = '', mode }) => {
+ const { t } = useTranslation();
+ const colors = useColors();
+ const [name, setName] = useState(initialName);
+ const [isSubmitting, setIsSubmitting] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const trimmedName = name.trim();
+
+ useEffect(() => {
+ if (isOpen) {
+ // eslint-disable-next-line react-hooks/set-state-in-effect -- reset the form each time the modal opens
+ setName(initialName);
+ setError(null);
+ }
+ }, [isOpen, initialName]);
+
+ /**
+ * Save the name and close.
+ */
+ const handleSubmit = async (): Promise<void> => {
+ if (!trimmedName || isSubmitting) {
+ return;
+ }
+
+ setIsSubmitting(true);
+ setError(null);
+
+ try {
+ await onSave(trimmedName);
+ HapticsUtility.notification(Haptics.NotificationFeedbackType.Success);
+ onClose();
+ } catch (err) {
+ setError(t('common.errors.unknownErrorTryAgain'));
+ console.error('Error saving shared vault:', err);
+ } finally {
+ setIsSubmitting(false);
+ }
+ };
+
+ const canSubmit = trimmedName.length > 0 && !isSubmitting;
+
+ const styles = StyleSheet.create({
+ buttonRow: {
+ flexDirection: 'row',
+ gap: 12,
+ marginTop: 20,
+ },
+ cancelButton: {
+ alignItems: 'center',
+ borderColor: colors.accentBorder,
+ borderRadius: 8,
+ borderWidth: 1,
+ flex: 1,
+ paddingVertical: 12,
+ },
+ cancelButtonText: {
+ color: colors.text,
+ fontSize: 16,
+ fontWeight: '500',
+ },
+ errorText: {
+ color: colors.destructive,
+ fontSize: 14,
+ marginTop: 8,
+ },
+ input: {
+ backgroundColor: colors.modalSurfaceRaised,
+ borderColor: colors.accentBorder,
+ borderRadius: 8,
+ borderWidth: 1,
+ color: colors.text,
+ fontSize: 16,
+ marginTop: 8,
+ paddingHorizontal: 12,
+ paddingVertical: 10,
+ },
+ label: {
+ color: colors.textMuted,
+ fontSize: 14,
+ fontWeight: '500',
+ },
+ saveButton: {
+ alignItems: 'center',
+ backgroundColor: colors.tint,
+ borderRadius: 8,
+ flex: 1,
+ paddingVertical: 12,
+ },
+ saveButtonDisabled: {
+ opacity: 0.6,
+ },
+ saveButtonText: {
+ color: colors.white,
+ fontSize: 16,
+ fontWeight: '600',
+ },
+ });
+
+ return (
+ <ModalWrapper
+ isOpen={isOpen}
+ onClose={onClose}
+ isSubmitting={isSubmitting}
+ title={mode === 'create' ? familySharingText.createSharedVault : familySharingText.renameVault}
+ keyboardAvoiding
+ showHeaderBorder={false}
+ showFooterBorder={false}
+ >
+ <Text style={styles.label}>{familySharingText.vaultName}</Text>
+ <TextInput
+ style={styles.input}
+ value={name}
+ onChangeText={setName}
+ placeholder={familySharingText.vaultNamePlaceholder}
+ placeholderTextColor={colors.textMuted}
+ autoFocus
+ autoCapitalize="sentences"
+ returnKeyType="done"
+ onSubmitEditing={handleSubmit}
+ editable={!isSubmitting}
+ />
+
+ {error && <Text style={styles.errorText}>{error}</Text>}
+
+ <View style={styles.buttonRow}>
+ <TouchableOpacity style={styles.cancelButton} onPress={onClose} disabled={isSubmitting}>
+ <Text style={styles.cancelButtonText}>{t('common.cancel')}</Text>
+ </TouchableOpacity>
+ <TouchableOpacity style={[styles.saveButton, !canSubmit && styles.saveButtonDisabled]} onPress={handleSubmit} disabled={!canSubmit}>
+ {isSubmitting ? (
+ <ActivityIndicator color={colors.white} size="small" />
+ ) : (
+ <Text style={styles.saveButtonText}>{mode === 'create' ? familySharingText.create : t('common.save')}</Text>
+ )}
+ </TouchableOpacity>
+ </View>
+ </ModalWrapper>
+ );
+};
+
+export default SharedVaultModal;
diff --git a/core/client/src/sharing/FamilySharingView.ts b/core/client/src/sharing/FamilySharingView.ts
index 3050a98a5..c12a806b7 100644
--- a/core/client/src/sharing/FamilySharingView.ts
+++ b/core/client/src/sharing/FamilySharingView.ts
@@ -40,12 +40,14 @@ export const familySharingText = {
/** Confirmation for leaving a shared vault. */
leaveVaultConfirm: (vault: string): string => `Leave “${vault}”? You lose access to it, but stay in the family.`,
cannotInviteWithoutAccess: 'You do not have access to this vault, so you cannot invite anyone to it. Ask a member who has access to invite you first.',
+ vaultName: 'Vault name',
vaultNamePlaceholder: 'Vault name, for example Streaming',
+ renameVault: 'Rename vault',
/** Notice after an invitation was sent. */
invitationSent: (username: string): string => `Invitation sent to ${username}.`,
/** Confirmation for taking a member's access away. */
revokeAccessConfirm: (username: string, vault: string): string => `Take ${username} out of “${vault}”? They lose access to it right away, but stay in the family.`,
- revokeAccessWarning: 'They keep any copy of this vault they already downloaded. Change the passwords in it that you do not want them to keep using.',
+ revokeAccessWarning: 'They may have already seen or copied the passwords in it. Change any you do not want them to keep using.',
deleteVault: 'Delete vault',
/** Confirmation for deleting a shared vault. */
deleteVaultConfirm: (vault: string): string => `Permanently delete “${vault}”? Every member of the family loses this vault and everything in it. This cannot be undone.`,