import React, { useState } from "react"; import { View, Text, TouchableOpacity, TextInput, StyleSheet, Image, } from "react-native"; import { Ionicons, FontAwesome } from "@expo/vector-icons"; const AksesAkun = ({ navigation }) => { const [role, setRole] = useState(null); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [showPassword, setShowPassword] = useState(false); const [errorMessage, setErrorMessage] = useState(""); const handleLogin = () => { if (!role) { setErrorMessage("Pilih dulu role Anda (Admin atau Warga)"); return; } if (!email || !password) { setErrorMessage("Masukkan email dan kata sandi dengan benar"); return; } if ( role === "admin" && email === "admin@gmail.com" && password === "1234" ) { setErrorMessage(""); navigation.navigate("AksesAdminNavigator", { screen: "AdminScreen" }); } else if ( role === "warga" && email === "warga@gmail.com" && password === "1234" ) { setErrorMessage(""); navigation.navigate("AksesWargaNavigator", { screen: "Home" }); } else { setErrorMessage("Email atau kata sandi salah"); } }; return ( navigation.navigate("Onboarding")} > Selamat Datang kembali, EcoMapper ! Pilih Akses setRole("admin")} > ADMIN setRole("warga")} > WARGA Email Kata Sandi setShowPassword(!showPassword)} > {errorMessage ? ( {errorMessage} ) : null} Masuk {/* "Daftar Sekarang" Text */} Belum punya akun?{" "} navigation.navigate("AksesWargaNavigator", { screen: "daftar" }) } > Daftar Sekarang {/* "Lupa Kata Sandi?" Text */} navigation.navigate("AksesWargaNavigator", { screen: "lupasandi" }) } > Lupa Kata Sandi? ); }; export default AksesAkun; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "#fff", padding: 20, alignItems: "center", justifyContent: "center", }, backButton: { position: "absolute", top: 60, // sesuaikan dengan tinggi status bar dan padding left: 20, zIndex: 10, padding: 6, borderRadius: 6, backgroundColor: "#fff", // warna soft supaya tombol terlihat shadowColor: "#000", shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.2, }, image: { width: 300, height: 200, marginBottom: 20, }, welcomeText: { fontSize: 28, fontWeight: "bold", textAlign: "center", }, ecoMapperText: { fontSize: 34, fontWeight: "bold", color: "#000", marginBottom: 30, textAlign: "center", }, label: { fontSize: 18, alignSelf: "flex-start", marginLeft: 10, marginBottom: 10, fontWeight: "600", }, buttonContainer: { flexDirection: "row", marginBottom: 30, justifyContent: "center", gap: 15, }, roleButton: { flexDirection: "row", alignItems: "center", borderWidth: 1, borderColor: "#000", borderRadius: 12, paddingVertical: 15, paddingHorizontal: 25, marginHorizontal: 5, backgroundColor: "#fff", }, roleButtonSelected: { backgroundColor: "#2D572C", borderColor: "#2D572C", }, roleButtonText: { fontSize: 20, fontWeight: "bold", marginLeft: 8, color: "#000", }, roleButtonTextSelected: { color: "#fff", }, inputContainer: { flexDirection: "row", alignItems: "center", borderColor: "#ddd", borderWidth: 1, borderRadius: 8, marginBottom: 20, paddingLeft: 10, height: 50, width: "100%", }, input: { flex: 1, fontSize: 16, }, passwordContainer: { flexDirection: "row", alignItems: "center", borderColor: "#ddd", borderWidth: 1, borderRadius: 8, marginBottom: 40, paddingLeft: 10, height: 50, width: "100%", }, passwordInput: { flex: 1, fontSize: 16, }, icon: { marginRight: 10, }, eyeIcon: { paddingHorizontal: 10, }, loginButton: { backgroundColor: "#2D572C", paddingVertical: 15, paddingHorizontal: 160, borderRadius: 8, marginBottom: 15, }, loginButtonText: { color: "#fff", textAlign: "center", fontWeight: "bold", fontSize: 20, }, registerContainer: { marginTop: 10, }, registerText: { fontSize: 16, color: "#333", }, registerLink: { color: "#2D572C", fontWeight: "bold", }, forgotPasswordContainer: { marginTop: 10, }, forgotPasswordText: { color: "#2D572C", fontWeight: "bold", textAlign: "center", fontSize: 16, }, errorText: { color: "red", fontSize: 15, marginBottom: 10, }, });