Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add inline skeleton loader (#771)
Leendert de Borstb0a40ef5ee4b
diff --git a/apps/mobile-app/app/(tabs)/credentials/index.tsx b/apps/mobile-app/app/(tabs)/credentials/index.tsxindex 195507549..71f717517 100644--- a/apps/mobile-app/app/(tabs)/credentials/index.tsx+++ b/apps/mobile-app/app/(tabs)/credentials/index.tsx@@ -4,10 +4,10 @@ import { useNavigation } from '@react-navigation/native';import { useRouter } from 'expo-router';import Toast from 'react-native-toast-message';import MaterialIcons from '@expo/vector-icons/MaterialIcons';+import { useSafeAreaInsets } from 'react-native-safe-area-context';import { ThemedText } from '@/components/themed/ThemedText';import { ThemedView } from '@/components/themed/ThemedView';-import { ThemedSafeAreaView } from '@/components/themed/ThemedSafeAreaView';import { useDb } from '@/context/DbContext';import { useAuth } from '@/context/AuthContext';import { Credential } from '@/utils/types/Credential';@@ -34,7 +34,8 @@ export default function CredentialsScreen() : React.ReactNode {const [isTabFocused, setIsTabFocused] = useState(false);const router = useRouter();const [credentialsList, setCredentialsList] = useState<Credential[]>([]);- const [isLoadingCredentials, setIsLoadingCredentials] = useMinDurationLoading(false, 300);+ const [isLoadingCredentials, setIsLoadingCredentials] = useMinDurationLoading(false, 200);+ const insets = useSafeAreaInsets();const authContext = useAuth();const dbContext = useDb();@@ -181,6 +182,7 @@ export default function CredentialsScreen() : React.ReactNode {},container: {flex: 1,+ paddingTop: insets.top,},content: {flex: 1,@@ -224,7 +226,7 @@ export default function CredentialsScreen() : React.ReactNode {});return (- <ThemedSafeAreaView style={styles.container}>+ <ThemedView style={styles.container}><CollapsibleHeadertitle="Credentials"scrollY={scrollY}@@ -302,6 +304,6 @@ export default function CredentialsScreen() : React.ReactNode {)}</ThemedView></ThemedView>- </ThemedSafeAreaView>+ </ThemedView>);}\ No newline at end of filediff --git a/apps/mobile-app/app/(tabs)/emails/index.tsx b/apps/mobile-app/app/(tabs)/emails/index.tsxindex d2c154d7d..803674db6 100644--- a/apps/mobile-app/app/(tabs)/emails/index.tsx+++ b/apps/mobile-app/app/(tabs)/emails/index.tsx@@ -1,6 +1,7 @@import React, { useEffect, useState, useCallback, useRef } from 'react';import { StyleSheet, View, ScrollView, RefreshControl, Animated } from 'react-native';import { useNavigation } from 'expo-router';+import { useSafeAreaInsets } from 'react-native-safe-area-context';import { MailboxEmail } from '@/utils/types/webapi/MailboxEmail';import { useDb } from '@/context/DbContext';@@ -12,7 +13,6 @@ import { MailboxBulkRequest, MailboxBulkResponse } from '@/utils/types/webapi/Maimport EncryptionUtility from '@/utils/EncryptionUtility';import { useColors } from '@/hooks/useColorScheme';import { ThemedView } from '@/components/themed/ThemedView';-import { ThemedSafeAreaView } from '@/components/themed/ThemedSafeAreaView';import { EmailCard } from '@/components/EmailCard';import { SkeletonLoader } from '@/components/ui/SkeletonLoader';import emitter from '@/utils/EventEmitter';@@ -30,9 +30,10 @@ export default function EmailsScreen() : React.ReactNode {const scrollViewRef = useRef<ScrollView>(null);const [error, setError] = useState<string | null>(null);const [emails, setEmails] = useState<MailboxEmail[]>([]);- const [isLoading, setIsLoading] = useMinDurationLoading(true, 300);+ const [isLoading, setIsLoading] = useMinDurationLoading(true, 200);const [isRefreshing, setIsRefreshing] = useState(false);const [isTabFocused, setIsTabFocused] = useState(false);+ const insets = useSafeAreaInsets();/*** Load emails.@@ -131,6 +132,7 @@ export default function EmailsScreen() : React.ReactNode {},container: {flex: 1,+ paddingTop: insets.top,},content: {flex: 1,@@ -149,6 +151,9 @@ export default function EmailsScreen() : React.ReactNode {color: colors.errorBackground,textAlign: 'center',},+ loadingContainer: {+ flex: 1,+ },});/**@@ -157,7 +162,7 @@ export default function EmailsScreen() : React.ReactNode {const renderContent = () : React.ReactNode => {if (isLoading) {return (- <View style={styles.container}>+ <View style={styles.loadingContainer}><SkeletonLoader count={4} height={90} parts={3} /></View>);@@ -187,7 +192,7 @@ export default function EmailsScreen() : React.ReactNode {};return (- <ThemedSafeAreaView style={styles.container}>+ <ThemedView style={styles.container}><CollapsibleHeadertitle="Emails"scrollY={scrollY}@@ -216,6 +221,6 @@ export default function EmailsScreen() : React.ReactNode {{renderContent()}</Animated.ScrollView></ThemedView>- </ThemedSafeAreaView>+ </ThemedView>);}diff --git a/apps/mobile-app/app/(tabs)/settings/index.tsx b/apps/mobile-app/app/(tabs)/settings/index.tsxindex 66b4af021..f9b826cf0 100644--- a/apps/mobile-app/app/(tabs)/settings/index.tsx+++ b/apps/mobile-app/app/(tabs)/settings/index.tsx@@ -2,6 +2,7 @@ import { StyleSheet, View, ScrollView, TouchableOpacity, Image, Animated, Platfoimport { router, useFocusEffect } from 'expo-router';import { Ionicons } from '@expo/vector-icons';import { useRef, useState, useCallback } from 'react';+import { useSafeAreaInsets } from 'react-native-safe-area-context';import { ThemedText } from '@/components/themed/ThemedText';import { ThemedView } from '@/components/themed/ThemedView';@@ -10,8 +11,9 @@ import { AppInfo } from '@/utils/AppInfo';import { useColors } from '@/hooks/useColorScheme';import { TitleContainer } from '@/components/ui/TitleContainer';import { useAuth } from '@/context/AuthContext';-import { ThemedSafeAreaView } from '@/components/themed/ThemedSafeAreaView';import { CollapsibleHeader } from '@/components/ui/CollapsibleHeader';+import { InlineSkeletonLoader } from '@/components/ui/InlineSkeletonLoader';+import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';import avatarImage from '@/assets/images/avatar.webp';/**@@ -26,6 +28,8 @@ export default function SettingsScreen() : React.ReactNode {const scrollViewRef = useRef<ScrollView>(null);const [autoLockDisplay, setAutoLockDisplay] = useState<string>('');const [authMethodDisplay, setAuthMethodDisplay] = useState<string>('');+ const [isFirstLoad, setIsFirstLoad] = useMinDurationLoading(true, 100);+ const insets = useSafeAreaInsets();useFocusEffect(useCallback(() => {@@ -65,9 +69,16 @@ export default function SettingsScreen() : React.ReactNode {setAuthMethodDisplay(authMethod);};- loadAutoLockDisplay();- loadAuthMethodDisplay();- }, [getAutoLockTimeout, getAuthMethodDisplay])+ /**+ * Load all settings data.+ */+ const loadData = async () : Promise<void> => {+ await Promise.all([loadAutoLockDisplay(), loadAuthMethodDisplay()]);+ setIsFirstLoad(false);+ };++ loadData();+ }, [getAutoLockTimeout, getAuthMethodDisplay, setIsFirstLoad]));/**@@ -108,6 +119,7 @@ export default function SettingsScreen() : React.ReactNode {},container: {flex: 1,+ paddingTop: insets.top,},content: {flex: 1,@@ -177,6 +189,9 @@ export default function SettingsScreen() : React.ReactNode {fontSize: 16,marginRight: 8,},+ skeletonLoader: {+ marginRight: 8,+ },userInfoContainer: {alignItems: 'center',backgroundColor: colors.background,@@ -202,11 +217,11 @@ export default function SettingsScreen() : React.ReactNode {});return (- <ThemedSafeAreaView style={styles.container}>+ <ThemedView style={styles.container}><CollapsibleHeadertitle="Settings"scrollY={scrollY}- showNavigationHeader={true}+ showNavigationHeader={false}/><ThemedView style={styles.content}><Animated.ScrollView@@ -260,7 +275,11 @@ export default function SettingsScreen() : React.ReactNode {</View><View style={styles.settingItemContent}><ThemedText style={styles.settingItemText}>Vault Unlock Method</ThemedText>- <ThemedText style={styles.settingItemValue}>{authMethodDisplay}</ThemedText>+ {isFirstLoad ? (+ <InlineSkeletonLoader width={100} style={styles.skeletonLoader} />+ ) : (+ <ThemedText style={styles.settingItemValue}>{authMethodDisplay}</ThemedText>+ )}<Ionicons name="chevron-forward" size={20} color={colors.textMuted} /></View></TouchableOpacity>@@ -274,7 +293,11 @@ export default function SettingsScreen() : React.ReactNode {</View><View style={styles.settingItemContent}><ThemedText style={styles.settingItemText}>Auto-lock Timeout</ThemedText>- <ThemedText style={styles.settingItemValue}>{autoLockDisplay}</ThemedText>+ {isFirstLoad ? (+ <InlineSkeletonLoader width={80} style={styles.skeletonLoader} />+ ) : (+ <ThemedText style={styles.settingItemValue}>{autoLockDisplay}</ThemedText>+ )}<Ionicons name="chevron-forward" size={20} color={colors.textMuted} /></View></TouchableOpacity>@@ -299,6 +322,6 @@ export default function SettingsScreen() : React.ReactNode {</View></Animated.ScrollView></ThemedView>- </ThemedSafeAreaView>+ </ThemedView>);}\ No newline at end of filediff --git a/apps/mobile-app/components/ui/CollapsibleHeader.tsx b/apps/mobile-app/components/ui/CollapsibleHeader.tsxindex d91588dc8..7dd8989f8 100644--- a/apps/mobile-app/components/ui/CollapsibleHeader.tsx+++ b/apps/mobile-app/components/ui/CollapsibleHeader.tsx@@ -50,7 +50,7 @@ export function CollapsibleHeader({});const headerTransform = alwaysVisible- ? 0+ ? new Animated.Value(0): headerOpacity.interpolate({inputRange: [0, 1],outputRange: [-20, 0],diff --git a/apps/mobile-app/components/ui/InlineSkeletonLoader.tsx b/apps/mobile-app/components/ui/InlineSkeletonLoader.tsxnew file mode 100644index 000000000..e8f3a535f--- /dev/null+++ b/apps/mobile-app/components/ui/InlineSkeletonLoader.tsx@@ -0,0 +1,80 @@+import { StyleSheet, View, Animated, ViewStyle, DimensionValue } from 'react-native';+import { useEffect, useRef } from 'react';+import { LinearGradient } from 'expo-linear-gradient';++import { useColors } from '@/hooks/useColorScheme';++type InlineSkeletonLoaderProps = {+ /** Width of the skeleton loader */+ width?: DimensionValue;+ /** Height of the skeleton loader */+ height?: number;+ /** Additional styles to apply to the skeleton loader */+ style?: ViewStyle;+}++/**+ * A small, inline skeleton loader component for loading states in text or small UI elements.+ * @param props - The component props+ * @returns A React node containing the inline skeleton loader+ */+export const InlineSkeletonLoader = ({+ width = 80,+ height = 16,+ style,+}: InlineSkeletonLoaderProps): React.ReactNode => {+ const colors = useColors();+ const animatedValue = useRef(new Animated.Value(0)).current;++ useEffect(() => {+ Animated.loop(+ Animated.sequence([+ Animated.timing(animatedValue, {+ toValue: 1,+ duration: 1000,+ useNativeDriver: true,+ }),+ Animated.timing(animatedValue, {+ toValue: 0,+ duration: 1000,+ useNativeDriver: true,+ }),+ ])+ ).start();+ }, [animatedValue]);++ const translateX = animatedValue.interpolate({+ inputRange: [0, 1],+ outputRange: [-50, 50],+ });++ const styles = StyleSheet.create({+ container: {+ backgroundColor: colors.skeleton,+ borderRadius: 4,+ height,+ overflow: 'hidden',+ width,+ },+ });++ return (+ <View style={[styles.container, style]}>+ <Animated.View+ style={[+ StyleSheet.absoluteFill,+ {+ transform: [{ translateX }],+ },+ ]}+ >+ <LinearGradient+ colors={['transparent', colors.skeleton, 'transparent']}+ start={{ x: 0, y: 0 }}+ end={{ x: 1, y: 0 }}+ style={StyleSheet.absoluteFill}+ />+ </Animated.View>+ </View>+ );+};\ No newline at end of filediff --git a/apps/mobile-app/components/ui/SkeletonLoader.tsx b/apps/mobile-app/components/ui/SkeletonLoader.tsxindex 8e7838c18..ef4506dcf 100644--- a/apps/mobile-app/components/ui/SkeletonLoader.tsx+++ b/apps/mobile-app/components/ui/SkeletonLoader.tsx@@ -4,7 +4,7 @@ import { LinearGradient } from 'expo-linear-gradient';import { useColors } from '@/hooks/useColorScheme';-interface ISkeletonLoaderProps {+type SkeletonLoaderProps = {/** Number of skeleton items to render */count?: number;/** Height of each skeleton item */@@ -25,7 +25,7 @@ export const SkeletonLoader = ({height = 60,parts = 2,style,-}: ISkeletonLoaderProps): React.ReactNode => {+}: SkeletonLoaderProps): React.ReactNode => {const colors = useColors();const animatedValue = useRef(new Animated.Value(0)).current;@@ -64,7 +64,7 @@ export const SkeletonLoader = ({padding: 16,},part: {- backgroundColor: colors.accentBorder,+ backgroundColor: colors.skeleton,borderRadius: 4,height: 12,width: `${100 / parts}%`,@@ -86,7 +86,7 @@ export const SkeletonLoader = ({]}><LinearGradient- colors={['transparent', colors.accentBorder, 'transparent']}+ colors={['transparent', colors.skeleton, 'transparent']}start={{ x: 0, y: 0 }}end={{ x: 1, y: 0 }}style={StyleSheet.absoluteFill}diff --git a/apps/mobile-app/constants/Colors.ts b/apps/mobile-app/constants/Colors.tsindex 49cb48061..570cc90a1 100644--- a/apps/mobile-app/constants/Colors.ts+++ b/apps/mobile-app/constants/Colors.ts@@ -26,6 +26,7 @@ export const Colors = {tertiary: '#eabf69',loginHeader: '#f6dfc4',greenBackground: '#22c55e',+ skeleton: '#rgba(255,255,255,0.4)',},dark: {white: '#ffffff',@@ -50,6 +51,7 @@ export const Colors = {tertiary: '#eabf69',loginHeader: '#5c4331',greenBackground: '#22c55e',+ skeleton: '#rgba(255,255,255,0.2)',},} as const;