mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 00:24:53 +00:00
addGrocery dialog
This commit is contained in:
90
components/pages/grocery/AddGroceryItem.tsx
Normal file
90
components/pages/grocery/AddGroceryItem.tsx
Normal file
@ -0,0 +1,90 @@
|
||||
import { StyleSheet } from "react-native";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Colors,
|
||||
Dialog,
|
||||
Drawer,
|
||||
Text,
|
||||
View,
|
||||
PanningProvider,
|
||||
} from "react-native-ui-lib";
|
||||
interface AddGroceryItemProps {
|
||||
visible: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
const AddGroceryItem = () => {
|
||||
const [visible, setVisible] = useState<boolean>(false);
|
||||
|
||||
const handleShowDialog = () => {
|
||||
setVisible(true);
|
||||
};
|
||||
const handleHideDialog = () => {
|
||||
setVisible(false);
|
||||
};
|
||||
const addGroceryDialog = (
|
||||
<Dialog
|
||||
visible={visible}
|
||||
onDismiss={handleHideDialog}
|
||||
panDirection={PanningProvider.Directions.DOWN}
|
||||
containerStyle={{ borderRadius: 12, backgroundColor: "white" }}
|
||||
>
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.title}>New Grocery</Text>
|
||||
<View style={styles.divider} />
|
||||
<View style={styles.inner}>
|
||||
<Text>Category</Text>
|
||||
</View>
|
||||
</View>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Button
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: -680,
|
||||
right: 20,
|
||||
height: 60,
|
||||
borderRadius: 30,
|
||||
backgroundColor: "#19ad61",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
color="white"
|
||||
label="Create new"
|
||||
enableShadow
|
||||
onPress={() => setVisible(true)}
|
||||
/>
|
||||
{addGroceryDialog}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddGroceryItem;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
paddingVertical: 10,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "space-between",
|
||||
},
|
||||
inner: {
|
||||
paddingHorizontal: 20,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
fontWeight: "400",
|
||||
textAlign: "center",
|
||||
},
|
||||
divider: {
|
||||
width: "100%",
|
||||
height: 1,
|
||||
backgroundColor: "#E0E0E0",
|
||||
marginVertical: 10,
|
||||
},
|
||||
});
|
||||
@ -4,6 +4,7 @@ import { View, Text, ListItem, Button } from "react-native-ui-lib";
|
||||
import MaterialCommunityIcons from "@expo/vector-icons/MaterialCommunityIcons";
|
||||
import { ProfileType, useAuthContext } from "@/contexts/AuthContext";
|
||||
import AntDesign from "@expo/vector-icons/AntDesign";
|
||||
import AddGroceryItem from "./AddGroceryItem";
|
||||
|
||||
export interface IGrocery {
|
||||
title: String;
|
||||
@ -26,8 +27,8 @@ export enum GroceryCategory {
|
||||
Frozen = "Frozen",
|
||||
}
|
||||
|
||||
type MaterialIconNames = keyof typeof MaterialCommunityIcons.glyphMap;
|
||||
const iconMapping: { [key in GroceryCategory]: MaterialIconNames } = {
|
||||
type MaterialIconNames = keyof typeof MaterialCommunityIcons.glyphMap;
|
||||
const iconMapping: { [key in GroceryCategory]: MaterialIconNames } = { //за сад се иконице за категорију бирају одавде
|
||||
[GroceryCategory.Fruit]: "food-apple",
|
||||
[GroceryCategory.Dairy]: "cheese",
|
||||
[GroceryCategory.Vegetables]: "carrot",
|
||||
@ -68,7 +69,7 @@ const GroceryList = () => {
|
||||
bought: false,
|
||||
},
|
||||
]);
|
||||
const { user, profileType } = useAuthContext();
|
||||
const { profileType } = useAuthContext();
|
||||
const renderItem = ({ item }: { item: IGrocery }) => (
|
||||
<ListItem backgroundColor="white">
|
||||
<ListItem.Part left containerStyle={{ flex: 1, paddingStart: 15 }}>
|
||||
@ -136,7 +137,7 @@ const GroceryList = () => {
|
||||
<FlatList
|
||||
data={groceries}
|
||||
renderItem={renderItem}
|
||||
keyExtractor={(item) => item.category.toString()}
|
||||
keyExtractor={(item) => item.title.toString()}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user