From 5c4dadbe7c663de00801521cb91a287b5ff4fedb Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Wed, 9 Jul 2025 11:40:22 +0800 Subject: [PATCH] fix dekripsi: - fix styles Select --- .../(user)/portofolio/[id]/create.tsx | 32 ++++--- components/Select/SelectCustom.tsx | 90 ++++--------------- components/TextArea/TextAreaCustom.tsx | 22 ++--- components/TextInput/TextInputCustom.tsx | 22 ++--- styles/global-styles.ts | 57 +++++++++--- 5 files changed, 103 insertions(+), 120 deletions(-) diff --git a/app/(application)/(user)/portofolio/[id]/create.tsx b/app/(application)/(user)/portofolio/[id]/create.tsx index 0405867..3673875 100644 --- a/app/(application)/(user)/portofolio/[id]/create.tsx +++ b/app/(application)/(user)/portofolio/[id]/create.tsx @@ -1,14 +1,14 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { - ButtonCustom, - Grid, - SelectCustom, - Spacing, - StackCustom, - TextAreaCustom, - TextCustom, - TextInputCustom, - ViewWrapper, + ButtonCustom, + Grid, + SelectCustom, + Spacing, + StackCustom, + TextAreaCustom, + TextCustom, + TextInputCustom, + ViewWrapper, } from "@/components"; import BoxButtonOnFooter from "@/components/Box/BoxButtonOnFooter"; import InformationBox from "@/components/Box/InformationBox"; @@ -71,9 +71,12 @@ export default function PortofolioCreate() { label: item.name, value: item.id, }))} - value="" - onChange={(value) => console.log(value)} + value={data.bidang_usaha} + onChange={(value) => { + setData({ ...(data as any), bidang_usaha: value }); + }} /> + console.log(value)} + value={data.sub_bidang_usaha} + onChange={(value) => { + setData({ ...(data as any), sub_bidang_usaha: value }); + }} /> + console.log("add")}> Tambah Pilihan diff --git a/components/Select/SelectCustom.tsx b/components/Select/SelectCustom.tsx index 5d7492c..c1b32e5 100644 --- a/components/Select/SelectCustom.tsx +++ b/components/Select/SelectCustom.tsx @@ -1,15 +1,13 @@ // components/Select.tsx -import { MainColor } from "@/constants/color-palet"; -import { TEXT_SIZE_MEDIUM } from "@/constants/constans-value"; +import { GStyles } from "@/styles/global-styles"; import React, { useState } from "react"; import { FlatList, Modal, Pressable, - StyleSheet, Text, TouchableOpacity, - View, + View } from "react-native"; type SelectItem = { @@ -24,6 +22,7 @@ type SelectProps = { value?: string | number | null; required?: boolean; // <-- new prop onChange: (value: string | number) => void; + borderRadius?: number; }; const SelectCustom: React.FC = ({ @@ -33,6 +32,7 @@ const SelectCustom: React.FC = ({ value, required = false, // <-- default false onChange, + borderRadius = 8, }) => { const [modalVisible, setModalVisible] = useState(false); @@ -41,35 +41,41 @@ const SelectCustom: React.FC = ({ const hasError = required && value === null; // <-- check if empty and required return ( - + {label && ( - + {label} - {required && *} + {required && *} )} setModalVisible(true)} > - + {selectedItem?.label || placeholder} setModalVisible(false)} > - + String(item.value)} renderItem={({ item }) => ( { onChange(item.value); setModalVisible(false); @@ -85,68 +91,10 @@ const SelectCustom: React.FC = ({ {/* Optional Error Message */} {hasError && ( - Harap pilih salah satu + Harap pilih salah satu )} ); }; export default SelectCustom; - -const styles = StyleSheet.create({ - container: { - marginBottom: 16, - }, - label: { - fontSize: TEXT_SIZE_MEDIUM, - marginBottom: 4, - color: MainColor.white_gray, - fontWeight: "500", - }, - requiredIndicator: { - color: "red", - fontWeight: "bold", - }, - input: { - borderWidth: 1, - borderColor: MainColor.white_gray, - padding: 12, - borderRadius: 8, - minHeight: 48, - justifyContent: "center", - backgroundColor: MainColor.white, - }, - inputError: { - borderColor: "red", - }, - text: { - fontSize: TEXT_SIZE_MEDIUM, - }, - placeholder: { - fontSize: TEXT_SIZE_MEDIUM, - color: MainColor.placeholder, - }, - modalOverlay: { - flex: 1, - backgroundColor: "rgba(0,0,0,0.3)", - justifyContent: "center", - alignItems: "center", - }, - modalContent: { - width: "80%", - maxHeight: 300, - backgroundColor: "white", - borderRadius: 8, - overflow: "hidden", - }, - option: { - padding: 16, - borderBottomWidth: 1, - borderBottomColor: MainColor.white_gray, - }, - errorMessage: { - marginTop: 4, - fontSize: 12, - color: "red", - }, -}); diff --git a/components/TextArea/TextAreaCustom.tsx b/components/TextArea/TextAreaCustom.tsx index 794fa20..cc3cb8f 100644 --- a/components/TextArea/TextAreaCustom.tsx +++ b/components/TextArea/TextAreaCustom.tsx @@ -1,3 +1,4 @@ +import { GStyles } from "@/styles/global-styles"; import React, { useEffect, useState } from "react"; import { TextInput as RNTextInput, @@ -6,7 +7,6 @@ import { View, ViewStyle, } from "react-native"; -import { GStyles } from "@/styles/global-styles"; type IconType = React.ReactNode | string; @@ -70,31 +70,31 @@ const TextAreaCustom: React.FC = ({ const renderIcon = (icon: IconType) => { if (!icon) return null; return typeof icon === "string" ? ( - {icon} + {icon} ) : ( icon ); }; return ( - + {label && ( - + {label} - {required && *} + {required && *} )} {iconLeft && ( - {renderIcon(iconLeft)} + {renderIcon(iconLeft)} )} = ({ multiline numberOfLines={numberOfLines} style={[ - GStyles.inputInput, + GStyles.inputText, GStyles.textAreaInput, { color: fontColor }, ]} @@ -113,7 +113,7 @@ const TextAreaCustom: React.FC = ({ /> {iconRight && ( - {renderIcon(iconRight)} + {renderIcon(iconRight)} )} @@ -127,7 +127,7 @@ const TextAreaCustom: React.FC = ({ }} > {hasError ? ( - {error} + {error} ) : null} {showCount && maxLength ? ( diff --git a/components/TextInput/TextInputCustom.tsx b/components/TextInput/TextInputCustom.tsx index 0ff2789..bd1087a 100644 --- a/components/TextInput/TextInputCustom.tsx +++ b/components/TextInput/TextInputCustom.tsx @@ -50,7 +50,7 @@ export const TextInputCustom = ({ const renderIcon = (icon: IconType) => { if (!icon) return null; return typeof icon === "string" ? ( - {icon} + {icon} ) : ( icon ); @@ -74,27 +74,27 @@ export const TextInputCustom = ({ }; return ( - + {label && ( - + {label} - {required && *} + {required && *} )} {iconLeft && ( - {renderIcon(iconLeft)} + {renderIcon(iconLeft)} )} setIsPasswordVisible((prev) => !prev)} - style={GStyles.iconInput} + style={GStyles.inputIcon} > )} {iconRight && ( - {renderIcon(iconRight)} + {renderIcon(iconRight)} )} {/* Prioritaskan error eksternal */} {externalError || internalError ? ( - + {externalError || internalError} ) : null} diff --git a/styles/global-styles.ts b/styles/global-styles.ts index 8eabd9d..92c5e30 100644 --- a/styles/global-styles.ts +++ b/styles/global-styles.ts @@ -155,27 +155,27 @@ export const GStyles = StyleSheet.create({ }, // =============== BUTTON =============== // - // =============== TEXT INPUT =============== // + // =============== TEXT INPUT , TEXT AREA , SELECT =============== // // Container utama input (View luar) - containerAreaInput: { + inputContainerArea: { marginBottom: 16, }, // Label di atas input - labelInput: { + inputLabel: { fontSize: TEXT_SIZE_MEDIUM, - marginBottom: 6, + marginBottom: 4, fontWeight: "500", color: MainColor.white_gray, }, // Tanda bintang merah untuk required - requiredInput: { + inputRequired: { color: "red", }, // Pesan error di bawah input - errorMessageInput: { + inputErrorMessage: { marginTop: 4, fontSize: TEXT_SIZE_SMALL, color: MainColor.red, @@ -189,49 +189,78 @@ export const GStyles = StyleSheet.create({ // Wrapper input (View pembungkus TextInput) inputContainerInput: { - flexDirection: "row", - alignItems: "center", borderWidth: 1, borderColor: MainColor.white_gray, backgroundColor: MainColor.white, + flexDirection: "row", + alignItems: "center", paddingHorizontal: 10, height: 50, }, // Style saat disabled - disabledInput: { + inputDisabled: { backgroundColor: "#f9f9f9", borderColor: "#e0e0e0", }, // Input utama (TextInput) - inputInput: { + inputText: { flex: 1, fontSize: TEXT_SIZE_MEDIUM, paddingVertical: 0, }, // Ikon di kiri/kanan - iconInput: { + inputIcon: { marginHorizontal: 4, justifyContent: "center", }, // Teks ikon jika berupa string - iconTextInput: { + inputIconText: { fontSize: TEXT_SIZE_LARGE, color: "#000", }, // Border merah jika ada error - errorBorderInput: { + inputErrorBorder: { borderColor: "red", + borderWidth: 1, }, - // Untuk TextArea tambahan + // Placeholder input + inputPlaceholder: { + fontSize: TEXT_SIZE_MEDIUM, + color: MainColor.placeholder, + }, + + // TextArea untuk tambahan textAreaInput: { textAlignVertical: "top", padding: 5, height: undefined, // biar multiline bebas tinggi }, + + // Select + selectModalOverlay: { + flex: 1, + backgroundColor: "rgba(0,0,0,0.3)", + justifyContent: "center", + alignItems: "center", + }, + selectModalContent: { + width: "80%", + maxHeight: 300, + backgroundColor: "white", + borderRadius: 8, + overflow: "hidden", + }, + selectOption: { + padding: 16, + borderBottomWidth: 1, + borderBottomColor: MainColor.white_gray, + }, + + // =============== TEXT INPUT , TEXT AREA , SELECT =============== // });