Files
hipmi-mobile/components/Drawer/MenuDrawerDynamicGird.tsx
Bagasbanuna02 bcc0e02581 Admin
Add:
- screens/Admin/
- admin/notification/

Component
Add:
-  components/_ShareComponent/GridSectionView.tsx

### No Issue
2025-08-06 15:02:47 +08:00

82 lines
2.1 KiB
TypeScript

import { AccentColor, MainColor } from "@/constants/color-palet";
import { TEXT_SIZE_SMALL } from "@/constants/constans-value";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { IMenuDrawerItem } from "../_Interface/types";
import { Href } from "expo-router";
type IMenuDrawerItemProps = {
icon: React.ReactNode;
label: string;
value?: string;
path?: Href;
color?: string;
}
interface MenuDrawerDynamicGridProps {
data: IMenuDrawerItemProps[];
columns?: number;
onPressItem?: (item: IMenuDrawerItemProps) => void;
}
const MenuDrawerDynamicGrid = ({ data, columns = 4, onPressItem }: MenuDrawerDynamicGridProps) => {
const numColumns = columns;
return (
<View style={styles.container}>
{data.map((item: IMenuDrawerItemProps, index: any) => (
<TouchableOpacity
key={index}
style={[styles.itemContainer, { flexBasis: `${100 / numColumns}%` }]}
onPress={() => onPressItem?.(item)}
>
<View
style={[
styles.iconContainer,
{ backgroundColor: item.color || AccentColor.blue },
]}
>
{item.icon}
{/* <Ionicons
name={item.icon}
size={ICON_SIZE_MEDIUM}
color={item.color || MainColor.white_gray}
/> */}
</View>
<Text
style={[styles.label, { color: item.color || AccentColor.white }]}
>
{item.label}
</Text>
</TouchableOpacity>
))}
</View>
);
};
export default MenuDrawerDynamicGrid;
const styles = StyleSheet.create({
container: {
flexDirection: "row",
flexWrap: "wrap",
padding: 0,
},
itemContainer: {
padding: 10,
alignItems: "center",
},
iconContainer: {
width: 56,
height: 56,
borderRadius: 28,
backgroundColor: AccentColor.blue,
justifyContent: "center",
alignItems: "center",
},
label: {
marginTop: 10,
fontSize: TEXT_SIZE_SMALL,
textAlign: "center",
color: MainColor.white_gray,
},
});