rersistesiion integraytion api impolement
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { View, Text, StyleSheet, ActivityIndicator } from "react-native";
|
||||
import * as Keychain from "react-native-keychain";
|
||||
import { StackNavigationProp } from "@react-navigation/stack";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { RootStackParamList } from "../navigation/AppNavigator"; // adjust path
|
||||
|
||||
const SplashScreen = () => {
|
||||
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>();
|
||||
|
||||
useEffect(() => {
|
||||
const checkLogin = async () => {
|
||||
try {
|
||||
const creds = await Keychain.getGenericPassword();
|
||||
if (creds) {
|
||||
console.log("🔑 Found token:", creds.password);
|
||||
navigation.replace("Home"); // go to bottom tabs if logged in
|
||||
} else {
|
||||
navigation.replace("Login"); // go to login if not logged in
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error checking login:", error);
|
||||
navigation.replace("Login");
|
||||
}
|
||||
};
|
||||
|
||||
setTimeout(checkLogin, 1500); // show splash for 1.5s
|
||||
}, [navigation]);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>Circle Collect</Text>
|
||||
<ActivityIndicator size="large" color="#FF7A00" style={{ marginTop: 20 }} />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default SplashScreen;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
backgroundColor: "#111111",
|
||||
},
|
||||
title: {
|
||||
fontSize: 28,
|
||||
fontWeight: "800",
|
||||
color: "#FF7A00",
|
||||
letterSpacing: 1,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user