fix component
- buttom radius valuenya constans - perbaikan bottom pada auth file
This commit is contained in:
@@ -6,7 +6,8 @@ import {
|
|||||||
TextInputCustom,
|
TextInputCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { useLocalSearchParams } from "expo-router";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Text } from "react-native";
|
import { Text } from "react-native";
|
||||||
|
|
||||||
@@ -21,10 +22,10 @@ export default function ProfileEdit() {
|
|||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
bottomBarComponent={
|
bottomBarComponent={
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
radius={30}
|
|
||||||
disabled={!nama || !email || !alamat}
|
disabled={!nama || !email || !alamat}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
console.log("data >>", nama, email, alamat);
|
console.log("data >>", nama, email, alamat);
|
||||||
|
// router.back();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
|
|||||||
@@ -3,9 +3,14 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Text, TouchableOpacity } from "react-native";
|
import { Text, TouchableOpacity } from "react-native";
|
||||||
import buttonStyles from "./buttonCustomStyles";
|
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 {
|
interface ButtonProps {
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
@@ -13,36 +18,28 @@ interface ButtonProps {
|
|||||||
title?: string;
|
title?: string;
|
||||||
backgroundColor?: string;
|
backgroundColor?: string;
|
||||||
textColor?: string;
|
textColor?: string;
|
||||||
radius?: number;
|
radius?: RadiusType; // ← bisa string enum atau number
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
iconLeft?: React.ReactNode;
|
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={<Icon name="arrow-right" size={20} color={MainColor.black}/>
|
|
||||||
*/
|
|
||||||
const ButtonCustom: React.FC<ButtonProps> = ({
|
const ButtonCustom: React.FC<ButtonProps> = ({
|
||||||
children,
|
children,
|
||||||
onPress,
|
onPress,
|
||||||
title = "Button",
|
title = "Button",
|
||||||
backgroundColor = "#007AFF",
|
backgroundColor = MainColor.yellow,
|
||||||
textColor = "#FFFFFF",
|
textColor = MainColor.black,
|
||||||
radius = 8,
|
radius = "full", // default md
|
||||||
disabled = false,
|
disabled = false,
|
||||||
iconLeft,
|
iconLeft,
|
||||||
}) => {
|
}) => {
|
||||||
|
const borderRadius =
|
||||||
|
typeof radius === "number" ? radius : radiusMap[radius ?? "md"]; // fallback ke 'md'
|
||||||
|
|
||||||
const styles = buttonStyles({
|
const styles = buttonStyles({
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
textColor,
|
textColor,
|
||||||
borderRadius: RADIUS_BUTTON || radius,
|
borderRadius,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -54,7 +51,7 @@ const ButtonCustom: React.FC<ButtonProps> = ({
|
|||||||
>
|
>
|
||||||
{/* Render icon jika tersedia */}
|
{/* Render icon jika tersedia */}
|
||||||
{iconLeft && iconLeft}
|
{iconLeft && iconLeft}
|
||||||
<Text style={styles.buttonText}>{children}</Text>
|
<Text style={styles.buttonText}>{children || title}</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
10
constants/radius-value.ts
Normal file
10
constants/radius-value.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// constants/radius.ts
|
||||||
|
|
||||||
|
export const radiusMap = {
|
||||||
|
xs: 2,
|
||||||
|
sm: 4,
|
||||||
|
md: 6,
|
||||||
|
lg: 8,
|
||||||
|
xl: 12,
|
||||||
|
full: 100,
|
||||||
|
} as const;
|
||||||
@@ -23,8 +23,13 @@ export default function LoginView() {
|
|||||||
function handleLogin() {
|
function handleLogin() {
|
||||||
const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || "";
|
const callingCode = selectedCountry?.callingCode.replace(/^\+/, "") || "";
|
||||||
const fixNumber = callingCode + inputValue;
|
const fixNumber = callingCode + inputValue;
|
||||||
console.log(fixNumber);
|
// console.log("fixNumber", fixNumber);
|
||||||
const id = fixNumber.replace(/\D/g, "");
|
// 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)/profile/${id}`);
|
||||||
// router.navigate("/(application)/home");
|
// router.navigate("/(application)/home");
|
||||||
@@ -67,13 +72,7 @@ export default function LoginView() {
|
|||||||
|
|
||||||
<Spacing height={20} />
|
<Spacing height={20} />
|
||||||
|
|
||||||
<ButtonCustom
|
<ButtonCustom onPress={handleLogin}>Login</ButtonCustom>
|
||||||
title="Login"
|
|
||||||
backgroundColor={MainColor.yellow}
|
|
||||||
textColor={MainColor.black}
|
|
||||||
radius={10}
|
|
||||||
onPress={handleLogin}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,8 +7,14 @@ import { GStyles } from "@/styles/global-styles";
|
|||||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
import { Text, View } from "react-native";
|
import { Text, View } from "react-native";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function RegisterView() {
|
export default function RegisterView() {
|
||||||
|
const [username, setUsername] = useState("Bagas Banuna");
|
||||||
|
const handleRegister = () => {
|
||||||
|
console.log("Success register", username);
|
||||||
|
router.push("/(application)/home");
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper withBackground>
|
<ViewWrapper withBackground>
|
||||||
@@ -30,24 +36,18 @@ export default function RegisterView() {
|
|||||||
<Text style={GStyles.textLabel}>+6282xxxxxxxxx</Text>
|
<Text style={GStyles.textLabel}>+6282xxxxxxxxx</Text>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
</View>
|
</View>
|
||||||
<TextInputCustom placeholder="Masukkan username" />
|
<TextInputCustom
|
||||||
|
placeholder="Masukkan username"
|
||||||
<ButtonCustom
|
value={username}
|
||||||
title="Daftar"
|
onChangeText={(text) => setUsername(text)}
|
||||||
backgroundColor={MainColor.yellow}
|
|
||||||
textColor={MainColor.black}
|
|
||||||
radius={10}
|
|
||||||
onPress={() => (
|
|
||||||
console.log("Success register"),
|
|
||||||
router.push("/(application)/home")
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<ButtonCustom onPress={handleRegister}>Daftar</ButtonCustom>
|
||||||
{/* <Spacing />
|
{/* <Spacing />
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
title="Coba"
|
title="Coba"
|
||||||
backgroundColor={MainColor.yellow}
|
backgroundColor={MainColor.yellow}
|
||||||
textColor={MainColor.black}
|
textColor={MainColor.black}
|
||||||
radius={10}
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
console.log("Home clicked");
|
console.log("Home clicked");
|
||||||
router.push("/(application)/coba");
|
router.push("/(application)/coba");
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import { Text, View } from "react-native";
|
|||||||
import { OtpInput } from "react-native-otp-entry";
|
import { OtpInput } from "react-native-otp-entry";
|
||||||
|
|
||||||
export default function VerificationView() {
|
export default function VerificationView() {
|
||||||
|
const handleVerification = () => {
|
||||||
|
console.log("Verification clicked");
|
||||||
|
router.push("/register");
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper withBackground>
|
<ViewWrapper withBackground>
|
||||||
@@ -48,12 +52,12 @@ export default function VerificationView() {
|
|||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
title="Verifikasi"
|
|
||||||
backgroundColor={MainColor.yellow}
|
backgroundColor={MainColor.yellow}
|
||||||
textColor={MainColor.black}
|
textColor={MainColor.black}
|
||||||
radius={10}
|
onPress={() => handleVerification()}
|
||||||
onPress={() => router.push("/register")}
|
>
|
||||||
/>
|
Verifikasi
|
||||||
|
</ButtonCustom>
|
||||||
</View>
|
</View>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user