Skip to content

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

Add collapsible header component (#771)

Leendert de Borst91b223bac905
diff --git a/mobile-app/app/(tabs)/(credentials)/index.tsx b/mobile-app/app/(tabs)/(credentials)/index.tsx
index e09aced41..06159ec42 100644
--- a/mobile-app/app/(tabs)/(credentials)/index.tsx
+++ b/mobile-app/app/(tabs)/(credentials)/index.tsx
@@ -1,6 +1,5 @@
-import { StyleSheet, Text, FlatList, ActivityIndicator, TouchableOpacity, TextInput, Keyboard, RefreshControl, Platform } from 'react-native';
+import { StyleSheet, Text, FlatList, ActivityIndicator, TouchableOpacity, TextInput, Keyboard, RefreshControl, Platform, Animated } from 'react-native';
import { useState, useEffect, useCallback, useRef } from 'react';
-import { router, Stack } from 'expo-router';
import { useNavigation } from '@react-navigation/native';
import { ThemedText } from '@/components/ThemedText';
import { ThemedView } from '@/components/ThemedView';
@@ -12,6 +11,7 @@ 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 emitter from '@/utils/EventEmitter';
import Toast from 'react-native-toast-message';
@@ -21,6 +21,7 @@ export default function CredentialsScreen() {
const { syncVault } = useVaultSync();
const colors = useColors();
const flatListRef = useRef<FlatList>(null);
+ const scrollY = useRef(new Animated.Value(0)).current;
const navigation = useNavigation();
const [isTabFocused, setIsTabFocused] = useState(false);
@@ -59,11 +60,6 @@ export default function CredentialsScreen() {
const isAuthenticated = authContext.isLoggedIn;
const isDatabaseAvailable = dbContext.dbAvailable;
- const navigateToCredential = (credentialId: string) => {
- console.log('Navigating to credential:', credentialId);
- router.push(`/(tabs)/(credentials)/${credentialId}`);
- };
-
const loadCredentials = async () => {
try {
const credentials = await dbContext.sqliteClient!.getAllCredentials();
@@ -189,17 +185,27 @@ export default function CredentialsScreen() {
return (
<ThemedSafeAreaView style={styles.container}>
- <Stack.Screen options={{ title: "Credentials" }} />
+ <CollapsibleHeader
+ title="Credentials"
+ scrollY={scrollY}
+ showNavigationHeader={true}
+ />
+
<ThemedView style={styles.content}>
<ThemedView style={styles.stepContainer}>
{isLoadingCredentials ? (
<ActivityIndicator size="large" color={colors.primary} />
) : (
- <FlatList
+ <Animated.FlatList
ref={flatListRef}
data={filteredCredentials}
keyExtractor={(item) => item.Id}
keyboardShouldPersistTaps='handled'
+ onScroll={Animated.event(
+ [{ nativeEvent: { contentOffset: { y: scrollY } } }],
+ { useNativeDriver: true }
+ )}
+ scrollEventThrottle={16}
ListHeaderComponent={
<ThemedView>
<TitleContainer title="Credentials" />
diff --git a/mobile-app/app/(tabs)/(emails)/index.tsx b/mobile-app/app/(tabs)/(emails)/index.tsx
index ac4179697..d70f1a024 100644
--- a/mobile-app/app/(tabs)/(emails)/index.tsx
+++ b/mobile-app/app/(tabs)/(emails)/index.tsx
@@ -1,11 +1,12 @@
import React, { useEffect, useState, useCallback, useRef } from 'react';
-import { StyleSheet, View, ActivityIndicator, ScrollView, RefreshControl } from 'react-native';
+import { StyleSheet, View, ActivityIndicator, ScrollView, RefreshControl, Animated } from 'react-native';
import { Stack, 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 { MailboxBulkRequest, MailboxBulkResponse } from '@/utils/types/webapi/MailboxBulk';
import EncryptionUtility from '@/utils/EncryptionUtility';
import { useColors } from '@/hooks/useColorScheme';
@@ -43,6 +44,7 @@ export default function EmailsScreen() {
const webApi = useWebApi();
const colors = useColors();
const navigation = useNavigation();
+ const scrollY = useRef(new Animated.Value(0)).current;
const scrollViewRef = useRef<ScrollView>(null);
const [error, setError] = useState<string | null>(null);
const [emails, setEmails] = useState<MailboxEmail[]>([]);
@@ -198,10 +200,19 @@ export default function EmailsScreen() {
return (
<ThemedSafeAreaView style={styles.container}>
- <Stack.Screen options={{ title: "Emails" }} />
+ <CollapsibleHeader
+ title="Emails"
+ scrollY={scrollY}
+ showNavigationHeader={true}
+ />
<ThemedView style={styles.content}>
- <ScrollView
+ <Animated.ScrollView
ref={scrollViewRef}
+ onScroll={Animated.event(
+ [{ nativeEvent: { contentOffset: { y: scrollY } } }],
+ { useNativeDriver: true }
+ )}
+ scrollEventThrottle={16}
refreshControl={
<RefreshControl
refreshing={isRefreshing}
@@ -213,7 +224,7 @@ export default function EmailsScreen() {
>
<TitleContainer title="Emails" />
{renderContent()}
- </ScrollView>
+ </Animated.ScrollView>
</ThemedView>
</ThemedSafeAreaView>
);
diff --git a/mobile-app/components/CollapsibleHeader.tsx b/mobile-app/components/CollapsibleHeader.tsx
new file mode 100644
index 000000000..0d864bbfb
--- /dev/null
+++ b/mobile-app/components/CollapsibleHeader.tsx
@@ -0,0 +1,72 @@
+import React from 'react';
+import { StyleSheet, Platform, Animated } from 'react-native';
+import { Stack } from 'expo-router';
+import { useColors } from '@/hooks/useColorScheme';
+import { ThemedText } from './ThemedText';
+
+interface CollapsibleHeaderProps {
+ title: string;
+ scrollY: Animated.Value;
+ showNavigationHeader?: boolean;
+}
+
+export function CollapsibleHeader({ title, scrollY, showNavigationHeader = false }: CollapsibleHeaderProps) {
+ const colors = useColors();
+
+ // Calculate header opacity based on scroll position
+ const headerOpacity = scrollY.interpolate({
+ inputRange: [10, 60],
+ outputRange: [0, 1],
+ extrapolate: 'clamp',
+ });
+
+ const styles = StyleSheet.create({
+ floatingHeader: {
+ position: 'absolute',
+ top: 0,
+ left: 0,
+ right: 0,
+ height: Platform.OS === 'ios' ? 96 : 64,
+ backgroundColor: colors.accentBackground,
+ alignItems: 'center',
+ justifyContent: 'flex-end',
+ paddingBottom: 12,
+ borderBottomWidth: 1,
+ borderBottomColor: colors.accentBorder,
+ zIndex: 100,
+ },
+ floatingTitle: {
+ fontSize: 17,
+ fontWeight: '600',
+ color: colors.text,
+ },
+ });
+
+ return (
+ <>
+ {showNavigationHeader ? (
+ <Stack.Screen options={{
+ title: title,
+ headerShown: false,
+ }} />
+ ) : null}
+
+ <Animated.View
+ style={[
+ styles.floatingHeader,
+ {
+ opacity: headerOpacity,
+ transform: [{
+ translateY: headerOpacity.interpolate({
+ inputRange: [0, 1],
+ outputRange: [-20, 0],
+ })
+ }]
+ }
+ ]}
+ >
+ <ThemedText style={styles.floatingTitle}>{title}</ThemedText>
+ </Animated.View>
+ </>
+ );
+}
\ No newline at end of file