Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"backgroundColor": "#000000"
}
}
]
],
"expo-secure-store"
],
"experiments": {
"typedRoutes": true,
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions app/(protected)/(tabs)/calendar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "@/features/calendar/screens/CalendarScreen";
50 changes: 50 additions & 0 deletions app/(protected)/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Button from "@/components/ui/buttons";
import { useAuth } from "@/features/shared/hooks/useAuth";
import { router } from "expo-router";
import { StyleSheet, Text, View } from "react-native";

export default function Index() {
const { logout } = useAuth();

const handleLogout = async () => {
await logout();
router.replace("/login");
};

return (
<View style={styles.container}>
<Text style={styles.title}>To-do app</Text>
<Text style={styles.subtitle}>You are logged in.</Text>
<View style={styles.actions}>
<Button
label="Go to the Calendar"
onPress={() => router.push("/calendar")}
/>
<Button label="Logout" onPress={handleLogout} />
</View>
</View>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
gap: 12,
paddingHorizontal: 24,
},
actions: {
alignItems: "center",
gap: 12,
},
title: {
fontSize: 24,
fontWeight: "700",
},
subtitle: {
fontSize: 14,
color: "#555",
textAlign: "center",
},
});
File renamed without changes.
21 changes: 21 additions & 0 deletions app/(protected)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useAuth } from "@/features/shared/hooks/useAuth";
import { Redirect, Slot } from "expo-router";
import { Text, View } from "react-native";

export default function ProtectedLayout() {
const { isAuthenticated, isLoading } = useAuth();

if (isLoading) {
return (
<View>
<Text>Loading...</Text>
</View>
);
}

if (!isAuthenticated) {
return <Redirect href="/login" />;
}

return <Slot />;
}
5 changes: 5 additions & 0 deletions app/(protected)/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Redirect } from "expo-router";

export default function ProtectedIndex() {
return <Redirect href="/calendar" />;
}
21 changes: 21 additions & 0 deletions app/(public)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useAuth } from "@/features/shared/hooks/useAuth";
import { Redirect, Slot } from "expo-router";
import { Text, View } from "react-native";

export default function PublicLayout() {
const { isAuthenticated, isLoading } = useAuth();

if (isLoading) {
return (
<View>
<Text>Loading...</Text>
</View>
);
}

if (isAuthenticated) {
return <Redirect href="/calendar" />;
}

return <Slot />;
}
5 changes: 5 additions & 0 deletions app/(public)/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Redirect } from "expo-router";

export default function PublicIndex() {
return <Redirect href="/login" />;
}
46 changes: 46 additions & 0 deletions app/(public)/login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import Button from "@/components/ui/buttons";
import { useAuth } from "@/features/shared/hooks/useAuth";
import { router } from "expo-router";
import { StyleSheet, Text, View } from "react-native";

export default function LoginScreen() {
const { login, isLoading } = useAuth();

const handleLogin = async () => {
await login();
router.replace("/calendar");
};

return (
<View style={styles.container}>
<Text style={styles.title}>To-do app</Text>
<Text style={styles.subtitle}>
Welcome to the app. Login to access all pages.
</Text>
<Button
label={isLoading ? "Loading..." : "Login"}
onPress={handleLogin}
/>
</View>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
gap: 12,
paddingHorizontal: 24,
},
title: {
fontSize: 24,
fontWeight: "700",
},
subtitle: {
fontSize: 14,
color: "#555",
marginBottom: 8,
textAlign: "center",
},
});
Loading