From f5cf9e15499ac1c0268c856cfa4befca4bb345b6 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Thu, 3 Jul 2025 17:05:53 +0800 Subject: [PATCH] fix component - buttom radius valuenya constans - perbaikan bottom pada auth file --- app/(application)/profile/[id]/edit.tsx | 5 +-- components/Button/ButtonCustom.tsx | 35 ++++++++++----------- constants/radius-value.ts | 10 ++++++ screens/Authentication/LoginView.tsx | 17 +++++----- screens/Authentication/RegisterView.tsx | 24 +++++++------- screens/Authentication/VerificationView.tsx | 12 ++++--- 6 files changed, 57 insertions(+), 46 deletions(-) create mode 100644 constants/radius-value.ts diff --git a/app/(application)/profile/[id]/edit.tsx b/app/(application)/profile/[id]/edit.tsx index d4d3ef4..ba39981 100644 --- a/app/(application)/profile/[id]/edit.tsx +++ b/app/(application)/profile/[id]/edit.tsx @@ -6,7 +6,8 @@ import { TextInputCustom, ViewWrapper, } from "@/components"; -import { useLocalSearchParams } from "expo-router"; +import { MainColor } from "@/constants/color-palet"; +import { router, useLocalSearchParams } from "expo-router"; import { useState } from "react"; import { Text } from "react-native"; @@ -21,10 +22,10 @@ export default function ProfileEdit() { { console.log("data >>", nama, email, alamat); + // router.back(); }} > Simpan diff --git a/components/Button/ButtonCustom.tsx b/components/Button/ButtonCustom.tsx index bdfc553..f6cd71a 100644 --- a/components/Button/ButtonCustom.tsx +++ b/components/Button/ButtonCustom.tsx @@ -3,9 +3,14 @@ import React from "react"; import { Text, TouchableOpacity } from "react-native"; import buttonStyles from "./buttonCustomStyles"; -import { RADIUS_BUTTON } from "@/constants/constans-value"; +import { radiusMap } from "@/constants/radius-value"; +import { MainColor } from "@/constants/color-palet"; -// Definisi props dengan TypeScript +// Import radiusMap + + +// Definisi type untuk radius +type RadiusType = keyof typeof radiusMap | number; interface ButtonProps { children?: React.ReactNode; @@ -13,36 +18,28 @@ interface ButtonProps { title?: string; backgroundColor?: string; textColor?: string; - radius?: number; + radius?: RadiusType; // ← bisa string enum atau number disabled?: boolean; iconLeft?: React.ReactNode; } -/** - * Props untuk ButtonCustom - * @param onPress: () => void - * @param title?: string - * @param backgroundColor?: string - * @param textColor?: string - * @param radius?: number - * @param disabled?: boolean - * @param iconLeft?: React.ReactNode - * @example iconLeft={ - */ const ButtonCustom: React.FC = ({ children, onPress, title = "Button", - backgroundColor = "#007AFF", - textColor = "#FFFFFF", - radius = 8, + backgroundColor = MainColor.yellow, + textColor = MainColor.black, + radius = "full", // default md disabled = false, iconLeft, }) => { + const borderRadius = + typeof radius === "number" ? radius : radiusMap[radius ?? "md"]; // fallback ke 'md' + const styles = buttonStyles({ backgroundColor, textColor, - borderRadius: RADIUS_BUTTON || radius, + borderRadius, }); return ( @@ -54,7 +51,7 @@ const ButtonCustom: React.FC = ({ > {/* Render icon jika tersedia */} {iconLeft && iconLeft} - {children} + {children || title} ); }; diff --git a/constants/radius-value.ts b/constants/radius-value.ts new file mode 100644 index 0000000..b8925f4 --- /dev/null +++ b/constants/radius-value.ts @@ -0,0 +1,10 @@ +// constants/radius.ts + +export const radiusMap = { + xs: 2, + sm: 4, + md: 6, + lg: 8, + xl: 12, + full: 100, +} as const; diff --git a/screens/Authentication/LoginView.tsx b/screens/Authentication/LoginView.tsx index d04063e..256676d 100644 --- a/screens/Authentication/LoginView.tsx +++ b/screens/Authentication/LoginView.tsx @@ -23,8 +23,13 @@ export default function LoginView() { function handleLogin() { const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || ""; const fixNumber = callingCode + inputValue; - console.log(fixNumber); - const id = fixNumber.replace(/\D/g, ""); + // console.log("fixNumber", fixNumber); + // router.navigate("/verification"); + + const randomAlfabet = Math.random().toString(36).substring(2, 8); + const randomNumber = Math.floor(Math.random() * 1000000); + const id = randomAlfabet + randomNumber + fixNumber; + console.log("user id :", id); router.navigate(`/(application)/profile/${id}`); // router.navigate("/(application)/home"); @@ -67,13 +72,7 @@ export default function LoginView() { - + Login ); diff --git a/screens/Authentication/RegisterView.tsx b/screens/Authentication/RegisterView.tsx index d8e1d01..af10e51 100644 --- a/screens/Authentication/RegisterView.tsx +++ b/screens/Authentication/RegisterView.tsx @@ -7,8 +7,14 @@ import { GStyles } from "@/styles/global-styles"; import { MaterialCommunityIcons } from "@expo/vector-icons"; import { router } from "expo-router"; import { Text, View } from "react-native"; +import { useState } from "react"; export default function RegisterView() { + const [username, setUsername] = useState("Bagas Banuna"); + const handleRegister = () => { + console.log("Success register", username); + router.push("/(application)/home"); + }; return ( <> @@ -30,24 +36,18 @@ export default function RegisterView() { +6282xxxxxxxxx - - - ( - console.log("Success register"), - router.push("/(application)/home") - )} + setUsername(text)} /> + + Daftar {/* { console.log("Home clicked"); router.push("/(application)/coba"); diff --git a/screens/Authentication/VerificationView.tsx b/screens/Authentication/VerificationView.tsx index d26621f..6a1aaa1 100644 --- a/screens/Authentication/VerificationView.tsx +++ b/screens/Authentication/VerificationView.tsx @@ -8,6 +8,10 @@ import { Text, View } from "react-native"; import { OtpInput } from "react-native-otp-entry"; export default function VerificationView() { + const handleVerification = () => { + console.log("Verification clicked"); + router.push("/register"); + }; return ( <> @@ -48,12 +52,12 @@ export default function VerificationView() { router.push("/register")} - /> + onPress={() => handleVerification()} + > + Verifikasi +