Skip to content

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

Add generic modal backdrop to mobile app UI (#2413)

Leendert de Borst7fb21fb820c9
diff --git a/apps/mobile-app/components/common/ModalBackdrop.tsx b/apps/mobile-app/components/common/ModalBackdrop.tsx
new file mode 100644
index 000000000..2a3d05b11
--- /dev/null
+++ b/apps/mobile-app/components/common/ModalBackdrop.tsx
@@ -0,0 +1,25 @@
+import { BlurView } from 'expo-blur';
+import React from 'react';
+import { Platform, StyleSheet, View } from 'react-native';
+
+import { useColors, useColorScheme } from '@/hooks/useColorScheme';
+
+/**
+ * Tinted, blurred backdrop shared by every modal. Render it as the first child of the full-screen overlay.
+ * The blur is iOS only: Android blur needs a blur target and is too costly for a modal backdrop.
+ */
+export const ModalBackdrop: React.FC = () => {
+ const colors = useColors();
+ const colorScheme = useColorScheme();
+
+ return (
+ <View style={StyleSheet.absoluteFill} pointerEvents="none">
+ {Platform.OS === 'ios' && (
+ <BlurView intensity={20} tint={colorScheme === 'dark' ? 'dark' : 'light'} style={StyleSheet.absoluteFill} />
+ )}
+ <View style={[StyleSheet.absoluteFill, { backgroundColor: colors.modalBackground }]} />
+ </View>
+ );
+};
+
+export default ModalBackdrop;
diff --git a/apps/mobile-app/components/common/ModalWrapper.tsx b/apps/mobile-app/components/common/ModalWrapper.tsx
index d58c8226d..f43217ac4 100644
--- a/apps/mobile-app/components/common/ModalWrapper.tsx
+++ b/apps/mobile-app/components/common/ModalWrapper.tsx
@@ -12,44 +12,29 @@ import {
StatusBar,
} from 'react-native';
+import { ModalBackdrop } from '@/components/common/ModalBackdrop';
import { useColors } from '@/hooks/useColorScheme';
interface IModalWrapperProps {
- /** Whether the modal is visible. */
isOpen: boolean;
- /** Callback when the modal is requested to close. */
onClose: () => void;
- /** Whether closing is disabled (e.g., during submission). */
isSubmitting?: boolean;
- /** Optional modal title. */
title?: string;
- /** Modal body content. */
children: React.ReactNode;
- /** Optional footer content (e.g., buttons). */
footer?: React.ReactNode;
- /** Whether to enable keyboard avoiding behavior. Default: false. */
keyboardAvoiding?: boolean;
- /** Whether the content should be scrollable. Default: false. */
scrollable?: boolean;
- /** Maximum height for scrollable content. Default: 400. */
maxScrollHeight?: number;
- /** Animation type for the modal. Default: 'fade'. */
animationType?: 'fade' | 'slide' | 'none';
- /** Custom max width for the container. Default: 400. */
maxWidth?: number;
- /** Custom width percentage. Default: '90%'. */
width?: string;
- /** Whether to show header border. Default: true (only when title is provided). */
showHeaderBorder?: boolean;
- /** Whether to show footer border. Default: true (only when footer is provided). */
showFooterBorder?: boolean;
- /** Whether tapping the backdrop (outside the content) closes the modal. Default: false. */
closeOnBackdropPress?: boolean;
}
/**
* A generic modal wrapper component that provides consistent behavior:
- * - Themed backdrop (dark/light mode support)
* - Consistent container styling
* - Optional title with header
* - Optional scrollable content
@@ -87,8 +72,6 @@ export const ModalWrapper: React.FC<IModalWrapperProps> = ({
const styles = StyleSheet.create({
backdrop: {
alignItems: 'center',
- // Lighter backdrop in dark mode for better contrast against black background
- backgroundColor: 'rgba(0, 0, 0, 0.65)',
flex: 1,
justifyContent: 'center',
},
@@ -209,6 +192,7 @@ export const ModalWrapper: React.FC<IModalWrapperProps> = ({
barStyle="light-content"
/>
)}
+ <ModalBackdrop />
{renderBackdrop()}
</Modal>
);
diff --git a/apps/mobile-app/components/form/AddFieldMenu.tsx b/apps/mobile-app/components/form/AddFieldMenu.tsx
index fa85208e0..8bebad99a 100644
--- a/apps/mobile-app/components/form/AddFieldMenu.tsx
+++ b/apps/mobile-app/components/form/AddFieldMenu.tsx
@@ -14,6 +14,7 @@ import { FieldCategories } from '@aliasvault/models/vault';
import { useColors } from '@/hooks/useColorScheme';
+import { ModalBackdrop } from '@/components/common/ModalBackdrop';
import { ThemedText } from '@/components/themed/ThemedText';
import { RobustPressable } from '@/components/ui/RobustPressable';
@@ -159,7 +160,6 @@ export const AddFieldMenu: React.FC<AddFieldMenuProps> = ({
fontWeight: '500',
},
modalOverlay: {
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
flex: 1,
justifyContent: 'flex-end',
paddingBottom: 40,
@@ -243,6 +243,7 @@ export const AddFieldMenu: React.FC<AddFieldMenuProps> = ({
animationType="slide"
onRequestClose={() => setIsOpen(false)}
>
+ <ModalBackdrop />
<TouchableWithoutFeedback onPress={() => setIsOpen(false)}>
<View style={styles.modalOverlay}>
<TouchableWithoutFeedback>
diff --git a/apps/mobile-app/components/form/EmailDomainField.tsx b/apps/mobile-app/components/form/EmailDomainField.tsx
index 5beecd9b6..c0311ee7e 100644
--- a/apps/mobile-app/components/form/EmailDomainField.tsx
+++ b/apps/mobile-app/components/form/EmailDomainField.tsx
@@ -5,6 +5,7 @@ import { View, Text, TextInput, TouchableOpacity, Modal, ScrollView, Pressable,
import { useColors } from '@/hooks/useColorScheme';
+import { ModalBackdrop } from '@/components/common/ModalBackdrop';
import { ThemedText } from '@/components/themed/ThemedText';
import { useDb } from '@/context/DbContext';
@@ -418,7 +419,6 @@ export const EmailDomainField: React.FC<EmailDomainFieldProps> = ({
paddingVertical: 12,
},
modalOverlay: {
- backgroundColor: colors.modalBackground,
flex: 1,
justifyContent: 'flex-end',
},
@@ -536,6 +536,7 @@ export const EmailDomainField: React.FC<EmailDomainFieldProps> = ({
animationType="slide"
onRequestClose={() => setIsModalVisible(false)}
>
+ <ModalBackdrop />
<Pressable style={styles.modalOverlay} onPress={() => setIsModalVisible(false)}>
<Pressable style={styles.modalContent} onPress={(e) => e.stopPropagation()}>
<View style={styles.modalHeader}>
diff --git a/apps/mobile-app/components/items/ItemTypeSelector.tsx b/apps/mobile-app/components/items/ItemTypeSelector.tsx
index 2d2359212..63b1a2b52 100644
--- a/apps/mobile-app/components/items/ItemTypeSelector.tsx
+++ b/apps/mobile-app/components/items/ItemTypeSelector.tsx
@@ -8,6 +8,7 @@ import { ItemTypes } from '@aliasvault/models/vault';
import { useColors } from '@/hooks/useColorScheme';
+import { ModalBackdrop } from '@/components/common/ModalBackdrop';
import { ThemedText } from '@/components/themed/ThemedText';
import { RobustPressable } from '@/components/ui/RobustPressable';
@@ -96,7 +97,6 @@ export const ItemTypeSelector: React.FC<ItemTypeSelectorProps> = ({
opacity: 0.8,
},
modalContainer: {
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
flex: 1,
justifyContent: 'center',
padding: 20,
@@ -184,6 +184,7 @@ export const ItemTypeSelector: React.FC<ItemTypeSelectorProps> = ({
animationType="fade"
onRequestClose={() => setShowDropdown(false)}
>
+ <ModalBackdrop />
<TouchableWithoutFeedback onPress={() => setShowDropdown(false)}>
<View style={styles.modalContainer}>
<TouchableWithoutFeedback>
diff --git a/apps/mobile-app/components/items/details/TotpEditor.tsx b/apps/mobile-app/components/items/details/TotpEditor.tsx
index c5aadb750..ed3e8d258 100644
--- a/apps/mobile-app/components/items/details/TotpEditor.tsx
+++ b/apps/mobile-app/components/items/details/TotpEditor.tsx
@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';
import { View, StyleSheet, TextInput, Modal, TouchableOpacity, ScrollView, KeyboardAvoidingView, Platform } from 'react-native';
import QRCode from 'react-native-qrcode-svg';
+import { ModalBackdrop } from '@/components/common/ModalBackdrop';
import { ThemedText } from '@/components/themed/ThemedText';
import { ThemedView } from '@/components/themed/ThemedView';
import { useDialog } from '@/context/DialogContext';
@@ -473,7 +474,6 @@ export const TotpEditor: React.FC<TotpEditorProps> = ({
flex: 1,
},
modalContainer: {
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
flex: 1,
justifyContent: 'flex-end',
},
@@ -621,6 +621,7 @@ export const TotpEditor: React.FC<TotpEditorProps> = ({
animationType="fade"
onRequestClose={hideAddChoiceModal}
>
+ <ModalBackdrop />
<TouchableOpacity
style={styles.modalContainer}
activeOpacity={1}
@@ -680,6 +681,7 @@ export const TotpEditor: React.FC<TotpEditorProps> = ({
animationType="fade"
onRequestClose={hideAddForm}
>
+ <ModalBackdrop />
<KeyboardAvoidingView
style={styles.modalContainer}
behavior="padding"
@@ -790,6 +792,7 @@ export const TotpEditor: React.FC<TotpEditorProps> = ({
animationType="fade"
onRequestClose={closeEditModal}
>
+ <ModalBackdrop />
<KeyboardAvoidingView
style={styles.modalContainer}
behavior="padding"
diff --git a/apps/mobile-app/constants/Colors.ts b/apps/mobile-app/constants/Colors.ts
index e191d2e52..d501d93ee 100644
--- a/apps/mobile-app/constants/Colors.ts
+++ b/apps/mobile-app/constants/Colors.ts
@@ -31,7 +31,7 @@ export const Colors = {
skeleton: 'rgba(98, 98, 98, 0.33)',
red: '#ff0000',
black: '#000000',
- modalBackground: 'rgba(0, 0, 0, 0.5)',
+ modalBackground: 'rgba(75, 85, 99, 0.5)',
modalSurface: '#f3f2f7',
modalSurfaceRaised: '#ffffff',
success: '#10B981',
@@ -69,7 +69,7 @@ export const Colors = {
skeleton: '#rgba(255,255,255,0.2)',
red: '#ff0000',
black: '#000000',
- modalBackground: 'rgba(88, 88, 88, 0.5)',
+ modalBackground: 'rgba(0, 0, 0, 0.8)',
modalSurface: '#1c1c1e',
modalSurfaceRaised: '#2c2c2e',
success: '#10B981',