Ok it might work

This commit is contained in:
2026-04-25 12:08:14 +02:00
parent 928db54b3e
commit 858ee5e28b
10 changed files with 229 additions and 67 deletions

View File

@@ -44,20 +44,8 @@ jobs:
working-directory: ./apk/android working-directory: ./apk/android
run: | run: |
./gradlew assembleRelease ./gradlew assembleRelease
- name: 📦 Zip APK - name: 📤 Upload APK Artifact
working-directory: . uses: actions/upload-artifact@v3
run: |
mkdir -p dist
cp apk/android/app/build/outputs/apk/release/app-release.apk dist/
zip -j dist/build.zip dist/app-release.apk
- name: Create Release
uses: https://gitea.com/actions/gitea-release-action@v1
working-directory: dist
with: with:
tag_name: latest name: app-release-apk
name: Latest Build path: apk/android/app/build/outputs/apk/release/app-release.apk
files: |
- build.zip
env:
GITEA_TOKEN: ${{ secrets.GITEA }}

View File

@@ -1,6 +1,7 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { View, Text, TextInput, TouchableOpacity, StyleSheet } from "react-native"; import { View, Text, TextInput, TouchableOpacity, StyleSheet } from "react-native";
import { useAuth } from "@/context/auth-context"; import { useAuth } from "@/context/auth-context";
import { router } from "expo-router";
export default function AuthScreen() { export default function AuthScreen() {
const [isLogin, setIsLogin] = useState(true); const [isLogin, setIsLogin] = useState(true);
@@ -17,9 +18,12 @@ function LoginScreen({ onSwitch }) {
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const { login } = useAuth(); const { login } = useAuth();
const handleLogin = () => { const handleLogin = async () => {
console.log("Login ->", { email, password }); const loginResult = await login(email, password);
login(email, password); if (loginResult) {
console.log("Login successful");
router.replace("/(tabs)");
}
}; };
return ( return (

View File

@@ -1,5 +1,25 @@
import { Tabs } from "expo-router"; import { Tabs } from "expo-router";
import { Ionicons } from "@expo/vector-icons";
export default function TabsLayout() { export default function TabsLayout() {
return <Tabs />; return (
<Tabs
screenOptions={{
headerShown: false,
}}
>
<Tabs.Screen name="index" options={{
title: "Birthdays",
tabBarIcon: ({ color, size }) => (
<Ionicons name="gift" size={size} color={color} />
),
}} />
<Tabs.Screen name="settings" options={{
title: "Settings",
tabBarIcon: ({ color, size }) => (
<Ionicons name="settings" size={size} color={color} />
),
}} />
</Tabs>
);
} }

View File

@@ -14,7 +14,11 @@ export default function HomeScreen() {
<View style={styles.actionsContainer}> <View style={styles.actionsContainer}>
<Text style={styles.title}>Upcoming Birthdays</Text> <Text style={styles.title}>Upcoming Birthdays</Text>
<TouchableOpacity <TouchableOpacity
onPress={() => router.push("/add")} onPress={() => {
router.push("/add");
}
}
style={styles.addButton} style={styles.addButton}
> >
<Text style={styles.addButtonText}>+</Text> <Text style={styles.addButtonText}>+</Text>

148
apk/app/(tabs)/settings.tsx Normal file
View File

@@ -0,0 +1,148 @@
import React, { useState } from "react";
import { StyleSheet, Text, View, TouchableOpacity, Alert } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { useRouter } from "expo-router";
import { useAuth } from "@/context/auth-context";
export default function SettingsScreen() {
const router = useRouter()
const { logout } = useAuth();
const [theme, setTheme] = useState("light"); // light | dark | system
const handleLogout = () => {
Alert.alert("Logout", "Are you sure you want to logout?", [
{ text: "Cancel", style: "cancel" },
{
text: "Logout",
style: "destructive",
onPress: () => {
// TODO: clear auth state here
router.replace("/login");
logout();
},
},
]);
};
const toggleTheme = (value) => {
setTheme(value);
// TODO: persist theme (AsyncStorage / context / zustand)
};
return (
<SafeAreaView style={styles.screen} edges={["top", "bottom"]}>
<View style={styles.content}>
<Text style={styles.title}>Settings</Text>
{/* Theme Selector */}
<View style={styles.section}>
<Text style={styles.sectionTitle}>Theme</Text>
<View style={styles.row}>
<ThemeButton
label="Light"
active={theme === "light"}
onPress={() => toggleTheme("light")}
/>
<ThemeButton
label="Dark"
active={theme === "dark"}
onPress={() => toggleTheme("dark")}
/>
<ThemeButton
label="System"
active={theme === "system"}
onPress={() => toggleTheme("system")}
/>
</View>
</View>
{/* Logout */}
<View style={styles.section}>
<Text style={styles.sectionTitle}>Account</Text>
<TouchableOpacity style={styles.logoutButton} onPress={handleLogout}>
<Text style={styles.logoutText}>Log Out</Text>
</TouchableOpacity>
</View>
</View>
</SafeAreaView>
);
}
function ThemeButton({ label, active, onPress }) {
return (
<TouchableOpacity
onPress={onPress}
style={[styles.themeButton, active && styles.themeButtonActive]}
>
<Text style={[styles.themeText, active && styles.themeTextActive]}>
{label}
</Text>
</TouchableOpacity>
);
}
const styles = StyleSheet.create({
screen: {
flex: 1,
backgroundColor: "#fff",
},
content: {
flex: 1,
paddingHorizontal: 16,
paddingTop: 12,
},
title: {
fontSize: 24,
fontWeight: "bold",
marginBottom: 20,
},
section: {
marginBottom: 24,
},
sectionTitle: {
fontSize: 16,
fontWeight: "600",
marginBottom: 10,
},
row: {
flexDirection: "row",
gap: 10,
},
themeButton: {
paddingVertical: 8,
paddingHorizontal: 12,
borderRadius: 8,
borderWidth: 1,
borderColor: "#ccc",
},
themeButtonActive: {
backgroundColor: "#111",
borderColor: "#111",
},
themeText: {
color: "#333",
paddingHorizontal: 5,
},
themeTextActive: {
color: "#fff",
},
logoutButton: {
padding: 14,
borderRadius: 10,
backgroundColor: "#ff3b30",
alignItems: "center",
},
logoutText: {
color: "#fff",
fontWeight: "600",
},
});

View File

@@ -0,0 +1,23 @@
import React from "react";
import { View, Text, ActivityIndicator, StyleSheet } from "react-native";
export default function LoadingScreen({ message = "Loading..." }) {
return (
<View style={styles.container}>
<ActivityIndicator size="large" color="#ffffff" />
<Text style={styles.text}>{message}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
text: {
marginTop: 10,
fontSize: 16,
},
});

View File

@@ -1,30 +1,33 @@
import { BirthdaysProvider } from "@/context/birthdays-context"; import { BirthdaysProvider } from "@/context/birthdays-context";
import { useAuth } from "@/context/auth-context"; import { useAuth } from "@/context/auth-context";
import { Stack, router, useRootNavigationState, useSegments } from "expo-router"; import { Stack, router, useRootNavigationState, useSegments } from "expo-router";
import { useEffect } from "react"; import React, { useEffect } from "react";
import LoadingScreen from "./loading-screen";
export default function RootLayout() { export default function RootLayout() {
const { user, isHydrated } = useAuth(); const { user, isHydrated } = useAuth();
const navigationState = useRootNavigationState(); const navigationState = useRootNavigationState();
const segments = useSegments(); const segments = useSegments();
const [loaded, setLoaded] = React.useState(false);
useEffect(() => { useEffect(() => {
if (!isHydrated || !navigationState?.key) { if (!isHydrated || !navigationState?.key) return;
return;
}
const inAuthGroup = segments[0] === "(auth)"; const inAuthGroup = segments.length === 0;
if (!user && !inAuthGroup) { if (!user) {
router.replace("/(auth)/login"); router.replace("/(auth)/login");
return; } else if (inAuthGroup) {
}
if (user && inAuthGroup) {
router.replace("/(tabs)"); router.replace("/(tabs)");
} }
setLoaded(true); // 👈 ALWAYS run this
}, [isHydrated, navigationState?.key, segments, user]); }, [isHydrated, navigationState?.key, segments, user]);
if(!loaded) {
return (<LoadingScreen />); // or a loading spinner
}
return ( return (
<BirthdaysProvider> <BirthdaysProvider>
<Stack screenOptions={{ headerShown: false }} /> <Stack screenOptions={{ headerShown: false }} />

View File

@@ -1,31 +0,0 @@
import {
DarkTheme,
DefaultTheme,
ThemeProvider,
} from "@react-navigation/native";
import { Stack } from "expo-router";
import { StatusBar } from "expo-status-bar";
import "react-native-reanimated";
import { BirthdaysProvider } from "@/context/birthdays-context";
import { useColorScheme } from "@/hooks/use-color-scheme";
export const unstable_settings = {
anchor: "(tabs)",
};
export default function RootLayout() {
const colorScheme = useColorScheme();
return (
<BirthdaysProvider>
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
<Stack>
<Stack.Screen name="index" options={{ headerShown: false }} />
<Stack.Screen name="add" options={{ headerShown: false }} />
</Stack>
<StatusBar style="auto" />
</ThemeProvider>
</BirthdaysProvider>
);
}

View File

@@ -8,7 +8,7 @@ interface User {
interface AuthContextValue { interface AuthContextValue {
user: User | null; user: User | null;
isHydrated: boolean; isHydrated: boolean;
login: (email: string, password: string) => Promise<void>; login: (email: string, password: string) => Promise<boolean>;
logout: () => Promise<void>; logout: () => Promise<void>;
} }
@@ -41,6 +41,9 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(fakeUser)); await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(fakeUser));
setUser(fakeUser); setUser(fakeUser);
console.log(fakeUser)
await new Promise((resolve) => setTimeout(resolve, 1000));
return true;
} }
const logout = async () => { const logout = async () => {