pogdark-app/components/TopNav.tsx

52 lines
2.8 KiB
TypeScript
Raw Normal View History

2025-03-22 17:48:00 +00:00
import {Appbar, Portal, Button, Dialog, Menu, useTheme} from "react-native-paper";
import {Image, useColorScheme, View} from "react-native";
import React, {useState} from "react";
import styles from "@/assets/styles";
import About from "@/components/About";
const TopNav = ({ toggleProfile }: { toggleProfile: () => void; }) => {
const theme = useTheme();
2025-03-01 18:11:36 +00:00
const colorScheme = useColorScheme();
const [aboutVisible, setAboutVisible] = useState(false);
const [menuVisible, setMenuVisible] = useState(false);
const [menuAnchor, setMenuAnchor] = useState<{ x: number; y: number } | null>(null);
return (
<View style={{ backgroundColor: theme.colors.background }}>
<Appbar.Header style={[styles.topBar, { backgroundColor: theme.colors.primaryContainer }]}>
<View>
2025-03-01 18:11:36 +00:00
<Menu visible={menuVisible} onDismiss={() => setMenuVisible(false)} anchor={menuAnchor} style={{ backgroundColor: theme.colors.primaryContainer }}>
<Menu.Item onPress={() => { setMenuVisible(false); setAboutVisible(true);}} title="About Us" style={{ backgroundColor: theme.colors.primaryContainer }}/>
</Menu>
<Appbar.Action icon="menu"
onPressIn={(event) => {
setMenuAnchor({ x: event.nativeEvent.pageX, y: event.nativeEvent.pageY + 40 });
setMenuVisible(true);
}}
2025-02-22 02:56:54 +00:00
iconColor={theme.colors.primary} />
</View>
2025-03-02 20:32:39 +00:00
<View style={styles.logoContainer} >
2025-03-01 18:11:36 +00:00
<Image source={
colorScheme === 'dark' ?
require("../assets/images/pogdark_logo_inverse.png") : require("../assets/images/pogdark_logo.png")
2025-03-02 20:32:39 +00:00
} style={styles.logo} resizeMode={"contain"} />
</View>
2025-02-22 02:56:54 +00:00
<Appbar.Action icon="pencil" onPress={toggleProfile} iconColor={ theme.colors.primary } />
</Appbar.Header>
<Portal>
2025-03-01 18:11:36 +00:00
<Dialog visible={aboutVisible} onDismiss={() => setAboutVisible(false)} style={{ backgroundColor: theme.colors.primaryContainer }}>
<Dialog.Title style={{ color: theme.colors.primary, textAlign: 'center' }}>About Us</Dialog.Title>
<About />
<Dialog.Actions style={{ justifyContent: "center" }}>
2025-03-01 18:11:36 +00:00
<Button onPress={() => setAboutVisible(false)} mode="contained" style={{ backgroundColor: theme.colors.inversePrimary }} labelStyle={{ color: theme.colors.primary }}>
Close
</Button>
</Dialog.Actions>
</Dialog>
</Portal>
</View>
);
};
export default TopNav;