-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathThemeWrapper.js
More file actions
43 lines (38 loc) · 1.37 KB
/
ThemeWrapper.js
File metadata and controls
43 lines (38 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import { View, StyleSheet, StatusBar } from 'react-native';
import { LinearGradient } from 'expo-linear-gradient';
import { THEMES, COLORS } from '../constants/theme';
import { useTheme } from '../context/ThemeContext';
import { SafeAreaView } from 'react-native-safe-area-context';
export const ThemeWrapper = ({ children }) => {
const { style, mode } = useTheme();
let BackgroundComponent;
let statusBarColor;
if (style === THEMES.NEOBRUTALISM) {
const bgColor = mode === 'dark' ? COLORS.neo.dark : COLORS.neo.lightBg;
BackgroundComponent = <View style={[styles.container, { backgroundColor: bgColor }]}>{children}</View>;
statusBarColor = mode === 'dark' ? 'light-content' : 'dark-content';
} else {
// Glassmorphism
const colors = mode === 'dark' ? COLORS.glass.dark : COLORS.glass.light;
BackgroundComponent = (
<LinearGradient colors={colors} style={styles.container} start={{ x: 1, y: 0 }} end={{ x: 0, y: 1 }}>
{children}
</LinearGradient>
);
statusBarColor = mode === 'dark' ? 'light-content' : 'dark-content';
}
return (
<>
<StatusBar barStyle={statusBarColor} />
<SafeAreaView style={{flex: 1}} edges={['top', 'left', 'right']}>
{BackgroundComponent}
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
});