Skip to content

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

Linting refactor components (#771)

Leendert de Borst15d707615a4f
diff --git a/apps/mobile-app/app/(tabs)/_layout.tsx b/apps/mobile-app/app/(tabs)/_layout.tsx
index 782c44015..0695c815b 100644
--- a/apps/mobile-app/app/(tabs)/_layout.tsx
+++ b/apps/mobile-app/app/(tabs)/_layout.tsx
@@ -8,7 +8,7 @@ import { useColors } from '@/hooks/useColorScheme';
import { useAuth } from '@/context/AuthContext';
import { useDb } from '@/context/DbContext';
import emitter from '@/utils/EventEmitter';
-import { ThemedText } from '@/components/ThemedText';
+import { ThemedText } from '@/components/themed/ThemedText';
/**
* This is the main layout for the app. It is used to navigate between the tabs.
diff --git a/apps/mobile-app/app/(tabs)/credentials/[id].tsx b/apps/mobile-app/app/(tabs)/credentials/[id].tsx
index b5ee78ab2..fedf57a07 100644
--- a/apps/mobile-app/app/(tabs)/credentials/[id].tsx
+++ b/apps/mobile-app/app/(tabs)/credentials/[id].tsx
@@ -4,10 +4,10 @@ import { ActivityIndicator, View, Text, StyleSheet, TouchableOpacity, Linking }
import Toast from 'react-native-toast-message';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
-import { ThemedScrollView } from '@/components/ThemedScrollView';
-import { CredentialIcon } from '@/components/CredentialIcon';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
+import { ThemedScrollView } from '@/components/themed/ThemedScrollView';
+import { CredentialIcon } from '@/components/credentials/CredentialIcon';
import { useDb } from '@/context/DbContext';
import { Credential } from '@/utils/types/Credential';
import { LoginCredentials } from '@/components/credentialDetails/LoginCredentials';
diff --git a/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx b/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx
index bc9342b9e..3789e66a9 100644
--- a/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx
+++ b/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx
@@ -6,9 +6,9 @@ import Toast from 'react-native-toast-message';
import { Resolver, useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
-import { ThemedSafeAreaView } from '@/components/ThemedSafeAreaView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
+import { ThemedSafeAreaView } from '@/components/themed/ThemedSafeAreaView';
import { useColors } from '@/hooks/useColorScheme';
import { useDb } from '@/context/DbContext';
import { useWebApi } from '@/context/WebApiContext';
@@ -19,7 +19,7 @@ import { AliasVaultToast } from '@/components/Toast';
import { useVaultMutate } from '@/hooks/useVaultMutate';
import { IdentityGeneratorEn, IdentityGeneratorNl, IdentityHelperUtils, BaseIdentityGenerator } from '@/utils/shared/identity-generator';
import { PasswordGenerator } from '@/utils/shared/password-generator';
-import { ValidatedFormField, ValidatedFormFieldRef } from '@/components/ValidatedFormField';
+import { ValidatedFormField, ValidatedFormFieldRef } from '@/components/form/ValidatedFormField';
import { credentialSchema } from '@/utils/validationSchema';
import LoadingOverlay from '@/components/LoadingOverlay';
diff --git a/apps/mobile-app/app/(tabs)/credentials/autofill-credential-created.tsx b/apps/mobile-app/app/(tabs)/credentials/autofill-credential-created.tsx
index c629e80cd..6804e040b 100644
--- a/apps/mobile-app/app/(tabs)/credentials/autofill-credential-created.tsx
+++ b/apps/mobile-app/app/(tabs)/credentials/autofill-credential-created.tsx
@@ -3,9 +3,9 @@ import { useNavigation, useRouter } from 'expo-router';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
import { useCallback, useEffect } from 'react';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
-import { ThemedSafeAreaView } from '@/components/ThemedSafeAreaView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
+import { ThemedSafeAreaView } from '@/components/themed/ThemedSafeAreaView';
import { useColors } from '@/hooks/useColorScheme';
/**
diff --git a/apps/mobile-app/app/(tabs)/credentials/index.tsx b/apps/mobile-app/app/(tabs)/credentials/index.tsx
index e0bd0d573..c334c7a48 100644
--- a/apps/mobile-app/app/(tabs)/credentials/index.tsx
+++ b/apps/mobile-app/app/(tabs)/credentials/index.tsx
@@ -5,17 +5,17 @@ import { useRouter } from 'expo-router';
import Toast from 'react-native-toast-message';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
-import { ThemedSafeAreaView } from '@/components/ThemedSafeAreaView';
+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';
import { useVaultSync } from '@/hooks/useVaultSync';
import { useColors } from '@/hooks/useColorScheme';
-import { CredentialCard } from '@/components/CredentialCard';
-import { TitleContainer } from '@/components/TitleContainer';
-import { CollapsibleHeader } from '@/components/CollapsibleHeader';
+import { CredentialCard } from '@/components/credentials/CredentialCard';
+import { TitleContainer } from '@/components/ui/TitleContainer';
+import { CollapsibleHeader } from '@/components/ui/CollapsibleHeader';
import emitter from '@/utils/EventEmitter';
/**
diff --git a/apps/mobile-app/app/(tabs)/emails/[id].tsx b/apps/mobile-app/app/(tabs)/emails/[id].tsx
index 5f4aeca2d..0dfa621a6 100644
--- a/apps/mobile-app/app/(tabs)/emails/[id].tsx
+++ b/apps/mobile-app/app/(tabs)/emails/[id].tsx
@@ -9,7 +9,7 @@ import { Email } from '@/utils/types/webapi/Email';
import { Credential } from '@/utils/types/Credential';
import { useDb } from '@/context/DbContext';
import { useWebApi } from '@/context/WebApiContext';
-import { ThemedText } from '@/components/ThemedText';
+import { ThemedText } from '@/components/themed/ThemedText';
import EncryptionUtility from '@/utils/EncryptionUtility';
import { useColors } from '@/hooks/useColorScheme';
import { IconSymbol } from '@/components/ui/IconSymbol';
diff --git a/apps/mobile-app/app/(tabs)/emails/index.tsx b/apps/mobile-app/app/(tabs)/emails/index.tsx
index 8436659de..13865b5bd 100644
--- a/apps/mobile-app/app/(tabs)/emails/index.tsx
+++ b/apps/mobile-app/app/(tabs)/emails/index.tsx
@@ -5,14 +5,14 @@ import { useNavigation } from 'expo-router';
import { MailboxEmail } from '@/utils/types/webapi/MailboxEmail';
import { useDb } from '@/context/DbContext';
import { useWebApi } from '@/context/WebApiContext';
-import { ThemedText } from '@/components/ThemedText';
-import { TitleContainer } from '@/components/TitleContainer';
-import { CollapsibleHeader } from '@/components/CollapsibleHeader';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { TitleContainer } from '@/components/ui/TitleContainer';
+import { CollapsibleHeader } from '@/components/ui/CollapsibleHeader';
import { MailboxBulkRequest, MailboxBulkResponse } from '@/utils/types/webapi/MailboxBulk';
import EncryptionUtility from '@/utils/EncryptionUtility';
import { useColors } from '@/hooks/useColorScheme';
-import { ThemedView } from '@/components/ThemedView';
-import { ThemedSafeAreaView } from '@/components/ThemedSafeAreaView';
+import { ThemedView } from '@/components/themed/ThemedView';
+import { ThemedSafeAreaView } from '@/components/themed/ThemedSafeAreaView';
import { EmailCard } from '@/components/EmailCard';
import emitter from '@/utils/EventEmitter';
diff --git a/apps/mobile-app/app/(tabs)/settings/auto-lock.tsx b/apps/mobile-app/app/(tabs)/settings/auto-lock.tsx
index 3cb375be7..0009501a6 100644
--- a/apps/mobile-app/app/(tabs)/settings/auto-lock.tsx
+++ b/apps/mobile-app/app/(tabs)/settings/auto-lock.tsx
@@ -2,8 +2,8 @@ import { StyleSheet, View, TouchableOpacity, ScrollView } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { useEffect, useState } from 'react';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
import { useColors } from '@/hooks/useColorScheme';
import { useAuth } from '@/context/AuthContext';
diff --git a/apps/mobile-app/app/(tabs)/settings/index.tsx b/apps/mobile-app/app/(tabs)/settings/index.tsx
index f210d7953..ae1da4c81 100644
--- a/apps/mobile-app/app/(tabs)/settings/index.tsx
+++ b/apps/mobile-app/app/(tabs)/settings/index.tsx
@@ -3,15 +3,15 @@ import { router } from 'expo-router';
import { Ionicons } from '@expo/vector-icons';
import { useRef, useState, useEffect } from 'react';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
import { useWebApi } from '@/context/WebApiContext';
import { AppInfo } from '@/utils/AppInfo';
import { useColors } from '@/hooks/useColorScheme';
-import { TitleContainer } from '@/components/TitleContainer';
+import { TitleContainer } from '@/components/ui/TitleContainer';
import { useAuth } from '@/context/AuthContext';
-import { ThemedSafeAreaView } from '@/components/ThemedSafeAreaView';
-import { CollapsibleHeader } from '@/components/CollapsibleHeader';
+import { ThemedSafeAreaView } from '@/components/themed/ThemedSafeAreaView';
+import { CollapsibleHeader } from '@/components/ui/CollapsibleHeader';
import avatarImage from '@/assets/images/avatar.webp';
/**
diff --git a/apps/mobile-app/app/(tabs)/settings/ios-autofill.tsx b/apps/mobile-app/app/(tabs)/settings/ios-autofill.tsx
index 44926cbe3..e1f453f1c 100644
--- a/apps/mobile-app/app/(tabs)/settings/ios-autofill.tsx
+++ b/apps/mobile-app/app/(tabs)/settings/ios-autofill.tsx
@@ -1,8 +1,8 @@
import { StyleSheet, View, TouchableOpacity, ScrollView, Linking } from 'react-native';
import { router } from 'expo-router';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
import { useColors } from '@/hooks/useColorScheme';
import { useAuth } from '@/context/AuthContext';
diff --git a/apps/mobile-app/app/(tabs)/settings/vault-unlock.tsx b/apps/mobile-app/app/(tabs)/settings/vault-unlock.tsx
index b01339e66..219e34a00 100644
--- a/apps/mobile-app/app/(tabs)/settings/vault-unlock.tsx
+++ b/apps/mobile-app/app/(tabs)/settings/vault-unlock.tsx
@@ -2,8 +2,8 @@ import { StyleSheet, View, ScrollView, Alert, Platform, Linking, Switch, Touchab
import * as LocalAuthentication from 'expo-local-authentication';
import { useState, useEffect, useCallback } from 'react';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedSafeAreaView } from '@/components/ThemedSafeAreaView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedSafeAreaView } from '@/components/themed/ThemedSafeAreaView';
import { useColors } from '@/hooks/useColorScheme';
import { AuthMethod, useAuth } from '@/context/AuthContext';
diff --git a/apps/mobile-app/app/+not-found.tsx b/apps/mobile-app/app/+not-found.tsx
index a6695d0b5..9a1bc7f59 100644
--- a/apps/mobile-app/app/+not-found.tsx
+++ b/apps/mobile-app/app/+not-found.tsx
@@ -1,8 +1,8 @@
import { Link, Stack } from 'expo-router';
import { StyleSheet } from 'react-native';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
/**
* Not found screen.
@@ -12,9 +12,9 @@ export default function NotFoundScreen() : React.ReactNode {
<>
<Stack.Screen options={{ title: 'Oops!' }} />
<ThemedView style={styles.container}>
- <ThemedText type="title">This screen doesn&apos;t exist.</ThemedText>
- <Link href="/login" style={styles.link}>
- <ThemedText type="link">Go to home screen!</ThemedText>
+ <ThemedText type="title">This page doesn&apos;t exist.</ThemedText>
+ <Link href="/sync" style={styles.link}>
+ <ThemedText type="link">Go back to the home page</ThemedText>
</Link>
</ThemedView>
</>
diff --git a/apps/mobile-app/app/login.tsx b/apps/mobile-app/app/login.tsx
index b57ea811f..491d53161 100644
--- a/apps/mobile-app/app/login.tsx
+++ b/apps/mobile-app/app/login.tsx
@@ -7,7 +7,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import { useFocusEffect } from '@react-navigation/native';
import { MaterialIcons } from '@expo/vector-icons';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedView } from '@/components/themed/ThemedView';
import { useDb } from '@/context/DbContext';
import { useAuth } from '@/context/AuthContext';
import { SrpUtility } from '@/utils/SrpUtility';
diff --git a/apps/mobile-app/app/settings.tsx b/apps/mobile-app/app/settings.tsx
index 940b087ab..194e2b3aa 100644
--- a/apps/mobile-app/app/settings.tsx
+++ b/apps/mobile-app/app/settings.tsx
@@ -3,7 +3,7 @@ import { useState, useEffect } from 'react';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useColors } from '@/hooks/useColorScheme';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedView } from '@/components/themed/ThemedView';
import { AppInfo } from '@/utils/AppInfo';
type ApiOption = {
diff --git a/apps/mobile-app/app/sync.tsx b/apps/mobile-app/app/sync.tsx
index d199c0f0b..4ed4e6844 100644
--- a/apps/mobile-app/app/sync.tsx
+++ b/apps/mobile-app/app/sync.tsx
@@ -6,7 +6,7 @@ import NativeVaultManager from '../specs/NativeVaultManager';
import { useAuth } from '@/context/AuthContext';
import { useVaultSync } from '@/hooks/useVaultSync';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedView } from '@/components/themed/ThemedView';
import LoadingIndicator from '@/components/LoadingIndicator';
import { useDb } from '@/context/DbContext';
diff --git a/apps/mobile-app/app/unlock.tsx b/apps/mobile-app/app/unlock.tsx
index 0aaf7a8c8..6cceed682 100644
--- a/apps/mobile-app/app/unlock.tsx
+++ b/apps/mobile-app/app/unlock.tsx
@@ -5,8 +5,8 @@ import { MaterialIcons } from '@expo/vector-icons';
import { useAuth } from '@/context/AuthContext';
import { useDb } from '@/context/DbContext';
-import { ThemedView } from '@/components/ThemedView';
-import { ThemedText } from '@/components/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
+import { ThemedText } from '@/components/themed/ThemedText';
import LoadingIndicator from '@/components/LoadingIndicator';
import { useColors } from '@/hooks/useColorScheme';
import Logo from '@/assets/images/logo.svg';
diff --git a/apps/mobile-app/components/Collapsible.tsx b/apps/mobile-app/components/Collapsible.tsx
deleted file mode 100644
index 55bff2f91..000000000
--- a/apps/mobile-app/components/Collapsible.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { PropsWithChildren, useState } from 'react';
-import { StyleSheet, TouchableOpacity } from 'react-native';
-
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
-import { IconSymbol } from '@/components/ui/IconSymbol';
-import { Colors } from '@/constants/Colors';
-import { useColorScheme } from '@/hooks/useColorScheme';
-
-export function Collapsible({ children, title }: PropsWithChildren & { title: string }) {
- const [isOpen, setIsOpen] = useState(false);
- const theme = useColorScheme() ?? 'light';
-
- return (
- <ThemedView>
- <TouchableOpacity
- style={styles.heading}
- onPress={() => setIsOpen((value) => !value)}
- activeOpacity={0.8}>
- <IconSymbol
- name="chevron.right"
- size={18}
- weight="medium"
- color={theme === 'light' ? Colors.light.icon : Colors.dark.icon}
- style={{ transform: [{ rotate: isOpen ? '90deg' : '0deg' }] }}
- />
-
- <ThemedText type="defaultSemiBold">{title}</ThemedText>
- </TouchableOpacity>
- {isOpen && <ThemedView style={styles.content}>{children}</ThemedView>}
- </ThemedView>
- );
-}
-
-const styles = StyleSheet.create({
- heading: {
- flexDirection: 'row',
- alignItems: 'center',
- gap: 6,
- },
- content: {
- marginTop: 6,
- marginLeft: 24,
- },
-});
diff --git a/apps/mobile-app/components/EmailCard.tsx b/apps/mobile-app/components/EmailCard.tsx
index 733b493b0..46ca9b7d4 100644
--- a/apps/mobile-app/components/EmailCard.tsx
+++ b/apps/mobile-app/components/EmailCard.tsx
@@ -1,16 +1,23 @@
import { StyleSheet, View, TouchableOpacity } from 'react-native';
+import { router } from 'expo-router';
+
+import { ThemedText } from '@/components/themed/ThemedText';
import { useColors } from '@/hooks/useColorScheme';
-import { ThemedText } from './ThemedText';
import { MailboxEmail } from '@/utils/types/webapi/MailboxEmail';
-import { router } from 'expo-router';
type EmailCardProps = {
email: MailboxEmail;
};
-export function EmailCard({ email }: EmailCardProps) {
+/**
+ * Email card component.
+ */
+export function EmailCard({ email }: EmailCardProps) : React.ReactNode {
const colors = useColors();
+ /**
+ * Format the email date.
+ */
const formatEmailDate = (dateSystem: string): string => {
const now = new Date();
const emailDate = new Date(dateSystem);
@@ -37,11 +44,12 @@ export function EmailCard({ email }: EmailCardProps) {
const styles = StyleSheet.create({
emailCard: {
backgroundColor: colors.accentBackground,
+ borderColor: colors.accentBorder,
borderRadius: 8,
- padding: 12,
- marginBottom: 12,
borderWidth: 1,
- borderColor: colors.accentBorder,
+ elevation: 3,
+ marginBottom: 12,
+ padding: 12,
shadowColor: colors.text,
shadowOffset: {
width: 0,
@@ -49,30 +57,29 @@ export function EmailCard({ email }: EmailCardProps) {
},
shadowOpacity: 0.1,
shadowRadius: 3,
- elevation: 3,
+ },
+ emailDate: {
+ color: colors.textMuted,
+ fontSize: 12,
+ opacity: 0.6,
},
emailHeader: {
+ alignItems: 'flex-start',
flexDirection: 'row',
justifyContent: 'space-between',
- alignItems: 'flex-start',
marginBottom: 8,
},
+ emailPreview: {
+ color: colors.text,
+ fontSize: 14,
+ opacity: 0.8,
+ },
emailSubject: {
+ color: colors.text,
flex: 1,
fontSize: 16,
fontWeight: 'bold',
marginRight: 8,
- color: colors.text,
- },
- emailDate: {
- fontSize: 12,
- opacity: 0.6,
- color: colors.textMuted,
- },
- emailPreview: {
- fontSize: 14,
- opacity: 0.8,
- color: colors.text,
},
});
diff --git a/apps/mobile-app/components/ExternalLink.tsx b/apps/mobile-app/components/ExternalLink.tsx
deleted file mode 100644
index 8f05675b2..000000000
--- a/apps/mobile-app/components/ExternalLink.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Link } from 'expo-router';
-import { openBrowserAsync } from 'expo-web-browser';
-import { type ComponentProps } from 'react';
-import { Platform } from 'react-native';
-
-type Props = Omit<ComponentProps<typeof Link>, 'href'> & { href: string };
-
-export function ExternalLink({ href, ...rest }: Props) {
- return (
- <Link
- target="_blank"
- {...rest}
- href={href}
- onPress={async (event) => {
- if (Platform.OS !== 'web') {
- // Prevent the default behavior of linking to the default browser on native.
- event.preventDefault();
- // Open the link in an in-app browser.
- await openBrowserAsync(href);
- }
- }}
- />
- );
-}
diff --git a/apps/mobile-app/components/HelloWave.tsx b/apps/mobile-app/components/HelloWave.tsx
deleted file mode 100644
index 9b4bc31cb..000000000
--- a/apps/mobile-app/components/HelloWave.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { useEffect } from 'react';
-import { StyleSheet } from 'react-native';
-import Animated, {
- useSharedValue,
- useAnimatedStyle,
- withTiming,
- withRepeat,
- withSequence,
-} from 'react-native-reanimated';
-
-import { ThemedText } from '@/components/ThemedText';
-
-export function HelloWave() {
- const rotationAnimation = useSharedValue(0);
-
- useEffect(() => {
- rotationAnimation.value = withRepeat(
- withSequence(withTiming(25, { duration: 150 }), withTiming(0, { duration: 150 })),
- 4 // Run the animation 4 times
- );
- }, []);
-
- const animatedStyle = useAnimatedStyle(() => ({
- transform: [{ rotate: `${rotationAnimation.value}deg` }],
- }));
-
- return (
- <Animated.View style={animatedStyle}>
- <ThemedText style={styles.text}>👋</ThemedText>
- </Animated.View>
- );
-}
-
-const styles = StyleSheet.create({
- text: {
- fontSize: 28,
- lineHeight: 32,
- marginTop: -6,
- },
-});
diff --git a/apps/mobile-app/components/LoadingIndicator.tsx b/apps/mobile-app/components/LoadingIndicator.tsx
index ae5fe17e9..f7c60a141 100644
--- a/apps/mobile-app/components/LoadingIndicator.tsx
+++ b/apps/mobile-app/components/LoadingIndicator.tsx
@@ -1,21 +1,29 @@
import { StyleSheet, View, Text, Animated } from 'react-native';
import { useEffect, useRef, useState } from 'react';
+
import { useColors } from '@/hooks/useColorScheme';
-interface LoadingIndicatorProps {
+type LoadingIndicatorProps = {
status: string;
-}
+};
-export default function LoadingIndicator({ status }: LoadingIndicatorProps) {
+/**
+ * Loading indicator component.
+ */
+export default function LoadingIndicator({ status }: LoadingIndicatorProps): React.ReactNode {
const colors = useColors();
const dot1Anim = useRef(new Animated.Value(0)).current;
const dot2Anim = useRef(new Animated.Value(0)).current;
const dot3Anim = useRef(new Animated.Value(0)).current;
const dot4Anim = useRef(new Animated.Value(0)).current;
+ const animationRef = useRef<Animated.CompositeAnimation | null>(null);
const [dots, setDots] = useState('');
useEffect(() => {
- const createPulseAnimation = (anim: Animated.Value) => {
+ /**
+ * Create the pulse animation.
+ */
+ const createPulseAnimation = (anim: Animated.Value): Animated.CompositeAnimation => {
return Animated.sequence([
Animated.timing(anim, {
toValue: 1,
@@ -30,7 +38,12 @@ export default function LoadingIndicator({ status }: LoadingIndicatorProps) {
]);
};
- const animation = Animated.loop(
+ // Stop any previous animation
+ if (animationRef.current) {
+ animationRef.current.stop();
+ }
+
+ const newAnimation = Animated.loop(
Animated.parallel([
createPulseAnimation(dot1Anim),
Animated.sequence([
@@ -48,64 +61,74 @@ export default function LoadingIndicator({ status }: LoadingIndicatorProps) {
])
);
+ animationRef.current = newAnimation;
+ newAnimation.start();
+
// Reset dots when status changes
setDots('');
const dotsInterval = setInterval(() => {
setDots(prevDots => {
- if (prevDots.length >= 3) return '';
+ if (prevDots.length >= 3) {
+ return '';
+ }
return prevDots + '.';
});
}, 400);
- animation.start();
-
- return () => {
- animation.stop();
+ return (): void => {
+ if (animationRef.current) {
+ animationRef.current.stop();
+ }
clearInterval(dotsInterval);
};
- }, [status]);
+ }, [status, dot1Anim, dot2Anim, dot3Anim, dot4Anim]);
- // If the status ends with a pipe character (|), don't show any dots
- // This provides an explicit way to disable the loading dots animation
+ /*
+ * If the status ends with a pipe character (|), don't show any dots
+ * This provides an explicit way to disable the loading dots animation
+ */
const statusTrimmed = status.endsWith('|') ? status.slice(0, -1) : status;
const shouldShowDots = !status.endsWith('|');
+ const backgroundColor = 'transparent';
+ const shadowColor = '#000';
+
const styles = StyleSheet.create({
container: {
+ alignItems: 'center',
flex: 1,
justifyContent: 'center',
- alignItems: 'center',
padding: 20,
},
+ dot: {
+ backgroundColor: colors.tertiary,
+ borderRadius: 4,
+ height: 8,
+ width: 8,
+ },
dotsContainer: {
- flexDirection: 'row',
- backgroundColor: 'transparent',
+ backgroundColor: backgroundColor,
+ borderColor: colors.tertiary,
borderRadius: 20,
+ borderWidth: 5,
+ elevation: 1,
+ flexDirection: 'row',
+ gap: 10,
padding: 12,
paddingHorizontal: 24,
- gap: 10,
- borderWidth: 5,
- borderColor: colors.tertiary,
- shadowColor: '#000',
+ shadowColor: shadowColor,
shadowOffset: {
width: 0,
height: 1,
},
shadowOpacity: 0.05,
shadowRadius: 2,
- elevation: 1,
- },
- dot: {
- width: 8,
- height: 8,
- borderRadius: 4,
- backgroundColor: colors.tertiary,
},
statusText: {
- marginTop: 16,
- fontSize: 16,
color: colors.text,
+ fontSize: 16,
+ marginTop: 16,
textAlign: 'center',
},
});
@@ -164,4 +187,4 @@ export default function LoadingIndicator({ status }: LoadingIndicatorProps) {
</Text>
</View>
);
-}
\ No newline at end of file
+}
diff --git a/apps/mobile-app/components/LoadingOverlay.tsx b/apps/mobile-app/components/LoadingOverlay.tsx
index 8d0913c7b..73357ce3d 100644
--- a/apps/mobile-app/components/LoadingOverlay.tsx
+++ b/apps/mobile-app/components/LoadingOverlay.tsx
@@ -1,10 +1,10 @@
import { StyleSheet, View } from 'react-native';
-import { useColors } from '@/hooks/useColorScheme';
+
import LoadingIndicator from './LoadingIndicator';
-interface LoadingOverlayProps {
+type LoadingOverlayProps = {
status: string;
-}
+};
/**
* LoadingOverlay component
@@ -13,19 +13,19 @@ interface LoadingOverlayProps {
* It is used to indicate that a process is in progress and the user should wait.
*
*/
-export default function LoadingOverlay({ status }: LoadingOverlayProps) {
- const colors = useColors();
+export default function LoadingOverlay({ status }: LoadingOverlayProps): React.ReactNode {
+ const backgroundColor = 'rgba(0,0,0,0.5)';
const styles = StyleSheet.create({
container: {
- position: 'absolute',
- top: 0,
- left: 0,
- right: 0,
+ alignItems: 'center',
+ backgroundColor: backgroundColor,
bottom: 0,
- backgroundColor: 'rgba(0,0,0,0.5)',
justifyContent: 'center',
- alignItems: 'center',
+ left: 0,
+ position: 'absolute',
+ right: 0,
+ top: 0,
zIndex: 1000,
},
});
diff --git a/apps/mobile-app/components/ParallaxScrollView.tsx b/apps/mobile-app/components/ParallaxScrollView.tsx
deleted file mode 100644
index 5df1d75fd..000000000
--- a/apps/mobile-app/components/ParallaxScrollView.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import type { PropsWithChildren, ReactElement } from 'react';
-import { StyleSheet } from 'react-native';
-import Animated, {
- interpolate,
- useAnimatedRef,
- useAnimatedStyle,
- useScrollViewOffset,
-} from 'react-native-reanimated';
-
-import { ThemedView } from '@/components/ThemedView';
-import { useBottomTabOverflow } from '@/components/ui/TabBarBackground';
-import { useColorScheme } from '@/hooks/useColorScheme';
-
-const HEADER_HEIGHT = 250;
-
-type Props = PropsWithChildren<{
- headerImage: ReactElement;
- headerBackgroundColor: { dark: string; light: string };
-}>;
-
-export default function ParallaxScrollView({
- children,
- headerImage,
- headerBackgroundColor,
-}: Props) {
- const colorScheme = useColorScheme() ?? 'light';
- const scrollRef = useAnimatedRef<Animated.ScrollView>();
- const scrollOffset = useScrollViewOffset(scrollRef);
- const bottom = useBottomTabOverflow();
- const headerAnimatedStyle = useAnimatedStyle(() => {
- return {
- transform: [
- {
- translateY: interpolate(
- scrollOffset.value,
- [-HEADER_HEIGHT, 0, HEADER_HEIGHT],
- [-HEADER_HEIGHT / 2, 0, HEADER_HEIGHT * 0.75]
- ),
- },
- {
- scale: interpolate(scrollOffset.value, [-HEADER_HEIGHT, 0, HEADER_HEIGHT], [2, 1, 1]),
- },
- ],
- };
- });
-
- return (
- <ThemedView style={styles.container}>
- <Animated.ScrollView
- ref={scrollRef}
- scrollEventThrottle={16}
- scrollIndicatorInsets={{ bottom }}
- contentContainerStyle={{ paddingBottom: bottom }}>
- <Animated.View
- style={[
- styles.header,
- { backgroundColor: headerBackgroundColor[colorScheme] },
- headerAnimatedStyle,
- ]}>
- {headerImage}
- </Animated.View>
- <ThemedView style={styles.content}>{children}</ThemedView>
- </Animated.ScrollView>
- </ThemedView>
- );
-}
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- },
- header: {
- height: HEADER_HEIGHT,
- overflow: 'hidden',
- },
- content: {
- flex: 1,
- padding: 32,
- gap: 16,
- overflow: 'hidden',
- },
-});
diff --git a/apps/mobile-app/components/PulseDot.tsx b/apps/mobile-app/components/PulseDot.tsx
index 2ec53127a..d7960f3fd 100644
--- a/apps/mobile-app/components/PulseDot.tsx
+++ b/apps/mobile-app/components/PulseDot.tsx
@@ -1,7 +1,13 @@
import React, { useEffect, useRef } from 'react';
import { StyleSheet, Animated } from 'react-native';
+import { useColors } from '@/hooks/useColorScheme';
+
+/**
+ * Pulsing dot component.
+ */
export const PulseDot: React.FC = () => {
+ const colors = useColors();
const pulseAnim = useRef(new Animated.Value(1)).current;
useEffect(() => {
@@ -22,17 +28,17 @@ export const PulseDot: React.FC = () => {
pulseAnimation.start();
- return () => {
+ return (): void => {
pulseAnimation.stop();
};
- }, []);
+ }, [pulseAnim, colors]);
const styles = StyleSheet.create({
refreshDot: {
- width: 8,
- height: 8,
+ backgroundColor: colors.greenBackground,
borderRadius: 4,
- backgroundColor: '#22c55e', // green-500
+ height: 8,
+ width: 8,
},
});
diff --git a/apps/mobile-app/components/ThemedScrollView.tsx b/apps/mobile-app/components/ThemedScrollView.tsx
deleted file mode 100644
index 5343dbe62..000000000
--- a/apps/mobile-app/components/ThemedScrollView.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import { ScrollView, StyleSheet } from 'react-native';
-
-export function ThemedScrollView({ style, lightColor, darkColor, ...otherProps }: ThemedScrollViewProps) {
- return (
- <ScrollView
- style={[styles.container, style]}
- {...otherProps}
- />
- );
-}
-
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- marginBottom: 80,
- },
-});
diff --git a/apps/mobile-app/components/Toast.tsx b/apps/mobile-app/components/Toast.tsx
index 47528ac49..f630673a8 100644
--- a/apps/mobile-app/components/Toast.tsx
+++ b/apps/mobile-app/components/Toast.tsx
@@ -1,8 +1,16 @@
import { View, Text } from 'react-native';
import Toast from 'react-native-toast-message';
+type ToastProps = {
+ text1: string;
+ text2?: string;
+};
+
export const toastConfig = {
- success: (props: any) => (
+ /**
+ * Success toast.
+ */
+ success: (props: ToastProps): React.ReactNode => (
<View
style={{
backgroundColor: '#f97316', // AliasVault orange
@@ -26,7 +34,10 @@ export const toastConfig = {
</Text>
</View>
),
- error: (props: any) => (
+ /**
+ * Error toast.
+ */
+ error: (props: ToastProps): React.ReactNode => (
<View
style={{
backgroundColor: '#dc2626', // Red
@@ -55,7 +66,10 @@ export const toastConfig = {
)}
</View>
),
- info: (props: any) => (
+ /**
+ * Info toast.
+ */
+ info: (props: ToastProps): React.ReactNode => (
<View
style={{
backgroundColor: '#3b82f6', // Blue
@@ -81,6 +95,9 @@ export const toastConfig = {
),
};
-export const AliasVaultToast = () => {
+/**
+ * AliasVault toast component.
+ */
+export const AliasVaultToast = (): React.ReactNode => {
return <Toast config={toastConfig} />;
};
diff --git a/apps/mobile-app/components/__tests__/ThemedText-test.tsx b/apps/mobile-app/components/__tests__/ThemedText-test.tsx
index 1ac322506..f381eabeb 100644
--- a/apps/mobile-app/components/__tests__/ThemedText-test.tsx
+++ b/apps/mobile-app/components/__tests__/ThemedText-test.tsx
@@ -1,7 +1,7 @@
import * as React from 'react';
import renderer from 'react-test-renderer';
-import { ThemedText } from '../ThemedText';
+import { ThemedText } from '../themed/ThemedText';
it(`renders correctly`, () => {
const tree = renderer.create(<ThemedText>Snapshot test!</ThemedText>).toJSON();
diff --git a/apps/mobile-app/components/CredentialCard.tsx b/apps/mobile-app/components/credentials/CredentialCard.tsx
similarity index 90%
rename from apps/mobile-app/components/CredentialCard.tsx
rename to apps/mobile-app/components/credentials/CredentialCard.tsx
index 5241bc823..864aa8de2 100644
--- a/apps/mobile-app/components/CredentialCard.tsx
+++ b/apps/mobile-app/components/credentials/CredentialCard.tsx
@@ -1,14 +1,18 @@
import { StyleSheet, View, Text, TouchableOpacity, Keyboard } from 'react-native';
-import { CredentialIcon } from './CredentialIcon';
+import { router } from 'expo-router';
+
+import { CredentialIcon } from '@/components/credentials/CredentialIcon';
import { useColors } from '@/hooks/useColorScheme';
import { Credential } from '@/utils/types/Credential';
-import { router } from 'expo-router';
type CredentialCardProps = {
credential: Credential;
};
-export function CredentialCard({ credential }: CredentialCardProps) {
+/**
+ * Credential card component.
+ */
+export function CredentialCard({ credential }: CredentialCardProps) : React.ReactNode {
const colors = useColors();
/**
@@ -33,24 +37,28 @@ export function CredentialCard({ credential }: CredentialCardProps) {
const styles = StyleSheet.create({
credentialCard: {
backgroundColor: colors.accentBackground,
+ borderColor: colors.accentBorder,
borderRadius: 8,
- padding: 12,
- marginBottom: 8,
borderWidth: 1,
- borderColor: colors.accentBorder,
+ marginBottom: 8,
+ padding: 12,
},
credentialContent: {
- flexDirection: 'row',
alignItems: 'center',
+ flexDirection: 'row',
+ },
+ credentialInfo: {
+ flex: 1,
+ },
+ credentialText: {
+ color: colors.textMuted,
+ fontSize: 14,
},
logo: {
- width: 32,
- height: 32,
borderRadius: 4,
+ height: 32,
marginRight: 12,
- },
- credentialInfo: {
- flex: 1,
+ width: 32,
},
serviceName: {
color: colors.text,
@@ -58,10 +66,6 @@ export function CredentialCard({ credential }: CredentialCardProps) {
fontWeight: '600',
marginBottom: 4,
},
- credentialText: {
- color: colors.textMuted,
- fontSize: 14,
- },
});
return (
@@ -76,10 +80,10 @@ export function CredentialCard({ credential }: CredentialCardProps) {
<View style={styles.credentialContent}>
<CredentialIcon logo={credential.Logo} style={styles.logo} />
<View style={styles.credentialInfo}>
- <Text style={[styles.serviceName]}>
+ <Text style={styles.serviceName}>
{credential.ServiceName ?? 'Unknown Service'}
</Text>
- <Text style={[styles.credentialText]}>
+ <Text style={styles.credentialText}>
{getCredentialDisplayText(credential)}
</Text>
</View>
diff --git a/apps/mobile-app/components/CredentialIcon.tsx b/apps/mobile-app/components/credentials/CredentialIcon.tsx
similarity index 78%
rename from apps/mobile-app/components/CredentialIcon.tsx
rename to apps/mobile-app/components/credentials/CredentialIcon.tsx
index 030f3750f..de674cd01 100644
--- a/apps/mobile-app/components/CredentialIcon.tsx
+++ b/apps/mobile-app/components/credentials/CredentialIcon.tsx
@@ -1,16 +1,28 @@
-import { Image, ImageStyle, StyleSheet } from 'react-native';
import { Buffer } from 'buffer';
+
+import { Image, ImageStyle, StyleSheet } from 'react-native';
import { SvgUri } from 'react-native-svg';
+import servicePlaceholder from '@/assets/images/service-placeholder.webp';
+
+/**
+ * Credential icon props.
+ */
type CredentialIconProps = {
logo?: Uint8Array | number[] | string | null;
style?: ImageStyle;
};
-export function CredentialIcon({ logo, style }: CredentialIconProps) {
- const getLogoSource = (logoData: Uint8Array | number[] | string | null | undefined) => {
+/**
+ * Credential icon component.
+ */
+export function CredentialIcon({ logo, style }: CredentialIconProps) : React.ReactNode {
+ /**
+ * Get the logo source.
+ */
+ const getLogoSource = (logoData: Uint8Array | number[] | string | null | undefined) : { type: 'image' | 'svg', source: string | number } => {
if (!logoData) {
- return { type: 'image', source: require('@/assets/images/service-placeholder.webp') };
+ return { type: 'image', source: servicePlaceholder };
}
try {
@@ -33,23 +45,25 @@ export function CredentialIcon({ logo, style }: CredentialIconProps) {
};
} catch (error) {
console.error('Error converting logo:', error);
- return { type: 'image', source: require('@/assets/images/service-placeholder.webp') };
+ return { type: 'image', source: servicePlaceholder };
}
};
const logoSource = getLogoSource(logo);
if (logoSource.type === 'svg') {
- // SVGs are not supported in React Native Image component,
- // so we use SvgUri from react-native-svg.
+ /*
+ * SVGs are not supported in React Native Image component,
+ * so we use SvgUri from react-native-svg.
+ */
return (
<SvgUri
- uri={logoSource.source}
+ uri={logoSource.source as string}
width={Number(style?.width ?? styles.logo.width)}
height={Number(style?.height ?? styles.logo.height)}
style={{
borderRadius: styles.logo.borderRadius,
- ...(style as any),
+ ...(style as ImageStyle),
}}
/>
);
@@ -59,7 +73,7 @@ export function CredentialIcon({ logo, style }: CredentialIconProps) {
<Image
source={typeof logoSource.source === 'string' ? { uri: logoSource.source } : logoSource.source}
style={[styles.logo, style]}
- defaultSource={require('@/assets/images/service-placeholder.webp')}
+ defaultSource={servicePlaceholder}
/>
);
}
@@ -85,22 +99,37 @@ function detectMimeTypeFromBase64(base64: string): string {
* Detect MIME type from file signature (magic numbers)
*/
function detectMimeType(bytes: Uint8Array): string {
+ /**
+ * Check if the file is an SVG.
+ */
const isSvg = (): boolean => {
const header = new TextDecoder().decode(bytes.slice(0, 5)).toLowerCase();
return header.includes('<?xml') || header.includes('<svg');
};
+ /**
+ * Check if the file is an ICO.
+ */
const isIco = (): boolean => {
return bytes[0] === 0x00 && bytes[1] === 0x00 && bytes[2] === 0x01 && bytes[3] === 0x00;
};
+ /**
+ * Check if the file is a PNG.
+ */
const isPng = (): boolean => {
return bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4E && bytes[3] === 0x47;
};
- if (isSvg()) return 'image/svg+xml';
- if (isIco()) return 'image/x-icon';
- if (isPng()) return 'image/png';
+ if (isSvg()) {
+ return 'image/svg+xml';
+ }
+ if (isIco()) {
+ return 'image/x-icon';
+ }
+ if (isPng()) {
+ return 'image/png';
+ }
return 'image/x-icon';
}
@@ -128,8 +157,8 @@ function toUint8Array(buffer: Uint8Array | number[] | {[key: number]: number}):
const styles = StyleSheet.create({
logo: {
- width: 32,
- height: 32,
borderRadius: 4,
+ height: 32,
+ width: 32,
},
});
\ No newline at end of file
diff --git a/apps/mobile-app/components/credentialDetails/AliasDetails.tsx b/apps/mobile-app/components/credentials/details/AliasDetails.tsx
similarity index 89%
rename from apps/mobile-app/components/credentialDetails/AliasDetails.tsx
rename to apps/mobile-app/components/credentials/details/AliasDetails.tsx
index 9908a9123..c9547ecb4 100644
--- a/apps/mobile-app/components/credentialDetails/AliasDetails.tsx
+++ b/apps/mobile-app/components/credentials/details/AliasDetails.tsx
@@ -1,7 +1,7 @@
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
import { Credential } from '@/utils/types/Credential';
-import FormInputCopyToClipboard from '@/components/FormInputCopyToClipboard';
+import FormInputCopyToClipboard from '@/components/form/FormInputCopyToClipboard';
import { IdentityHelperUtils } from '@/utils/shared/identity-generator';
type AliasDetailsProps = {
diff --git a/apps/mobile-app/components/credentialDetails/EmailPreview.tsx b/apps/mobile-app/components/credentials/details/EmailPreview.tsx
similarity index 98%
rename from apps/mobile-app/components/credentialDetails/EmailPreview.tsx
rename to apps/mobile-app/components/credentials/details/EmailPreview.tsx
index 50e528455..27543dc01 100644
--- a/apps/mobile-app/components/credentialDetails/EmailPreview.tsx
+++ b/apps/mobile-app/components/credentials/details/EmailPreview.tsx
@@ -10,8 +10,8 @@ import EncryptionUtility from '@/utils/EncryptionUtility';
import { useColors } from '@/hooks/useColorScheme';
import { AppInfo } from '@/utils/AppInfo';
import { PulseDot } from '@/components/PulseDot';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
type EmailPreviewProps = {
email: string | undefined;
diff --git a/apps/mobile-app/components/credentialDetails/LoginCredentials.tsx b/apps/mobile-app/components/credentials/details/LoginCredentials.tsx
similarity index 84%
rename from apps/mobile-app/components/credentialDetails/LoginCredentials.tsx
rename to apps/mobile-app/components/credentials/details/LoginCredentials.tsx
index a8eb00170..8c8b05d45 100644
--- a/apps/mobile-app/components/credentialDetails/LoginCredentials.tsx
+++ b/apps/mobile-app/components/credentials/details/LoginCredentials.tsx
@@ -1,7 +1,7 @@
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
import { Credential } from '@/utils/types/Credential';
-import FormInputCopyToClipboard from '@/components/FormInputCopyToClipboard';
+import FormInputCopyToClipboard from '@/components/form/FormInputCopyToClipboard';
type LoginCredentialsProps = {
credential: Credential;
diff --git a/apps/mobile-app/components/credentialDetails/NotesSection.tsx b/apps/mobile-app/components/credentials/details/NotesSection.tsx
similarity index 73%
rename from apps/mobile-app/components/credentialDetails/NotesSection.tsx
rename to apps/mobile-app/components/credentials/details/NotesSection.tsx
index c311197ee..669ea02b7 100644
--- a/apps/mobile-app/components/credentialDetails/NotesSection.tsx
+++ b/apps/mobile-app/components/credentials/details/NotesSection.tsx
@@ -1,8 +1,9 @@
-import { View, Text, useColorScheme, StyleSheet, Linking, Pressable } from 'react-native';
+import { View, Text, StyleSheet, Linking, Pressable } from 'react-native';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
import { Credential } from '@/utils/types/Credential';
+import { useColors } from '@/hooks/useColorScheme';
type NotesSectionProps = {
credential: Credential;
@@ -60,8 +61,7 @@ const splitTextAndUrls = (text: string): { type: 'text' | 'url', content: string
* Notes section component.
*/
export const NotesSection: React.FC<NotesSectionProps> = ({ credential }) : React.ReactNode => {
- const colorScheme = useColorScheme();
- const isDarkMode = colorScheme === 'dark';
+ const colors = useColors();
if (!credential.Notes) {
return null;
@@ -76,14 +76,35 @@ export const NotesSection: React.FC<NotesSectionProps> = ({ credential }) : Reac
Linking.openURL(url);
};
+ const styles = StyleSheet.create({
+ link: {
+ color: colors.primary,
+ fontSize: 14,
+ textDecorationLine: 'underline',
+ },
+ notes: {
+ color: colors.text,
+ fontSize: 14,
+ },
+ notesContainer: {
+ backgroundColor: colors.accentBackground,
+ borderColor: colors.accentBorder,
+ borderRadius: 8,
+ borderWidth: 1,
+ padding: 12,
+ },
+ section: {
+ gap: 8,
+ padding: 16,
+ paddingBottom: 8,
+ },
+ });
+
return (
<ThemedView style={styles.section}>
<ThemedText type="subtitle">Notes</ThemedText>
- <View style={[styles.notesContainer, {
- backgroundColor: isDarkMode ? '#1f2937' : '#f3f4f6',
- borderColor: isDarkMode ? '#374151' : '#d1d5db',
- }]}>
- <Text style={[styles.notes, { color: isDarkMode ? '#f3f4f6' : '#1f2937' }]}>
+ <View style={styles.notesContainer}>
+ <Text style={styles.notes}>
{parts.map((part, index) => {
if (part.type === 'url') {
return (
@@ -91,7 +112,7 @@ export const NotesSection: React.FC<NotesSectionProps> = ({ credential }) : Reac
key={index}
onPress={() => handleLinkPress(part.url!)}
>
- <Text style={[styles.link, { color: isDarkMode ? '#60a5fa' : '#2563eb' }]}>
+ <Text style={styles.link}>
{part.content}
</Text>
</Pressable>
@@ -107,24 +128,4 @@ export const NotesSection: React.FC<NotesSectionProps> = ({ credential }) : Reac
</View>
</ThemedView>
);
-};
-
-const styles = StyleSheet.create({
- link: {
- fontSize: 14,
- textDecorationLine: 'underline',
- },
- notes: {
- fontSize: 14,
- },
- notesContainer: {
- borderRadius: 8,
- borderWidth: 1,
- padding: 12,
- },
- section: {
- gap: 8,
- padding: 16,
- paddingBottom: 8,
- },
-});
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/apps/mobile-app/components/credentialDetails/TotpSection.tsx b/apps/mobile-app/components/credentials/details/TotpSection.tsx
similarity index 74%
rename from apps/mobile-app/components/credentialDetails/TotpSection.tsx
rename to apps/mobile-app/components/credentials/details/TotpSection.tsx
index 2a86819bb..de30e172e 100644
--- a/apps/mobile-app/components/credentialDetails/TotpSection.tsx
+++ b/apps/mobile-app/components/credentials/details/TotpSection.tsx
@@ -1,14 +1,15 @@
import React, { useState, useEffect } from 'react';
-import { View, StyleSheet, useColorScheme, TouchableOpacity } from 'react-native';
+import { View, StyleSheet, TouchableOpacity } from 'react-native';
import * as OTPAuth from 'otpauth';
import * as Clipboard from 'expo-clipboard';
import Toast from 'react-native-toast-message';
-import { ThemedText } from '@/components/ThemedText';
-import { ThemedView } from '@/components/ThemedView';
+import { ThemedText } from '@/components/themed/ThemedText';
+import { ThemedView } from '@/components/themed/ThemedView';
import { Credential } from '@/utils/types/Credential';
import { TotpCode } from '@/utils/types/TotpCode';
import { useDb } from '@/context/DbContext';
+import { useColors } from '@/hooks/useColorScheme';
type TotpSectionProps = {
credential: Credential;
@@ -20,8 +21,7 @@ type TotpSectionProps = {
export const TotpSection: React.FC<TotpSectionProps> = ({ credential }) : React.ReactNode => {
const [totpCodes, setTotpCodes] = useState<TotpCode[]>([]);
const [currentCodes, setCurrentCodes] = useState<Record<string, string>>({});
- const colorScheme = useColorScheme();
- const isDarkMode = colorScheme === 'dark';
+ const colors = useColors();
const dbContext = useDb();
/**
@@ -134,6 +134,53 @@ export const TotpSection: React.FC<TotpSectionProps> = ({ credential }) : React.
return null;
}
+ const styles = StyleSheet.create({
+ code: {
+ fontSize: 24,
+ fontWeight: 'bold',
+ letterSpacing: 2,
+ },
+ codeContainer: {
+ alignItems: 'center',
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ },
+ container: {
+ marginTop: 16,
+ padding: 16,
+ },
+ content: {
+ backgroundColor: colors.accentBackground,
+ borderColor: colors.accentBorder,
+ borderRadius: 8,
+ borderWidth: 1,
+ marginTop: 8,
+ padding: 12,
+ },
+ label: {
+ fontSize: 12,
+ marginBottom: 4,
+ },
+ progressBar: {
+ backgroundColor: colors.primary,
+ borderRadius: 2,
+ height: 4,
+ overflow: 'hidden',
+ width: 40,
+ },
+ progressFill: {
+ backgroundColor: colors.secondary,
+ height: '100%',
+ },
+ timer: {
+ fontSize: 12,
+ marginBottom: 4,
+ },
+ timerContainer: {
+ alignItems: 'flex-end',
+ },
+ });
+
return (
<ThemedView style={styles.container}>
<ThemedText type="subtitle">
@@ -142,26 +189,20 @@ export const TotpSection: React.FC<TotpSectionProps> = ({ credential }) : React.
{totpCodes.map(totpCode => (
<TouchableOpacity
key={totpCode.Id}
- style={[
- styles.content,
- {
- backgroundColor: isDarkMode ? '#1f2937' : '#f3f4f6',
- borderColor: isDarkMode ? '#374151' : '#d1d5db',
- }
- ]}
+ style={styles.content}
onPress={() => copyToClipboard(currentCodes[totpCode.Id])}
>
<View style={styles.codeContainer}>
<View>
- <ThemedText style={[styles.label, { color: isDarkMode ? '#9ca3af' : '#6b7280' }]}>
+ <ThemedText style={styles.label}>
TOTP Code
</ThemedText>
- <ThemedText style={[styles.code, { color: isDarkMode ? '#f3f4f6' : '#1f2937' }]}>
+ <ThemedText style={styles.code}>
{currentCodes[totpCode.Id]}
</ThemedText>
</View>
<View style={styles.timerContainer}>
- <ThemedText style={[styles.timer, { color: isDarkMode ? '#9ca3af' : '#6b7280' }]}>
+ <ThemedText style={styles.timer}>
{getRemainingSeconds()}s
</ThemedText>
<View style={styles.progressBar}>
@@ -179,48 +220,3 @@ export const TotpSection: React.FC<TotpSectionProps> = ({ credential }) : React.
</ThemedView>
);
};
-
-const styles = StyleSheet.create({
- code: {
- fontSize: 24,
- fontWeight: 'bold',
- letterSpacing: 2,
- },
- codeContainer: {
- alignItems: 'center',
- flexDirection: 'row',
- justifyContent: 'space-between',
- },
- container: {
- marginTop: 16,
- padding: 16,
- },
- content: {
- borderRadius: 8,
- borderWidth: 1,
- marginTop: 8,
- padding: 12,
- },
- label: {
- fontSize: 12,
- marginBottom: 4,
- },
- progressBar: {
- backgroundColor: 'rgba(0, 0, 0, 0.1)',
- borderRadius: 2,
- height: 4,
- overflow: 'hidden',
- width: 40,
- },
- progressFill: {
- backgroundColor: '#007AFF',
- height: '100%',
- },
- timer: {
- fontSize: 12,
- marginBottom: 4,
- },
- timerContainer: {
- alignItems: 'flex-end',
- },
-});
\ No newline at end of file
diff --git a/apps/mobile-app/components/FormInputCopyToClipboard.tsx b/apps/mobile-app/components/form/FormInputCopyToClipboard.tsx
similarity index 57%
rename from apps/mobile-app/components/FormInputCopyToClipboard.tsx
rename to apps/mobile-app/components/form/FormInputCopyToClipboard.tsx
index 7c041772e..8b3cd93bf 100644
--- a/apps/mobile-app/components/FormInputCopyToClipboard.tsx
+++ b/apps/mobile-app/components/form/FormInputCopyToClipboard.tsx
@@ -1,25 +1,32 @@
import React, { useState } from 'react';
-import { View, Text, TouchableOpacity, useColorScheme, StyleSheet } from 'react-native';
+import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
import * as Clipboard from 'expo-clipboard';
import Toast from 'react-native-toast-message';
import { MaterialIcons } from '@expo/vector-icons';
+
import { useColors } from '@/hooks/useColorScheme';
-interface FormInputCopyToClipboardProps {
+type FormInputCopyToClipboardProps = {
label: string;
value: string | undefined;
type?: 'text' | 'password';
}
+/**
+ * Form input copy to clipboard component.
+ */
const FormInputCopyToClipboard: React.FC<FormInputCopyToClipboardProps> = ({
label,
value,
type = 'text',
-}) => {
+}) : React.ReactNode => {
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
const colors = useColors();
- const copyToClipboard = async () => {
+ /**
+ * Copy the value to the clipboard.
+ */
+ const copyToClipboard = async () : Promise<void> => {
if (value) {
await Clipboard.setStringAsync(value);
Toast.show({
@@ -35,42 +42,38 @@ const FormInputCopyToClipboard: React.FC<FormInputCopyToClipboardProps> = ({
? '••••••••'
: value;
- const styles = StyleSheet.create({
- inputContainer: {
- borderRadius: 8,
- borderWidth: 1,
- padding: 12,
- marginBottom: 12,
- backgroundColor: colors.accentBackground,
- borderColor: colors.accentBorder,
- },
- inputContent: {
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
- },
- label: {
- fontSize: 12,
- marginBottom: 4,
- color: colors.textMuted,
- },
- value: {
- fontSize: 16,
- fontWeight: '500',
- color: colors.text,
- },
- actions: {
- flexDirection: 'row',
- alignItems: 'center',
- },
- iconButton: {
- padding: 8,
- },
- iconText: {
- fontSize: 20,
- },
- });
-
+ const styles = StyleSheet.create({
+ actions: {
+ alignItems: 'center',
+ flexDirection: 'row',
+ },
+ iconButton: {
+ padding: 8,
+ },
+ inputContainer: {
+ backgroundColor: colors.accentBackground,
+ borderColor: colors.accentBorder,
+ borderRadius: 8,
+ borderWidth: 1,
+ marginBottom: 12,
+ padding: 12,
+ },
+ inputContent: {
+ alignItems: 'center',
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ },
+ label: {
+ color: colors.textMuted,
+ fontSize: 12,
+ marginBottom: 4,
+ },
+ value: {
+ color: colors.text,
+ fontSize: 16,
+ fontWeight: '500',
+ },
+ });
return (
<TouchableOpacity
@@ -93,10 +96,10 @@ const FormInputCopyToClipboard: React.FC<FormInputCopyToClipboardProps> = ({
style={styles.iconButton}
>
<MaterialIcons
- name={isPasswordVisible ? "visibility-off" : "visibility"}
- size={20}
- color={colors.primary}
- />
+ name={isPasswordVisible ? "visibility-off" : "visibility"}
+ size={20}
+ color={colors.primary}
+ />
</TouchableOpacity>
)}
</View>
diff --git a/apps/mobile-app/components/ValidatedFormField.tsx b/apps/mobile-app/components/form/ValidatedFormField.tsx
similarity index 61%
rename from apps/mobile-app/components/ValidatedFormField.tsx
rename to apps/mobile-app/components/form/ValidatedFormField.tsx
index 32d28195a..81b273430 100644
--- a/apps/mobile-app/components/ValidatedFormField.tsx
+++ b/apps/mobile-app/components/form/ValidatedFormField.tsx
@@ -1,21 +1,22 @@
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
-import { View, TextInput, TextInputProps, StyleSheet, TouchableOpacity, TouchableHighlight } from 'react-native';
-import { ThemedText } from './ThemedText';
+import { View, TextInput, TextInputProps, StyleSheet, TouchableHighlight } from 'react-native';
import { Controller, Control, FieldValues, Path } from 'react-hook-form';
-import { useColors } from '@/hooks/useColorScheme';
import { MaterialIcons } from '@expo/vector-icons';
-interface FormFieldButton {
+import { ThemedText } from '@/components/themed/ThemedText';
+import { useColors } from '@/hooks/useColorScheme';
+
+type FormFieldButton = {
icon: string;
onPress: () => void;
}
-export interface ValidatedFormFieldRef {
+type ValidatedFormFieldRef = {
focus: () => void;
selectAll: () => void;
}
-interface ValidatedFormFieldProps<T extends FieldValues> extends Omit<TextInputProps, 'value' | 'onChangeText'> {
+type ValidatedFormFieldProps<T extends FieldValues> = Omit<TextInputProps, 'value' | 'onChangeText'> & {
label: string;
name: Path<T>;
control: Control<T>;
@@ -23,6 +24,9 @@ interface ValidatedFormFieldProps<T extends FieldValues> extends Omit<TextInputP
buttons?: FormFieldButton[];
}
+/**
+ * Validated form field component.
+ */
export const ValidatedFormField = forwardRef<ValidatedFormFieldRef, ValidatedFormFieldProps<any>>(({
label,
name,
@@ -36,58 +40,64 @@ export const ValidatedFormField = forwardRef<ValidatedFormFieldRef, ValidatedFor
const currentValue = useRef<string>('');
useImperativeHandle(ref, () => ({
- focus: () => {
+ /**
+ * Focus the input.
+ */
+ focus: (): void => {
console.log(inputRef.current);
inputRef.current?.focus();
},
- selectAll: () => {
+ /**
+ * Select all the text in the input.
+ */
+ selectAll: (): void => {
inputRef.current?.setSelection(0, currentValue.current.length);
}
}));
const styles = StyleSheet.create({
+ button: {
+ borderLeftColor: colors.accentBorder,
+ borderLeftWidth: 1,
+ padding: 10,
+ },
container: {
marginBottom: 16,
},
- inputGroup: {
- marginBottom: 6,
- },
- inputLabel: {
+ errorText: {
+ color: 'red',
fontSize: 12,
- marginBottom: 4,
- color: colors.textMuted,
+ marginTop: 4,
+ },
+ input: {
+ color: colors.text,
+ flex: 1,
+ fontSize: 16,
+ padding: 10,
},
inputContainer: {
- flexDirection: 'row',
alignItems: 'center',
- borderWidth: 1,
+ backgroundColor: colors.background,
borderColor: colors.accentBorder,
borderRadius: 4,
- backgroundColor: colors.background,
- },
- input: {
- flex: 1,
- padding: 10,
- fontSize: 16,
- color: colors.text,
+ borderWidth: 1,
+ flexDirection: 'row',
},
inputError: {
borderColor: 'red',
},
- errorText: {
- color: 'red',
+ inputGroup: {
+ marginBottom: 6,
+ },
+ inputLabel: {
+ color: colors.textMuted,
fontSize: 12,
- marginTop: 4,
+ marginBottom: 4,
},
requiredIndicator: {
color: 'red',
marginLeft: 4,
},
- button: {
- padding: 10,
- borderLeftWidth: 1,
- borderLeftColor: colors.accentBorder,
- },
});
return (
@@ -100,31 +110,32 @@ export const ValidatedFormField = forwardRef<ValidatedFormFieldRef, ValidatedFor
<View style={styles.inputGroup}>
<ThemedText style={styles.inputLabel}>{label} {required && <ThemedText style={styles.requiredIndicator}>*</ThemedText>}</ThemedText>
<View style={[styles.inputContainer, error ? styles.inputError : null]}>
- <TextInput
- ref={inputRef}
- style={styles.input}
- value={value as string}
- placeholderTextColor={colors.textMuted}
- onChangeText={onChange}
- autoCapitalize="none"
- autoComplete="off"
- autoCorrect={false}
- {...props}
- />
- {buttons?.map((button, index) => (
- <TouchableHighlight
- key={index}
- style={styles.button}
- onPress={button.onPress}
- underlayColor={colors.accentBackground}
- >
- <MaterialIcons name={button.icon as any} size={20} color={colors.primary} />
- </TouchableHighlight>
- ))}
+ <TextInput
+ ref={inputRef}
+ style={styles.input}
+ value={value as string}
+ placeholderTextColor={colors.textMuted}
+ onChangeText={onChange}
+ autoCapitalize="none"
+ autoComplete="off"
+ autoCorrect={false}
+ {...props}
+ />
+ {buttons?.map((button, index) => (
+ <TouchableHighlight
+ key={index}
+ style={styles.button}
+ onPress={button.onPress}
+ underlayColor={colors.accentBackground}
+ >
+ <MaterialIcons name={button.icon as any} size={20} color={colors.primary} />
+ </TouchableHighlight>
+ ))}
+ </View>
+ {error && <ThemedText style={styles.errorText}>{error.message}</ThemedText>}
</View>
- {error && <ThemedText style={styles.errorText}>{error.message}</ThemedText>}
- </View>
- )}}
+ )
+ }}
/>
);
});
\ No newline at end of file
diff --git a/apps/mobile-app/components/ThemedSafeAreaView.tsx b/apps/mobile-app/components/themed/ThemedSafeAreaView.tsx
similarity index 72%
rename from apps/mobile-app/components/ThemedSafeAreaView.tsx
rename to apps/mobile-app/components/themed/ThemedSafeAreaView.tsx
index 26accd91d..751b15617 100644
--- a/apps/mobile-app/components/ThemedSafeAreaView.tsx
+++ b/apps/mobile-app/components/themed/ThemedSafeAreaView.tsx
@@ -1,20 +1,24 @@
-import { SafeAreaView, StyleSheet } from 'react-native';
+import { SafeAreaView, StyleProp, ViewStyle } from 'react-native';
+
import { useThemeColor } from '@/hooks/useThemeColor';
type ThemedSafeAreaViewProps = {
lightColor?: string;
darkColor?: string;
- style?: any;
+ style?: StyleProp<ViewStyle>;
children?: React.ReactNode;
};
+/**
+ * Themed safe area view component.
+ */
export function ThemedSafeAreaView({
lightColor,
darkColor,
style,
children,
...otherProps
-}: ThemedSafeAreaViewProps) {
+}: ThemedSafeAreaViewProps): React.ReactNode {
const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor }, 'background');
return (
@@ -25,4 +29,4 @@ export function ThemedSafeAreaView({
{children}
</SafeAreaView>
);
-}
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/apps/mobile-app/components/themed/ThemedScrollView.tsx b/apps/mobile-app/components/themed/ThemedScrollView.tsx
new file mode 100644
index 000000000..552f19f54
--- /dev/null
+++ b/apps/mobile-app/components/themed/ThemedScrollView.tsx
@@ -0,0 +1,27 @@
+import { ScrollView, StyleProp, StyleSheet, ViewStyle } from 'react-native';
+
+type ThemedScrollViewProps = {
+ style?: StyleProp<ViewStyle>;
+ lightColor?: string;
+ darkColor?: string;
+ children?: React.ReactNode;
+};
+
+/**
+ * Themed scroll view component.
+ */
+export function ThemedScrollView({ style, lightColor, darkColor, ...otherProps }: ThemedScrollViewProps): React.ReactNode {
+ return (
+ <ScrollView
+ style={[styles.container, style]}
+ {...otherProps}
+ />
+ );
+}
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ marginBottom: 80,
+ },
+});
diff --git a/apps/mobile-app/components/ThemedText.tsx b/apps/mobile-app/components/themed/ThemedText.tsx
similarity index 52%
rename from apps/mobile-app/components/ThemedText.tsx
rename to apps/mobile-app/components/themed/ThemedText.tsx
index c0e1a78f5..071b33740 100644
--- a/apps/mobile-app/components/ThemedText.tsx
+++ b/apps/mobile-app/components/themed/ThemedText.tsx
@@ -1,26 +1,54 @@
import { Text, type TextProps, StyleSheet } from 'react-native';
-import { useThemeColor } from '@/hooks/useThemeColor';
-
+import { useColors } from '@/hooks/useColorScheme';
export type ThemedTextProps = TextProps & {
lightColor?: string;
darkColor?: string;
type?: 'default' | 'title' | 'defaultSemiBold' | 'subtitle' | 'link';
};
+/**
+ * Themed text component.
+ */
export function ThemedText({
style,
lightColor,
darkColor,
type = 'default',
...rest
-}: ThemedTextProps) {
- const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text');
+}: ThemedTextProps): React.ReactNode {
+ const colors = useColors();
+
+ const styles = StyleSheet.create({
+ default: {
+ fontSize: 16,
+ lineHeight: 24,
+ },
+ defaultSemiBold: {
+ fontSize: 16,
+ fontWeight: '600',
+ lineHeight: 24,
+ },
+ link: {
+ color: colors.primary,
+ fontSize: 16,
+ lineHeight: 30,
+ },
+ subtitle: {
+ fontSize: 20,
+ fontWeight: 'bold',
+ },
+ title: {
+ fontSize: 32,
+ fontWeight: 'bold',
+ lineHeight: 32,
+ },
+ });
return (
<Text
style={[
- { color },
+ { color: colors.text },
type === 'default' ? styles.default : undefined,
type === 'title' ? styles.title : undefined,
type === 'defaultSemiBold' ? styles.defaultSemiBold : undefined,
@@ -31,30 +59,4 @@ export function ThemedText({
{...rest}
/>
);
-}
-
-const styles = StyleSheet.create({
- default: {
- fontSize: 16,
- lineHeight: 24,
- },
- defaultSemiBold: {
- fontSize: 16,
- lineHeight: 24,
- fontWeight: '600',
- },
- title: {
- fontSize: 32,
- fontWeight: 'bold',
- lineHeight: 32,
- },
- subtitle: {
- fontSize: 20,
- fontWeight: 'bold',
- },
- link: {
- lineHeight: 30,
- fontSize: 16,
- color: '#0a7ea4',
- },
-});
+}
\ No newline at end of file
diff --git a/apps/mobile-app/components/ThemedView.tsx b/apps/mobile-app/components/themed/ThemedView.tsx
similarity index 84%
rename from apps/mobile-app/components/ThemedView.tsx
rename to apps/mobile-app/components/themed/ThemedView.tsx
index 4d2cb09d4..75911fb93 100644
--- a/apps/mobile-app/components/ThemedView.tsx
+++ b/apps/mobile-app/components/themed/ThemedView.tsx
@@ -7,7 +7,10 @@ export type ThemedViewProps = ViewProps & {
darkColor?: string;
};
-export function ThemedView({ style, lightColor, darkColor, ...otherProps }: ThemedViewProps) {
+/**
+ * Themed view component.
+ */
+export function ThemedView({ style, lightColor, darkColor, ...otherProps }: ThemedViewProps): React.ReactNode {
const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor }, 'background');
return <View style={[{ backgroundColor }, style]} {...otherProps} />;
diff --git a/apps/mobile-app/components/CollapsibleHeader.tsx b/apps/mobile-app/components/ui/CollapsibleHeader.tsx
similarity index 88%
rename from apps/mobile-app/components/CollapsibleHeader.tsx
rename to apps/mobile-app/components/ui/CollapsibleHeader.tsx
index ae8d2a7a3..ca869d165 100644
--- a/apps/mobile-app/components/CollapsibleHeader.tsx
+++ b/apps/mobile-app/components/ui/CollapsibleHeader.tsx
@@ -1,17 +1,18 @@
import React from 'react';
import { StyleSheet, Platform, Animated, TouchableOpacity } from 'react-native';
-import { Stack, useRouter } from 'expo-router';
-import { useColors } from '@/hooks/useColorScheme';
-import { ThemedText } from './ThemedText';
+import { Stack } from 'expo-router';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
-interface HeaderButton {
+import { ThemedText } from '@/components/themed/ThemedText';
+import { useColors } from '@/hooks/useColorScheme';
+
+type HeaderButton = {
icon: keyof typeof MaterialIcons.glyphMap;
onPress: () => void;
position: 'left' | 'right';
}
-interface CollapsibleHeaderProps {
+type CollapsibleHeaderProps = {
title: string;
scrollY: Animated.Value;
showNavigationHeader?: boolean;
@@ -19,13 +20,16 @@ interface CollapsibleHeaderProps {
headerButtons?: HeaderButton[];
}
+/**
+ * Collapsible header component.
+ */
export function CollapsibleHeader({
title,
scrollY,
showNavigationHeader = false,
alwaysVisible = false,
headerButtons = []
-}: CollapsibleHeaderProps) {
+}: CollapsibleHeaderProps) : React.ReactNode {
const colors = useColors();
// Calculate header opacity based on scroll position and transform
@@ -54,32 +58,43 @@ export function CollapsibleHeader({
const styles = StyleSheet.create({
floatingHeader: {
- position: 'absolute',
- top: 0,
- left: 0,
- right: 0,
- height: Platform.OS === 'ios' ? 100 : 64,
- flexDirection: 'row',
alignItems: 'flex-end',
+ flexDirection: 'row',
+ height: Platform.OS === 'ios' ? 100 : 64,
justifyContent: 'center',
+ left: 0,
paddingBottom: Platform.OS === 'ios' ? 12 : 16,
- zIndex: 100,
paddingTop: Platform.OS === 'ios' ? 60 : 0,
+ position: 'absolute',
+ right: 0,
+ top: 0,
+ zIndex: 100,
},
floatingTitle: {
- fontSize: Platform.OS === 'ios' ? 20 : 17,
- fontWeight: '600',
color: colors.text,
flex: 1,
- textAlign: 'center',
+ fontSize: Platform.OS === 'ios' ? 20 : 17,
+ fontWeight: '600',
marginHorizontal: 50,
marginTop: 5,
+ textAlign: 'center',
},
- headerButton: {
+ floatingTitleContainer: {
+ flex: 1,
+ },
+ headerBorder: {
+ backgroundColor: colors.accentBorder,
+ bottom: 0,
+ height: 1,
+ left: 0,
position: 'absolute',
+ right: 0,
+ },
+ headerButton: {
bottom: Platform.OS === 'ios' ? 6 : 16,
color: colors.primary,
padding: 4,
+ position: 'absolute',
},
leftButton: {
left: 16,
@@ -87,14 +102,6 @@ export function CollapsibleHeader({
rightButton: {
right: 16,
},
- headerBorder: {
- position: 'absolute',
- bottom: 0,
- left: 0,
- right: 0,
- height: 1,
- backgroundColor: colors.accentBorder,
- },
});
return (
@@ -117,7 +124,10 @@ export function CollapsibleHeader({
}
]}
>
- <Animated.View style={{ flex: 1, opacity: alwaysVisible ? titleOpacity : headerOpacity }}>
+ <Animated.View style={[
+ styles.floatingTitleContainer,
+ { opacity: alwaysVisible ? titleOpacity : headerOpacity },
+ ]}>
<ThemedText style={styles.floatingTitle}>{title}</ThemedText>
</Animated.View>
diff --git a/apps/mobile-app/components/ui/IconSymbol.ios.tsx b/apps/mobile-app/components/ui/IconSymbol.ios.tsx
index 9177f4daf..555085d9d 100644
--- a/apps/mobile-app/components/ui/IconSymbol.ios.tsx
+++ b/apps/mobile-app/components/ui/IconSymbol.ios.tsx
@@ -1,6 +1,9 @@
import { SymbolView, SymbolViewProps, SymbolWeight } from 'expo-symbols';
import { StyleProp, ViewStyle } from 'react-native';
+/**
+ * Icon symbol component.
+ */
export function IconSymbol({
name,
size = 24,
@@ -13,7 +16,7 @@ export function IconSymbol({
color: string;
style?: StyleProp<ViewStyle>;
weight?: SymbolWeight;
-}) {
+}): React.ReactNode {
return (
<SymbolView
weight={weight}
diff --git a/apps/mobile-app/components/ui/IconSymbol.tsx b/apps/mobile-app/components/ui/IconSymbol.tsx
index f1fabd4a1..920b55b1e 100644
--- a/apps/mobile-app/components/ui/IconSymbol.tsx
+++ b/apps/mobile-app/components/ui/IconSymbol.tsx
@@ -1,14 +1,15 @@
// This file is a fallback for using MaterialIcons on Android and web.
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
-import { SymbolWeight } from 'expo-symbols';
import React from 'react';
import { OpaqueColorValue, StyleProp, ViewStyle } from 'react-native';
// Add your SFSymbol to MaterialIcons mappings here.
const MAPPING = {
- // See MaterialIcons here: https://icons.expo.fyi
- // See SF Symbols in the SF Symbols app on Mac.
+ /*
+ * See MaterialIcons here: https://icons.expo.fyi
+ * See SF Symbols in the SF Symbols app on Mac.
+ */
'house.fill': 'home',
'paperplane.fill': 'send',
'chevron.left.forwardslash.chevron.right': 'code',
@@ -37,7 +38,6 @@ export function IconSymbol({
size?: number;
color: string | OpaqueColorValue;
style?: StyleProp<ViewStyle>;
- weight?: SymbolWeight;
-}) {
+}): React.ReactNode {
return <MaterialIcons color={color} size={size} name={MAPPING[name]} style={style} />;
}
diff --git a/apps/mobile-app/components/ui/TabBarBackground.ios.tsx b/apps/mobile-app/components/ui/TabBarBackground.ios.tsx
index 6668e78d2..460724a5e 100644
--- a/apps/mobile-app/components/ui/TabBarBackground.ios.tsx
+++ b/apps/mobile-app/components/ui/TabBarBackground.ios.tsx
@@ -3,11 +3,16 @@ import { BlurView } from 'expo-blur';
import { StyleSheet } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
-export default function BlurTabBarBackground() {
+/**
+ * Blur tab bar background component.
+ */
+export default function BlurTabBarBackground(): React.ReactNode {
return (
<BlurView
- // System chrome material automatically adapts to the system's theme
- // and matches the native tab bar appearance on iOS.
+ /*
+ * System chrome material automatically adapts to the system's theme
+ * and matches the native tab bar appearance on iOS.
+ */
tint="systemChromeMaterial"
intensity={100}
style={StyleSheet.absoluteFill}
@@ -15,7 +20,10 @@ export default function BlurTabBarBackground() {
);
}
-export function useBottomTabOverflow() {
+/**
+ * Use bottom tab overflow.
+ */
+export function useBottomTabOverflow(): number {
const tabHeight = useBottomTabBarHeight();
const { bottom } = useSafeAreaInsets();
return tabHeight - bottom;
diff --git a/apps/mobile-app/components/ui/TabBarBackground.tsx b/apps/mobile-app/components/ui/TabBarBackground.tsx
index 70d1c3c0b..b63337c1b 100644
--- a/apps/mobile-app/components/ui/TabBarBackground.tsx
+++ b/apps/mobile-app/components/ui/TabBarBackground.tsx
@@ -1,6 +1,9 @@
// This is a shim for web and Android where the tab bar is generally opaque.
export default undefined;
-export function useBottomTabOverflow() {
+/**
+ * Use bottom tab overflow.
+ */
+export function useBottomTabOverflow(): number {
return 0;
}
diff --git a/apps/mobile-app/components/TitleContainer.tsx b/apps/mobile-app/components/ui/TitleContainer.tsx
similarity index 77%
rename from apps/mobile-app/components/TitleContainer.tsx
rename to apps/mobile-app/components/ui/TitleContainer.tsx
index 872eb8dce..7e3dbd614 100644
--- a/apps/mobile-app/components/TitleContainer.tsx
+++ b/apps/mobile-app/components/ui/TitleContainer.tsx
@@ -1,13 +1,17 @@
import { StyleSheet, View } from 'react-native';
-import { ThemedText } from './ThemedText';
+
+import { ThemedText } from '@/components/themed/ThemedText';
import Logo from '@/assets/images/logo.svg';
-interface TitleContainerProps {
+type TitleContainerProps = {
title: string;
showLogo?: boolean;
-}
+};
-export function TitleContainer({ title, showLogo = true }: TitleContainerProps) {
+/**
+ * Title container component.
+ */
+export function TitleContainer({ title, showLogo = true }: TitleContainerProps): React.ReactNode {
return (
<View style={styles.titleContainer}>
{showLogo && <Logo width={40} height={40} style={styles.logo} />}
@@ -17,13 +21,13 @@ export function TitleContainer({ title, showLogo = true }: TitleContainerProps)
}
const styles = StyleSheet.create({
+ logo: {
+ marginBottom: 6,
+ },
titleContainer: {
- flexDirection: 'row',
alignItems: 'center',
+ flexDirection: 'row',
gap: 8,
marginBottom: 16,
},
- logo: {
- marginBottom: 6,
- },
});
diff --git a/apps/mobile-app/constants/Colors.ts b/apps/mobile-app/constants/Colors.ts
index 2d9ef176d..b0ea11e74 100644
--- a/apps/mobile-app/constants/Colors.ts
+++ b/apps/mobile-app/constants/Colors.ts
@@ -24,6 +24,7 @@ export const Colors = {
secondary: '#6b7280',
tertiary: '#eabf69',
loginHeader: '#f6dfc4',
+ greenBackground: '#22c55e',
},
dark: {
white: '#ffffff',
@@ -46,6 +47,7 @@ export const Colors = {
secondary: '#6b7280',
tertiary: '#eabf69',
loginHeader: '#5c4331',
+ greenBackground: '#22c55e',
},
} as const;