feature & fix
deskripsi: feature : - forumku fix : - forum index - Back button : bisa custom icon - Button custom : di tambah href # No Issue
This commit is contained in:
@@ -3,19 +3,33 @@ import { Ionicons } from "@expo/vector-icons";
|
||||
import { Href, router } from "expo-router";
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param path - path to navigate to ?
|
||||
* @default router.back()
|
||||
* @returns if path : router.replace(path) else router.back()
|
||||
*/
|
||||
const LeftButtonCustom = ({path}: {path?: Href}) => {
|
||||
const LeftButtonCustom = ({
|
||||
path,
|
||||
icon = "arrow-back",
|
||||
iconCustom,
|
||||
}: {
|
||||
path?: Href;
|
||||
icon?: React.ReactNode | any;
|
||||
iconCustom?: React.ReactNode;
|
||||
}) => {
|
||||
return (
|
||||
<Ionicons
|
||||
name="arrow-back"
|
||||
size={20}
|
||||
color={MainColor.yellow}
|
||||
onPress={() => path ? router.replace(path) : router.back()}
|
||||
/>
|
||||
<>
|
||||
{iconCustom ? (
|
||||
iconCustom
|
||||
) : (
|
||||
<Ionicons
|
||||
name={icon}
|
||||
size={20}
|
||||
color={MainColor.yellow}
|
||||
onPress={() => (path ? router.replace(path) : router.back())}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { StyleProp, Text, TouchableOpacity, ViewStyle } from "react-native";
|
||||
import { radiusMap } from "@/constants/radius-value";
|
||||
import { MainColor } from "@/constants/color-palet";
|
||||
import { stylesButton } from "./buttonCustomStyles";
|
||||
import { Href, router } from "expo-router";
|
||||
|
||||
// Import radiusMap
|
||||
|
||||
@@ -13,6 +14,7 @@ type RadiusType = keyof typeof radiusMap | number;
|
||||
|
||||
interface ButtonProps {
|
||||
children?: React.ReactNode;
|
||||
href?: Href;
|
||||
onPress?: () => void;
|
||||
title?: string;
|
||||
backgroundColor?: string;
|
||||
@@ -25,6 +27,7 @@ interface ButtonProps {
|
||||
|
||||
const ButtonCustom: React.FC<ButtonProps> = ({
|
||||
children,
|
||||
href,
|
||||
onPress,
|
||||
title = "Button",
|
||||
backgroundColor = MainColor.yellow,
|
||||
@@ -44,7 +47,13 @@ const ButtonCustom: React.FC<ButtonProps> = ({
|
||||
: { backgroundColor },
|
||||
style,
|
||||
]}
|
||||
onPress={onPress}
|
||||
onPress={() => {
|
||||
if (href) {
|
||||
router.push(href);
|
||||
} else {
|
||||
onPress?.();
|
||||
}
|
||||
}}
|
||||
disabled={disabled}
|
||||
activeOpacity={0.8}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user