login register

This commit is contained in:
2025-11-10 16:59:33 +07:00
parent 62f8299aef
commit 87269a6615
10 changed files with 249 additions and 4 deletions

View File

@@ -0,0 +1,53 @@
import { Tabs } from "expo-router";
import { Ionicons } from "@expo/vector-icons";
import { Button, Alert } from "react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { useRouter } from "expo-router";
export default function TabsLayout() {
const router = useRouter();
const handleLogout = async () => {
Alert.alert("Đăng xuất", "Bạn có chắc muốn đăng xuất?", [
{
text: "Hủy",
style: "cancel",
},
{
text: "Đăng xuất",
style: "destructive",
onPress: async () => {
await AsyncStorage.removeItem("authToken");
router.replace("/"); // quay về màn hình đăng nhập
},
},
]);
};
return (
<Tabs screenOptions={{ headerShown: true, tabBarActiveTintColor: "#007AFF" }}>
<Tabs.Screen
name="home"
options={{
title: "Trang chủ",
tabBarIcon: ({ color, size }) => <Ionicons name="home" color={color} size={size} />,
}}
/>
<Tabs.Screen
name="products"
options={{
title: "Sản phẩm",
tabBarIcon: ({ color, size }) => <Ionicons name="pricetags" color={color} size={size} />,
}}
/>
<Tabs.Screen
name="account"
options={{
title: "Tài khoản",
tabBarIcon: ({ color, size }) => <Ionicons name="person" color={color} size={size} />,
headerRight: () => <Button title="Logout" onPress={handleLogout} color="#FF3B30" />,
}}
/>
</Tabs>
);
}

View File

@@ -0,0 +1,9 @@
import { View, Text } from "react-native";
export default function HomeScreen() {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text>Chào mừng đến Tài khoản!</Text>
</View>
);
}

9
app/(tabs)/home.tsx Normal file
View File

@@ -0,0 +1,9 @@
import { View, Text } from "react-native";
export default function HomeScreen() {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text>Chào mừng đến Trang chủ!</Text>
</View>
);
}

View File

View File

@@ -0,0 +1,9 @@
import { View, Text } from "react-native";
export default function HomeScreen() {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text>Chào mừng đến Sản phẩm!</Text>
</View>
);
}