first commit
This commit is contained in:
61
mobile/src/components/BottomNav.tsx
Normal file
61
mobile/src/components/BottomNav.tsx
Normal file
@@ -0,0 +1,61 @@
|
||||
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
||||
import { useRouter } from "../router";
|
||||
import { TABS } from "../../App";
|
||||
|
||||
|
||||
export function BottomNav() {
|
||||
const { route, navigate } = useRouter();
|
||||
|
||||
return (
|
||||
<View style={styles.bar}>
|
||||
{TABS.map((tab) => {
|
||||
const active = tab.route === route;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
key={tab.route}
|
||||
style={styles.tab}
|
||||
onPress={() => navigate(tab.route)}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
<Text style={[styles.label, active && styles.labelActive]}>
|
||||
{tab.label}
|
||||
</Text>
|
||||
{active && <View style={styles.indicator} />}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
bar: {
|
||||
flexDirection: "row",
|
||||
height: 74,
|
||||
borderTopWidth:1,
|
||||
borderTopColor: "#e5e5e5",
|
||||
backgroundColor: "#fff",
|
||||
},
|
||||
tab: {
|
||||
flex: 1,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
label: {
|
||||
fontSize: 13,
|
||||
color: "#aaa",
|
||||
fontWeight: "500",
|
||||
},
|
||||
labelActive: {
|
||||
color: "#1a1a1a",
|
||||
fontWeight: "700",
|
||||
},
|
||||
indicator: {
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
width: 32,
|
||||
height: 3,
|
||||
borderRadius: 2,
|
||||
backgroundColor: "#1a1a1a",
|
||||
},
|
||||
});
|
||||
36
mobile/src/pages/NotFound.tsx
Normal file
36
mobile/src/pages/NotFound.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
|
||||
export function NotFoundPage() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.code}>404</Text>
|
||||
<Text style={styles.title}>Page Not Found</Text>
|
||||
<Text style={styles.subtitle}>This route doesn't exist yet.</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
backgroundColor: "#f9f9f9",
|
||||
},
|
||||
code: {
|
||||
fontSize: 72,
|
||||
fontWeight: "800",
|
||||
color: "#ccc",
|
||||
lineHeight: 80,
|
||||
},
|
||||
title: {
|
||||
fontSize: 22,
|
||||
fontWeight: "600",
|
||||
marginTop: 8,
|
||||
marginBottom: 6,
|
||||
},
|
||||
subtitle: {
|
||||
fontSize: 14,
|
||||
color: "#999",
|
||||
},
|
||||
});
|
||||
45
mobile/src/pages/index.tsx
Normal file
45
mobile/src/pages/index.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import { useState } from "react";
|
||||
import { Button, StyleSheet, Text, View } from "react-native";
|
||||
import { TextInput } from "react-native";
|
||||
|
||||
export function IndexPage() {
|
||||
const [text, setText] = useState("");
|
||||
|
||||
const handleSend = () => {
|
||||
alert(`You typed: ${text}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Update Title</Text>
|
||||
<Text style={styles.subtitle}>You typed "{text}"</Text>
|
||||
|
||||
<View>
|
||||
<TextInput
|
||||
placeholder="Type something..."
|
||||
value={text}
|
||||
onChangeText={setText}
|
||||
/>
|
||||
<Button title="Send" onPress={handleSend} />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
backgroundColor: "#f9f9f9",
|
||||
},
|
||||
title: {
|
||||
fontSize: 28,
|
||||
fontWeight: "700",
|
||||
marginBottom: 8,
|
||||
},
|
||||
subtitle: {
|
||||
fontSize: 16,
|
||||
color: "#666",
|
||||
},
|
||||
});
|
||||
26
mobile/src/router.tsx
Normal file
26
mobile/src/router.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import React, { createContext, useContext, useState } from "react";
|
||||
|
||||
export type Route = "home" | "mystery";
|
||||
|
||||
interface RouterContextValue {
|
||||
route: Route;
|
||||
navigate: (to: Route) => void;
|
||||
}
|
||||
|
||||
const RouterContext = createContext<RouterContextValue | null>(null);
|
||||
|
||||
export function RouterProvider({ children }: { children: React.ReactNode }) {
|
||||
const [route, setRoute] = useState<Route>("home");
|
||||
|
||||
return (
|
||||
<RouterContext.Provider value={{ route, navigate: setRoute }}>
|
||||
{children}
|
||||
</RouterContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useRouter(): RouterContextValue {
|
||||
const ctx = useContext(RouterContext);
|
||||
if (!ctx) throw new Error("useRouter must be used inside <RouterProvider>");
|
||||
return ctx;
|
||||
}
|
||||
Reference in New Issue
Block a user