-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.js
More file actions
44 lines (37 loc) · 1.17 KB
/
App.js
File metadata and controls
44 lines (37 loc) · 1.17 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
44
import React from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { ThemeProvider, useTheme } from "./ThemeContext";
import AllProfilesMain from "./components/all-profiles/AllProfilesMain";
const Stack = createNativeStackNavigator();
export default function App() {
return (
<ThemeProvider>
<AppContent />
</ThemeProvider>
);
}
function AppContent() {
const { theme } = useTheme();
return (
<NavigationContainer theme={theme}>
<Stack.Navigator>
<Stack.Screen
name="Profiles"
component={AllProfilesMain}
options={{ headerRight: () => <ThemeToggle /> }}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
import { Switch, View, Text } from "react-native";
function ThemeToggle() {
const { isDark, toggleTheme } = useTheme();
return (
<View style={{ flexDirection: "row", alignItems: "center", paddingRight: 10 }}>
<Text style={{ color: isDark ? "white" : "black", marginRight: 5 }}>Dark Mode</Text>
<Switch value={isDark} onValueChange={toggleTheme} />
</View>
);
}