fix
deskripsi: - perubahan pada component: ButtonCustom, TextArea, TextInput - fix style global - tambhan color pada palet
This commit is contained in:
@@ -2,13 +2,12 @@
|
||||
|
||||
import React from "react";
|
||||
import { StyleProp, Text, TouchableOpacity, ViewStyle } from "react-native";
|
||||
import buttonStyles from "./buttonCustomStyles";
|
||||
import { radiusMap } from "@/constants/radius-value";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { stylesButton } from "./buttonCustomStyles";
|
||||
|
||||
// Import radiusMap
|
||||
|
||||
|
||||
// Definisi type untuk radius
|
||||
type RadiusType = keyof typeof radiusMap | number;
|
||||
|
||||
@@ -30,30 +29,29 @@ const ButtonCustom: React.FC<ButtonProps> = ({
|
||||
title = "Button",
|
||||
backgroundColor = MainColor.yellow,
|
||||
textColor = MainColor.black,
|
||||
radius = "full", // default md
|
||||
radius = 50, // default md
|
||||
disabled = false,
|
||||
iconLeft,
|
||||
style,
|
||||
}) => {
|
||||
const borderRadius =
|
||||
typeof radius === "number" ? radius : radiusMap[radius ?? "md"]; // fallback ke 'md'
|
||||
|
||||
const styles = buttonStyles({
|
||||
backgroundColor,
|
||||
textColor,
|
||||
borderRadius,
|
||||
});
|
||||
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={[styles.button, disabled && styles.disabled, style]}
|
||||
style={[
|
||||
stylesButton.button,
|
||||
disabled && stylesButton.disabled,
|
||||
style,
|
||||
{ borderRadius: radius },
|
||||
{ backgroundColor },
|
||||
]}
|
||||
onPress={onPress}
|
||||
disabled={disabled}
|
||||
activeOpacity={0.8}
|
||||
>
|
||||
{/* Render icon jika tersedia */}
|
||||
{iconLeft && iconLeft}
|
||||
<Text style={styles.buttonText}>{children || title}</Text>
|
||||
<Text style={[stylesButton.buttonText, { color: textColor }]}>
|
||||
{children || title}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { GStyles } from "@/styles/global-styles";
|
||||
import { Feather } from "@expo/vector-icons";
|
||||
import React from "react";
|
||||
import ButtonCustom from "./ButtonCustom";
|
||||
|
||||
interface ButtonUploadProps {
|
||||
title?: string;
|
||||
onPress: () => void;
|
||||
}
|
||||
export default function ButtonUpload({ onPress, title = "Upload" }: ButtonUploadProps) {
|
||||
return (
|
||||
<ButtonCustom
|
||||
onPress={onPress}
|
||||
iconLeft={<Feather name="upload" size={20} color={MainColor.black} />}
|
||||
style={GStyles.buttonCentered50Percent}
|
||||
>
|
||||
{title}
|
||||
</ButtonCustom>
|
||||
);
|
||||
}
|
||||
@@ -4,24 +4,18 @@ import { MainColor } from "@/constants/color-palet";
|
||||
import { TEXT_SIZE_MEDIUM } from "@/constants/constans-value";
|
||||
import { StyleSheet } from "react-native";
|
||||
|
||||
export default function buttonStyles({
|
||||
backgroundColor = "#007AFF",
|
||||
textColor = "#FFFFFF",
|
||||
borderRadius = 8,
|
||||
}) {
|
||||
return StyleSheet.create({
|
||||
export const stylesButton = StyleSheet.create({
|
||||
button: {
|
||||
backgroundColor,
|
||||
backgroundColor: MainColor.yellow,
|
||||
paddingVertical: 12,
|
||||
paddingHorizontal: 20,
|
||||
borderRadius,
|
||||
flexDirection: "row", // 👈 Tambahkan baris ini
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
gap: 8,
|
||||
},
|
||||
buttonText: {
|
||||
color: textColor,
|
||||
color: MainColor.black,
|
||||
fontSize: TEXT_SIZE_MEDIUM,
|
||||
fontWeight: "600",
|
||||
},
|
||||
@@ -29,4 +23,3 @@ export default function buttonStyles({
|
||||
backgroundColor: MainColor.disabled,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
Pressable,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View
|
||||
View,
|
||||
} from "react-native";
|
||||
|
||||
type SelectItem = {
|
||||
@@ -21,6 +21,7 @@ type SelectProps = {
|
||||
data: SelectItem[];
|
||||
value?: string | number | null;
|
||||
required?: boolean; // <-- new prop
|
||||
disabled?: boolean; // <-- tambahkan prop disabled
|
||||
onChange: (value: string | number) => void;
|
||||
borderRadius?: number;
|
||||
};
|
||||
@@ -31,6 +32,7 @@ const SelectCustom: React.FC<SelectProps> = ({
|
||||
data,
|
||||
value,
|
||||
required = false, // <-- default false
|
||||
disabled = false, // <-- default false
|
||||
onChange,
|
||||
borderRadius = 8,
|
||||
}) => {
|
||||
@@ -51,13 +53,22 @@ const SelectCustom: React.FC<SelectProps> = ({
|
||||
<Pressable
|
||||
style={[
|
||||
{ borderRadius },
|
||||
GStyles.inputContainerInput,
|
||||
hasError ? GStyles.inputErrorBorder : null,
|
||||
GStyles.inputContainerInput,
|
||||
disabled && GStyles.disabledBox,
|
||||
]} // <-- add error style
|
||||
onPress={() => setModalVisible(true)}
|
||||
onPress={() => !disabled && setModalVisible(true)}
|
||||
>
|
||||
<Text
|
||||
style={selectedItem ? GStyles.inputText : GStyles.inputPlaceholder}
|
||||
style={
|
||||
selectedItem
|
||||
? disabled
|
||||
? GStyles.inputTextDisabled
|
||||
: GStyles.inputText
|
||||
: disabled
|
||||
? GStyles.inputPlaceholderDisabled
|
||||
: GStyles.inputPlaceholder
|
||||
}
|
||||
>
|
||||
{selectedItem?.label || placeholder}
|
||||
</Text>
|
||||
|
||||
@@ -87,7 +87,7 @@ const TextAreaCustom: React.FC<TextAreaCustomProps> = ({
|
||||
<View
|
||||
style={[
|
||||
GStyles.inputContainerInput,
|
||||
disabled && GStyles.inputDisabled,
|
||||
disabled && GStyles.disabledBox,
|
||||
hasError ? GStyles.inputErrorBorder : {},
|
||||
{ borderRadius },
|
||||
style,
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
ViewStyle,
|
||||
} from "react-native";
|
||||
|
||||
|
||||
type IconType = React.ReactNode | string;
|
||||
|
||||
type Props = {
|
||||
@@ -83,18 +82,27 @@ const TextInputCustom = ({
|
||||
)}
|
||||
<View
|
||||
style={[
|
||||
GStyles.inputContainerInput,
|
||||
disabled && GStyles.inputDisabled,
|
||||
style,
|
||||
{ borderRadius },
|
||||
externalError || internalError ? GStyles.inputErrorBorder : null,
|
||||
style,
|
||||
GStyles.inputContainerInput,
|
||||
disabled && GStyles.disabledBox,
|
||||
]}
|
||||
>
|
||||
{iconLeft && (
|
||||
<View style={GStyles.inputIcon}>{renderIcon(iconLeft)}</View>
|
||||
)}
|
||||
<RNTextInput
|
||||
style={[GStyles.inputText, { color: fontColor }]}
|
||||
style={[
|
||||
GStyles.inputText,
|
||||
{ color: fontColor },
|
||||
disabled
|
||||
? GStyles.inputTextDisabled // <-- custom style untuk text saat disabled
|
||||
: GStyles.inputText,
|
||||
disabled
|
||||
? GStyles.inputPlaceholderDisabled // <-- placeholder saat disabled
|
||||
: GStyles.inputPlaceholder,
|
||||
]}
|
||||
editable={!disabled}
|
||||
secureTextEntry={secureTextEntry && !isPasswordVisible}
|
||||
keyboardType={keyboardType}
|
||||
|
||||
@@ -4,7 +4,6 @@ import AlertCustom from "./Alert/AlertCustom";
|
||||
import LeftButtonCustom from "./Button/BackButton";
|
||||
import ButtonCenteredOnly from "./Button/ButtonCenteredOnly";
|
||||
import ButtonCustom from "./Button/ButtonCustom";
|
||||
import ButtonUpload from "./Button/ButtonUpload";
|
||||
// Drawer
|
||||
import DrawerCustom from "./Drawer/DrawerCustom";
|
||||
import MenuDrawerDynamicGrid from "./Drawer/MenuDrawerDynamicGird";
|
||||
@@ -38,12 +37,11 @@ export {
|
||||
AvatarCustom,
|
||||
LandscapeFrameUploaded,
|
||||
// Button
|
||||
ButtonCustom,
|
||||
LeftButtonCustom as BackButton,
|
||||
ButtonCenteredOnly,
|
||||
// Box
|
||||
BaseBox,
|
||||
ButtonCenteredOnly,
|
||||
ButtonCustom,
|
||||
ButtonUpload,
|
||||
BoxButtonOnFooter,
|
||||
InformationBox,
|
||||
// Drawer
|
||||
|
||||
Reference in New Issue
Block a user