Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add FolderIcon component with shared status indicator (#2159)
Leendert de Borst6fd4b9dd860c
diff --git a/apps/mobile-app/app/(tabs)/items/folder/[id].tsx b/apps/mobile-app/app/(tabs)/items/folder/[id].tsxindex c7bc90d9f..d3a77dd59 100644--- a/apps/mobile-app/app/(tabs)/items/folder/[id].tsx+++ b/apps/mobile-app/app/(tabs)/items/folder/[id].tsx@@ -1,4 +1,4 @@-import { canHaveSubfolders, getRecursiveItemCount } from '@aliasvault/client/items/FolderUtils';+import { canHaveSubfolders, getRecursiveItemCount, isSharedFolder } from '@aliasvault/client/items/FolderUtils';import { applyTypeFilter, isItemTypeFilter, parseItemFilterType, type ItemFilterType } from '@aliasvault/client/items/ItemFilters';import { getFieldValue, FieldKey, ItemTypes } from '@aliasvault/models/vault';import MaterialIcons from '@expo/vector-icons/MaterialIcons';@@ -18,6 +18,7 @@ import { useColors } from '@/hooks/useColorScheme';import { useItemSort, useSortedItems } from '@/hooks/useItemSort';import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';import { useNavigationDebounce } from '@/hooks/useNavigationDebounce';+import { usePersonalManifestId } from '@/hooks/usePersonalManifestId';import { useVaultMutate } from '@/hooks/useVaultMutate';import { useVaultSync } from '@/hooks/useVaultSync';@@ -82,6 +83,7 @@ export default function FolderViewScreen(): React.ReactNode {const [folder, setFolder] = useState<Folder | null>(null);const [canCreateSubfolder, setCanCreateSubfolder] = useState(false);const [allFolders, setAllFolders] = useState<Folder[]>([]);+ const personalManifestId = usePersonalManifestId();const [isLoadingItems, setIsLoadingItems] = useState(true);const [refreshing, setRefreshing] = useMinDurationLoading(false, 200);const { executeVaultMutation } = useVaultMutate();@@ -193,8 +195,9 @@ export default function FolderViewScreen(): React.ReactNode {id: f.Id,name: f.Name,itemCount: getRecursiveItemCount(f.Id, itemsForCount, allFolders),+ isShared: isSharedFolder(f, personalManifestId),}));- }, [folderId, allFolders, itemSummaries, filterType]);+ }, [folderId, allFolders, itemSummaries, filterType, personalManifestId]);/*** Load items in this folder, subfolders, and folder details.diff --git a/apps/mobile-app/app/(tabs)/items/index.tsx b/apps/mobile-app/app/(tabs)/items/index.tsxindex a69134608..77c4f8cb5 100644--- a/apps/mobile-app/app/(tabs)/items/index.tsx+++ b/apps/mobile-app/app/(tabs)/items/index.tsx@@ -1,3 +1,4 @@+import { isSharedFolder } from '@aliasvault/client/items/FolderUtils';import { applyTypeFilter, isItemTypeFilter, type ItemFilterType } from '@aliasvault/client/items/ItemFilters';import { getFieldValue, FieldKey, ItemTypes } from '@aliasvault/models/vault';import MaterialIcons from '@expo/vector-icons/MaterialIcons';@@ -17,6 +18,7 @@ import { useAppReviewPrompt } from '@/hooks/useAppReviewPrompt';import { useColors } from '@/hooks/useColorScheme';import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';import { useNavigationDebounce } from '@/hooks/useNavigationDebounce';+import { usePersonalManifestId } from '@/hooks/usePersonalManifestId';import { useVaultMutate } from '@/hooks/useVaultMutate';import { useVaultSync } from '@/hooks/useVaultSync';@@ -78,6 +80,7 @@ export default function ItemsScreen(): React.ReactNode {const { itemUrl } = useLocalSearchParams<{ itemUrl?: string }>();const [itemsList, setItemsList] = useState<DisplayItem[]>([]);const [folders, setFolders] = useState<Folder[]>([]);+ const personalManifestId = usePersonalManifestId();const [isLoadingItems, setIsLoadingItems] = useMinDurationLoading(false, 200);const [hasLoadedItems, setHasLoadedItems] = useState(false);const [refreshing, setRefreshing] = useMinDurationLoading(false, 200);@@ -212,10 +215,11 @@ export default function ItemsScreen(): React.ReactNode {.map(folder => ({id: folder.Id,name: folder.Name,- itemCount: getRecursiveItemCount(folder.Id)+ itemCount: getRecursiveItemCount(folder.Id),+ isShared: isSharedFolder(folder, personalManifestId)})).sort((a, b) => a.name.localeCompare(b.name));- }, [folders, itemsList, searchQuery, filterType]);+ }, [folders, itemsList, searchQuery, filterType, personalManifestId]);/*** Get the title based on the active filter.diff --git a/apps/mobile-app/components/folders/FolderIcon.tsx b/apps/mobile-app/components/folders/FolderIcon.tsxnew file mode 100644index 000000000..f999eb4c9--- /dev/null+++ b/apps/mobile-app/components/folders/FolderIcon.tsx@@ -0,0 +1,63 @@+import React from 'react';+import { StyleSheet, View } from 'react-native';+import Svg, { Path } from 'react-native-svg';++import { useColors } from '@/hooks/useColorScheme';++import type { StyleProp, ViewStyle } from 'react-native';++type FolderIconProps = {+ isShared?: boolean;+ size: number;+ color: string;+ style?: StyleProp<ViewStyle>;+};++const FOLDER_PATH = 'M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z';+const PEOPLE_PATH = 'M4.5 6.375a4.125 4.125 0 118.25 0 4.125 4.125 0 01-8.25 0zM14.25 8.625a3.375 3.375 0 116.75 0 3.375 3.375 0 01-6.75 0zM1.5 19.125a7.125 7.125 0 0114.25 0v.003l-.001.119a.75.75 0 01-.363.63 13.067 13.067 0 01-6.761 1.873c-2.472 0-4.786-.684-6.76-1.873a.75.75 0 01-.364-.63l-.001-.122zM17.25 19.128l-.001.144a2.25 2.25 0 01-.233.96 10.088 10.088 0 005.06-1.01.75.75 0 00.42-.643 4.875 4.875 0 00-6.957-4.611 8.586 8.586 0 011.71 5.157v.003z';++/**+ * Folder glyph, optionally carrying a small people badge that marks the folder as shared with other people.+ * Same drawing as the browser extension's FolderIcon, with the badge scaled to the glyph.+ */+export const FolderIcon: React.FC<FolderIconProps> = ({ isShared = false, size, color, style }) => {+ const colors = useColors();+ const badgeSize = Math.round(size * 0.625);+ const badgeOffset = -Math.round(size * 0.25);++ return (+ <View style={[{ width: size, height: size }, style]}>+ <Svg width={size} height={size} viewBox="0 0 24 24" fill={color}>+ <Path d={FOLDER_PATH} />+ </Svg>+ {isShared && (+ <View+ style={[styles.badge, {+ backgroundColor: colors.accentBackground,+ borderColor: colors.accentBorder,+ borderRadius: badgeSize / 2,+ bottom: badgeOffset,+ height: badgeSize,+ right: badgeOffset,+ width: badgeSize,+ }]}+ >+ <Svg width={badgeSize * 0.75} height={badgeSize * 0.75} viewBox="0 0 24 24" fill={colors.primary}>+ <Path d={PEOPLE_PATH} />+ </Svg>+ </View>+ )}+ </View>+ );+};++const styles = StyleSheet.create({+ badge: {+ alignItems: 'center',+ borderWidth: StyleSheet.hairlineWidth,+ justifyContent: 'center',+ position: 'absolute',+ },+});++export default FolderIcon;diff --git a/apps/mobile-app/components/folders/FolderPill.tsx b/apps/mobile-app/components/folders/FolderPill.tsxindex 7246bc01e..a2c70fbdf 100644--- a/apps/mobile-app/components/folders/FolderPill.tsx+++ b/apps/mobile-app/components/folders/FolderPill.tsx@@ -1,7 +1,7 @@-import MaterialIcons from '@expo/vector-icons/MaterialIcons';import React from 'react';-import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';+import { StyleSheet, Text, TouchableOpacity } from 'react-native';+import { FolderIcon } from '@/components/folders/FolderIcon';import { useColors } from '@/hooks/useColorScheme';/**@@ -11,6 +11,7 @@ export type FolderWithCount = {id: string;name: string;itemCount: number;+ isShared?: boolean;};interface IFolderPillProps {@@ -53,7 +54,7 @@ export const FolderPill: React.FC<IFolderPillProps> = ({ folder, onPress }) => {return (<TouchableOpacity style={styles.container} onPress={onPress} activeOpacity={0.7}>- <MaterialIcons name="folder" size={16} color={colors.tint} />+ <FolderIcon isShared={folder.isShared} size={16} color={colors.tint} /><Text style={styles.folderName} numberOfLines={1} ellipsizeMode="tail">{folder.name}</Text>diff --git a/apps/mobile-app/components/form/ItemNameField.tsx b/apps/mobile-app/components/form/ItemNameField.tsxindex d49b5363c..4f8b77bea 100644--- a/apps/mobile-app/components/form/ItemNameField.tsx+++ b/apps/mobile-app/components/form/ItemNameField.tsx@@ -1,4 +1,3 @@-import MaterialIcons from '@expo/vector-icons/MaterialIcons';import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import {@@ -8,16 +7,14 @@ import {View,} from 'react-native';+import { isSharedFolder } from '@aliasvault/client/items/FolderUtils';+import { FolderIcon } from '@/components/folders/FolderIcon';import { FolderSelectorModal } from '@/components/folders/FolderSelectorModal';import { RobustPressable } from '@/components/ui/RobustPressable';import { useColors } from '@/hooks/useColorScheme';+import { usePersonalManifestId } from '@/hooks/usePersonalManifestId';-type Folder = {- Id: string;- Name: string;- ParentFolderId: string | null;- Weight: number;-};+import type { Folder } from '@aliasvault/client/database/repositories/FolderRepository';export interface ItemNameFieldRef {focus: () => void;@@ -47,6 +44,7 @@ export const ItemNameField = forwardRef<ItemNameFieldRef, IItemNameFieldProps>((}, ref) => {const { t } = useTranslation();const colors = useColors();+ const personalManifestId = usePersonalManifestId();const inputRef = useRef<TextInput>(null);const [showModal, setShowModal] = useState(false);@@ -125,8 +123,8 @@ export const ItemNameField = forwardRef<ItemNameFieldRef, IItemNameFieldProps>((style={styles.folderButton}onPress={() => setShowModal(true)}>- <MaterialIcons- name="folder"+ <FolderIcon+ isShared={selectedFolder !== undefined && isSharedFolder(selectedFolder, personalManifestId)}size={18}color={selectedFolderId ? colors.tint : colors.textMuted}/>@@ -143,6 +141,7 @@ export const ItemNameField = forwardRef<ItemNameFieldRef, IItemNameFieldProps>((<FolderSelectorModalfolders={folders}selectedFolderId={selectedFolderId}+ personalManifestId={personalManifestId}onFolderChange={onFolderChange}isOpen={showModal}onClose={() => setShowModal(false)}