Compare commits
13 Commits
authentica
...
wishlistIn
| Author | SHA1 | Date | |
|---|---|---|---|
| 3bd3b9b70d | |||
| 35efcbe3a8 | |||
| d3b70cd842 | |||
| c7df0f1603 | |||
| b8a0d25c09 | |||
| 35a46a9396 | |||
| 27f3b8cf5c | |||
| f05d5b7500 | |||
| 0bae3bf212 | |||
| d6fd6a225b | |||
| 3af1e72c06 | |||
| 017b04116d | |||
| eca62c8b45 |
@@ -81,14 +81,14 @@ export async function getAllImagesByNoticeId(noticeId) {
|
|||||||
`${API_URL}/images/get/${imageName}`
|
`${API_URL}/images/get/${imageName}`
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(`Pobrano ${imageUrls.length} zdjęć dla ogłoszenia o id: ${noticeId}`);
|
// console.log(`Pobrano ${imageUrls.length} zdjęć dla ogłoszenia o id: ${noticeId}`);
|
||||||
return imageUrls;
|
return imageUrls;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Brak zdjęć dla ogłoszenia o id: ${noticeId}`);
|
// console.log(`Brak zdjęć dla ogłoszenia o id: ${noticeId}`);
|
||||||
return ["https://http.cat/404.jpg"];
|
return ["https://http.cat/404.jpg"];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`Błąd podczas pobierania listy zdjęć dla ogłoszenia o id: ${noticeId}`, err);
|
// console.log(`Błąd podczas pobierania listy zdjęć dla ogłoszenia o id: ${noticeId}`, err);
|
||||||
return ["https://http.cat/404.jpg"];
|
return ["https://http.cat/404.jpg"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
ArtisanConnect/api/wishlist.jsx
Normal file
29
ArtisanConnect/api/wishlist.jsx
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
// import FormData from 'form-data'
|
||||||
|
|
||||||
|
const API_URL = "https://testowe.zikor.pl/api/v1/wishlist";
|
||||||
|
|
||||||
|
export async function toggleNoticeStatus(noticeId) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(`${API_URL}/toggle/${noticeId}`, null, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error toggling wishlist item:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getWishlist() {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(`${API_URL}/`);
|
||||||
|
console.log("Wishlist response:", response.data);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching wishlist:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -51,13 +51,13 @@ export default function Login() {
|
|||||||
<VStack className="pb-4" space="xs">
|
<VStack className="pb-4" space="xs">
|
||||||
<Heading className="leading-[30px]">Logowanie</Heading>
|
<Heading className="leading-[30px]">Logowanie</Heading>
|
||||||
<Box className="flex flex-row">
|
<Box className="flex flex-row">
|
||||||
<Link href="/registration" asChild>
|
{/* <Link href="/registration" asChild> */}
|
||||||
<Button variant="link" size="sm" className="p-0">
|
<Button variant="link" size="sm" className="p-0" onPress={() => router.replace("/registration")}>
|
||||||
<ButtonText style={styles.signupbutton}>Nie masz jeszcze konta? Załóz je
|
<ButtonText style={styles.signupbutton}>Nie masz jeszcze konta? Załóz je
|
||||||
tutaj!</ButtonText>
|
tutaj!</ButtonText>
|
||||||
<ButtonIcon className="mr-1" size="md" as={ArrowRightIcon}/>
|
<ButtonIcon className="mr-1" size="md" as={ArrowRightIcon}/>
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
{/* </Link> */}
|
||||||
</Box>
|
</Box>
|
||||||
</VStack>
|
</VStack>
|
||||||
<VStack space="xl" className="py-2">
|
<VStack space="xl" className="py-2">
|
||||||
@@ -48,21 +48,10 @@ export default function TabLayout() {
|
|||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Tabs.Screen
|
|
||||||
name="login"
|
|
||||||
options={{
|
|
||||||
headerShown: false, // Ukryj nagłówek dla Drawer
|
|
||||||
title: "Authentication",
|
|
||||||
tabBarLabel: "Authentication",
|
|
||||||
tabBarIcon: ({color, size}) => (
|
|
||||||
<Ionicons name="key" size={size} color={color}/>
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Tabs.Screen
|
<Tabs.Screen
|
||||||
name="dashboard"
|
name="dashboard"
|
||||||
options={{
|
options={{
|
||||||
headerShown: false, // Ukryj nagłówek dla Drawer
|
headerShown: false,
|
||||||
title: "Konto",
|
title: "Konto",
|
||||||
tabBarLabel: "Konto",
|
tabBarLabel: "Konto",
|
||||||
tabBarIcon: ({color, size}) => (
|
tabBarIcon: ({color, size}) => (
|
||||||
|
|||||||
@@ -1,22 +1,45 @@
|
|||||||
import { View, Text } from "react-native";
|
import { ScrollView, View } from "react-native";
|
||||||
import { Link } from "expo-router";
|
import { useNoticesStore } from '@/store/noticesStore';
|
||||||
import { Button, ButtonText } from "@/components/ui/button";
|
import { CategorySection } from "@/components/CategorySection";
|
||||||
|
import { NoticeSection } from "@/components/NoticeSection";
|
||||||
|
import { UserSection } from "@/components/UserSection";
|
||||||
|
import { SearchSection } from "@/components/SearchSection";
|
||||||
|
import { FlatList } from 'react-native';
|
||||||
|
import { useAuthStore } from "@/store/authStore";
|
||||||
|
import { useRouter } from "expo-router";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
const token = useAuthStore((state) => state.token);
|
||||||
|
const router = useRouter();
|
||||||
|
const [isReady, setIsReady] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setIsReady(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isReady && !token) {
|
||||||
|
router.replace("/login");
|
||||||
|
}
|
||||||
|
}, [isReady, token, router]);
|
||||||
|
|
||||||
|
const notices = useNoticesStore((state) => state.notices);
|
||||||
|
const latestNotices = [...notices]
|
||||||
|
.sort((a, b) => new Date(b.publishDate) - new Date(a.publishDate))
|
||||||
|
.slice(0, 6);
|
||||||
|
const recomendedNotices = [...notices]
|
||||||
|
.sort(() => Math.random() - 0.5)
|
||||||
|
.slice(0, 6);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<Text>Home</Text>
|
<SearchSection/>
|
||||||
<Link href="/notices" asChild>
|
<ScrollView showsVerticalScrollIndicator={false} className='m-2'>
|
||||||
<Button>
|
<CategorySection title="Polecane kategorie" notices={notices} />
|
||||||
<ButtonText>Ogłoszenia</ButtonText>
|
<NoticeSection title="Najnowsze ogłoszenia" notices={latestNotices} ctaLink="/notices?sort=latest"/>
|
||||||
</Button>
|
<UserSection title="Popularni sprzedawcy" notices={notices} />
|
||||||
</Link>
|
<NoticeSection title="Proponowane ogłoszenia" notices={recomendedNotices} ctaLink="/notices"/>
|
||||||
|
</ScrollView>
|
||||||
<Link href="/wishlist" asChild>
|
</View>
|
||||||
<Button variant="outline" className="mt-2">
|
|
||||||
<ButtonText>Ulubione</ButtonText>
|
|
||||||
</Button>
|
|
||||||
</Link>
|
|
||||||
</View>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,144 @@
|
|||||||
import {FlatList, Text, ActivityIndicator, RefreshControl} from "react-native";
|
import { FlatList, Text, ActivityIndicator, RefreshControl, Dimensions } from "react-native";
|
||||||
import {useState, useEffect} from "react";
|
import { useState, useEffect } from "react";
|
||||||
import {useNoticesStore} from "@/store/noticesStore";
|
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import {NoticeCard} from "@/components/NoticeCard";
|
import { useNoticesStore } from "@/store/noticesStore";
|
||||||
|
import { NoticeCard } from "@/components/NoticeCard";
|
||||||
|
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||||
|
import { Box } from "@/components/ui/box";
|
||||||
|
import { Button, ButtonText } from "@/components/ui/button";
|
||||||
|
import { ChevronDownIcon } from "@/components/ui/icon";
|
||||||
|
import { listCategories } from "@/api/categories";
|
||||||
|
import { FormControl, FormControlLabel } from "@/components/ui/form-control";
|
||||||
|
import { Input, InputField } from "@/components/ui/input";
|
||||||
|
import { HStack } from "@/components/ui/hstack";
|
||||||
|
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
||||||
|
import { KeyboardAvoidingView, Platform } from "react-native";
|
||||||
|
import {
|
||||||
|
Actionsheet,
|
||||||
|
ActionsheetContent,
|
||||||
|
ActionsheetItem,
|
||||||
|
ActionsheetItemText,
|
||||||
|
ActionsheetDragIndicator,
|
||||||
|
ActionsheetDragIndicatorWrapper,
|
||||||
|
ActionsheetBackdrop,
|
||||||
|
} from "@/components/ui/actionsheet";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectInput,
|
||||||
|
SelectIcon,
|
||||||
|
SelectPortal,
|
||||||
|
SelectBackdrop,
|
||||||
|
SelectContent,
|
||||||
|
SelectDragIndicator,
|
||||||
|
SelectDragIndicatorWrapper,
|
||||||
|
SelectItem,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
import { ScrollView } from "react-native-gesture-handler";
|
||||||
|
|
||||||
export default function Notices() {
|
export default function Notices() {
|
||||||
const {notices, fetchNotices} = useNoticesStore();
|
// Hooks
|
||||||
|
const { notices, fetchNotices } = useNoticesStore();
|
||||||
const [refreshing, setRefreshing] = useState(false);
|
const [refreshing, setRefreshing] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
const [showActionsheet, setShowActionsheet] = useState(false);
|
||||||
|
const [showSortSheet, setShowSortSheet] = useState(false);
|
||||||
|
const [categories, setCategories] = useState([]);
|
||||||
|
const [filteredNotices, setFilteredNotices] = useState([]);
|
||||||
|
const params = useLocalSearchParams();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchSelectItems = async () => {
|
||||||
|
try {
|
||||||
|
const data = await listCategories();
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
setCategories(data);
|
||||||
|
} else {
|
||||||
|
console.error('listCategories did not return an array:', data);
|
||||||
|
setError(new Error('Invalid categories data'));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching select items:', error);
|
||||||
|
setError(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchSelectItems();
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let result = notices;
|
||||||
|
|
||||||
|
if (params.category) {
|
||||||
|
result = result.filter(notice => notice.category === params.category);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.sort) {
|
||||||
|
if( params.sort == "latest"){
|
||||||
|
result = [...result].sort(
|
||||||
|
(a, b) => new Date(b.publishDate) - new Date(a.publishDate)
|
||||||
|
);
|
||||||
|
}else if (params.sort == "oldest") {
|
||||||
|
result = [...result].sort(
|
||||||
|
(a, b) => new Date(a.publishDate) - new Date(b.publishDate)
|
||||||
|
);
|
||||||
|
}else if (params.sort == "cheapest") {
|
||||||
|
result = [...result].sort((a, b) => {
|
||||||
|
const priceA = parseFloat(a.price);
|
||||||
|
const priceB = parseFloat(b.price);
|
||||||
|
return isNaN(priceA) || isNaN(priceB) ? 0 : priceA - priceB;
|
||||||
|
});
|
||||||
|
}else if (params.sort == "expensive") {
|
||||||
|
result = [...result].sort((a, b) => {
|
||||||
|
const priceA = parseFloat(a.price);
|
||||||
|
const priceB = parseFloat(b.price);
|
||||||
|
return isNaN(priceA) || isNaN(priceB) ? 0 : priceB - priceA;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.priceFrom) {
|
||||||
|
result = result.filter(notice => {
|
||||||
|
const price = parseFloat(notice.price);
|
||||||
|
const priceFrom = parseFloat(params.priceFrom);
|
||||||
|
return !isNaN(price) && price >= priceFrom;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.priceTo) {
|
||||||
|
result = result.filter(notice => {
|
||||||
|
const price = parseFloat(notice.price);
|
||||||
|
const priceTo = parseFloat(params.priceTo);
|
||||||
|
return !isNaN(price) && price <= priceTo;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (params.search) {
|
||||||
|
const searchTerm = params.search.toLowerCase();
|
||||||
|
result = result.filter(notice => {
|
||||||
|
return notice.title.toLowerCase().includes(searchTerm);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setFilteredNotices(result);
|
||||||
|
}, [notices,
|
||||||
|
params.category,
|
||||||
|
params.sort,
|
||||||
|
params.priceFrom,
|
||||||
|
params.priceTo,
|
||||||
|
params.search]);
|
||||||
|
|
||||||
|
|
||||||
|
let filterActive = !!params.category || !!params.sort || !!params.priceFrom || !!params.priceTo || !!params.search;
|
||||||
|
|
||||||
|
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
@@ -25,6 +151,37 @@ export default function Notices() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCategorySelect = (value) => {
|
||||||
|
router.replace({
|
||||||
|
pathname: "/notices",
|
||||||
|
params: { ...params, category: value }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePriceFrom = (value) => {
|
||||||
|
router.replace({
|
||||||
|
pathname: "/notices",
|
||||||
|
params: { ...params, priceFrom: value }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlePriceTo = (value) => {
|
||||||
|
router.replace({
|
||||||
|
pathname: "/notices",
|
||||||
|
params: { ...params, priceTo: value }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClose = () => setShowActionsheet(false);
|
||||||
|
|
||||||
|
const handleSort = (value) => {
|
||||||
|
router.replace({
|
||||||
|
pathname: "/notices",
|
||||||
|
params: { ...params, sort: value }
|
||||||
|
});
|
||||||
|
setShowSortSheet(false);
|
||||||
|
}
|
||||||
|
|
||||||
const onRefresh = async () => {
|
const onRefresh = async () => {
|
||||||
setRefreshing(true);
|
setRefreshing(true);
|
||||||
try {
|
try {
|
||||||
@@ -37,29 +194,162 @@ export default function Notices() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (isLoading && !refreshing) {
|
if (isLoading && !refreshing) {
|
||||||
return <ActivityIndicator/>;
|
return <ActivityIndicator />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return <Text>Nie udało sie pobrać listy. {error.message}</Text>;
|
return <Text>Nie udało się pobrać listy. {error.message}</Text>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SCREEN_HEIGHT = Dimensions.get('window').height;
|
||||||
|
|
||||||
|
const selectedCategory = params.category && categories?.find(
|
||||||
|
(cat) => cat.value === params.category
|
||||||
|
) || null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FlatList
|
<>
|
||||||
key={2}
|
<Box style={{ flexDirection: "row", padding: 8, paddingTop: 16, paddingBottom: 16, backgroundColor: "white", alignItems: "center", justifyContent: "space-between" }}>
|
||||||
data={notices}
|
<Box style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
||||||
numColumns={2}
|
<Button variant="outline" onPress={() => setShowActionsheet(true)}>
|
||||||
columnContainerClassName="m-2"
|
<ButtonText>Filtruj</ButtonText>
|
||||||
columnWrapperClassName="gap-2 m-2"
|
<Ionicons name="filter-outline" size={20} color="black" />
|
||||||
renderItem={({item}) => <NoticeCard notice={item}/>}
|
</Button>
|
||||||
refreshControl={
|
<Button variant="outline" onPress={() => setShowSortSheet(true)}>
|
||||||
<RefreshControl
|
<Ionicons name="chevron-expand-outline" size={20} color="black" />
|
||||||
refreshing={refreshing}
|
</Button>
|
||||||
onRefresh={onRefresh}
|
</Box>
|
||||||
colors={["#3b82f6"]}
|
{filterActive && (
|
||||||
tintColor="#3b82f6"
|
<Button variant="link" onPress={() => router.replace("/notices")}>
|
||||||
/>
|
<ButtonText>Wyczyść</ButtonText>
|
||||||
}
|
</Button>
|
||||||
/>
|
)}
|
||||||
|
</Box>
|
||||||
|
<Actionsheet isOpen={showActionsheet} onClose={handleClose}>
|
||||||
|
<ActionsheetBackdrop />
|
||||||
|
<ActionsheetContent style={{ maxHeight: SCREEN_HEIGHT * 0.6, width: '100%' }} >
|
||||||
|
<KeyboardAwareScrollView
|
||||||
|
contentContainerStyle={{ flexGrow: 1, width: '100%' }}
|
||||||
|
enableOnAndroid={true}
|
||||||
|
extraScrollHeight={40}
|
||||||
|
>
|
||||||
|
<ActionsheetDragIndicatorWrapper>
|
||||||
|
<ActionsheetDragIndicator />
|
||||||
|
</ActionsheetDragIndicatorWrapper>
|
||||||
|
<Box className="mb-4" style={{ width: "100%" }}>
|
||||||
|
<HStack space="md" style={{ width: "100%" }}>
|
||||||
|
<FormControl
|
||||||
|
style={{ flex: 1 }}>
|
||||||
|
<Input>
|
||||||
|
<InputField
|
||||||
|
keyboardType="numeric"
|
||||||
|
placeholder="Od:"
|
||||||
|
value={params.priceFrom || ''}
|
||||||
|
onChangeText={handlePriceFrom}
|
||||||
|
/>
|
||||||
|
</Input>
|
||||||
|
</FormControl>
|
||||||
|
<FormControl
|
||||||
|
style={{ flex: 1 }}>
|
||||||
|
<Input>
|
||||||
|
<InputField
|
||||||
|
keyboardType="numeric"
|
||||||
|
placeholder="Do:"
|
||||||
|
value={params.priceTo || ''}
|
||||||
|
onChangeText={handlePriceTo}
|
||||||
|
/>
|
||||||
|
</Input>
|
||||||
|
</FormControl>
|
||||||
|
</HStack>
|
||||||
|
</Box>
|
||||||
|
<Box className="mb-4" style={{ flex: 1 }}>
|
||||||
|
<Select
|
||||||
|
style={{ flex: 1 }}
|
||||||
|
selectedValue={params.category || ''}
|
||||||
|
onValueChange={handleCategorySelect}
|
||||||
|
>
|
||||||
|
<SelectTrigger variant="outline" size="md">
|
||||||
|
<SelectInput
|
||||||
|
style={{ flex: 1 }}
|
||||||
|
placeholder="Wybierz kategorię"
|
||||||
|
value={selectedCategory ? selectedCategory.label : ""}
|
||||||
|
/>
|
||||||
|
<SelectIcon style={{ marginRight: 12 }} as={ChevronDownIcon} />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectPortal>
|
||||||
|
<SelectBackdrop />
|
||||||
|
<SelectContent
|
||||||
|
style={{ maxHeight: SCREEN_HEIGHT * 0.6}}
|
||||||
|
>
|
||||||
|
<SelectDragIndicatorWrapper>
|
||||||
|
<SelectDragIndicator />
|
||||||
|
</SelectDragIndicatorWrapper>
|
||||||
|
<FlatList
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
data={categories}
|
||||||
|
keyExtractor={(item) => item.value?.toString() || item.id?.toString() || Math.random().toString()}
|
||||||
|
renderItem={({ item }) => (
|
||||||
|
<SelectItem
|
||||||
|
label={item.label}
|
||||||
|
value={item.value}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</SelectContent>
|
||||||
|
</SelectPortal>
|
||||||
|
</Select>
|
||||||
|
</Box>
|
||||||
|
</KeyboardAwareScrollView>
|
||||||
|
</ActionsheetContent>
|
||||||
|
</Actionsheet>
|
||||||
|
<Actionsheet isOpen={showSortSheet} onClose={() => setShowSortSheet(false)}>
|
||||||
|
<ActionsheetBackdrop />
|
||||||
|
<ActionsheetContent>
|
||||||
|
<ActionsheetDragIndicatorWrapper>
|
||||||
|
<ActionsheetDragIndicator />
|
||||||
|
</ActionsheetDragIndicatorWrapper>
|
||||||
|
<ActionsheetItem
|
||||||
|
className={ !params.sort ? 'bg-gray-200' : ''}
|
||||||
|
onPress={() => handleSort()}>
|
||||||
|
<ActionsheetItemText>Trafność</ActionsheetItemText>
|
||||||
|
</ActionsheetItem>
|
||||||
|
<ActionsheetItem
|
||||||
|
className={ params.sort == 'latest' ? 'bg-gray-200' : ''}
|
||||||
|
onPress={() => handleSort('latest')}>
|
||||||
|
<ActionsheetItemText>Najnowsze</ActionsheetItemText>
|
||||||
|
</ActionsheetItem>
|
||||||
|
<ActionsheetItem
|
||||||
|
className={ params.sort == 'oldest' ? 'bg-gray-200' : ''}
|
||||||
|
onPress={() => handleSort('oldest')}>
|
||||||
|
<ActionsheetItemText>Najstarsze</ActionsheetItemText>
|
||||||
|
</ActionsheetItem>
|
||||||
|
<ActionsheetItem
|
||||||
|
className={ params.sort == 'cheapest' ? 'bg-gray-200' : ''}
|
||||||
|
onPress={() => handleSort('cheapest')}>
|
||||||
|
<ActionsheetItemText>Najtańsze</ActionsheetItemText>
|
||||||
|
</ActionsheetItem>
|
||||||
|
<ActionsheetItem
|
||||||
|
className={ params.sort == 'expensive' ? 'bg-gray-200' : ''}
|
||||||
|
onPress={() => handleSort('expensive')}>
|
||||||
|
<ActionsheetItemText>Najdroższe</ActionsheetItemText>
|
||||||
|
</ActionsheetItem>
|
||||||
|
</ActionsheetContent>
|
||||||
|
</Actionsheet>
|
||||||
|
<FlatList
|
||||||
|
data={filteredNotices}
|
||||||
|
numColumns={2}
|
||||||
|
columnWrapperStyle={{ gap: 8, marginHorizontal: 8 }}
|
||||||
|
contentContainerStyle={{ paddingBottom: 16 }}
|
||||||
|
renderItem={({ item }) => <NoticeCard notice={item} />}
|
||||||
|
refreshControl={
|
||||||
|
<RefreshControl
|
||||||
|
refreshing={refreshing}
|
||||||
|
onRefresh={onRefresh}
|
||||||
|
colors={["#3b82f6"]}
|
||||||
|
tintColor="#3b82f6"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -4,9 +4,15 @@ import { NoticeCard } from "@/components/NoticeCard";
|
|||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { Box } from "@/components/ui/box";
|
import { Box } from "@/components/ui/box";
|
||||||
import { Text } from "@/components/ui/text";
|
import { Text } from "@/components/ui/text";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export default function Wishlist() {
|
export default function Wishlist() {
|
||||||
const wishlistNotices = useWishlist((state) => state.wishlistNotices);
|
const wishlistNotices = useWishlist((state) => state.wishlistNotices);
|
||||||
|
const fetchWishlist = useWishlist((state) => state.fetchWishlist);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchWishlist();
|
||||||
|
}, []);
|
||||||
if (wishlistNotices.length === 0) {
|
if (wishlistNotices.length === 0) {
|
||||||
return (
|
return (
|
||||||
<Box className="flex-row flex-1 justify-center">
|
<Box className="flex-row flex-1 justify-center">
|
||||||
|
|||||||
@@ -1,13 +1,22 @@
|
|||||||
import { Stack } from "expo-router";
|
import { Stack, Redirect } from "expo-router";
|
||||||
import "@/global.css";
|
import "@/global.css";
|
||||||
import { GluestackUIProvider } from "@/components/ui/gluestack-ui-provider";
|
import { GluestackUIProvider } from "@/components/ui/gluestack-ui-provider";
|
||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { useNoticesStore } from "@/store/noticesStore";
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
export default function RootLayout() {
|
export default function RootLayout() {
|
||||||
return (
|
const fetchNotices = useNoticesStore((state) => state.fetchNotices);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchNotices();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<GluestackUIProvider>
|
<GluestackUIProvider>
|
||||||
|
|
||||||
<Stack
|
<Stack
|
||||||
screenOptions={{
|
screenOptions={{
|
||||||
headerTintColor: "#1c1c1e",
|
headerTintColor: "#1c1c1e",
|
||||||
@@ -16,6 +25,12 @@ export default function RootLayout() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||||
|
<Stack.Screen
|
||||||
|
name="(auth)/login"
|
||||||
|
options={{ headerShown: false }}/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="registration"
|
||||||
|
options={{ headerShown: false }}/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</GluestackUIProvider>
|
</GluestackUIProvider>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import {useAuthStore} from '@/store/authStore';
|
|||||||
import {useRouter} from 'expo-router';
|
import {useRouter} from 'expo-router';
|
||||||
|
|
||||||
import {Box} from "@/components/ui/box"
|
import {Box} from "@/components/ui/box"
|
||||||
import {Button, ButtonText} from "@/components/ui/button"
|
import {Button, ButtonText,ButtonIcon} from "@/components/ui/button"
|
||||||
|
import {ArrowRightIcon} from "@/components/ui/icon"
|
||||||
import {Center} from "@/components/ui/center"
|
import {Center} from "@/components/ui/center"
|
||||||
import {Heading} from "@/components/ui/heading"
|
import {Heading} from "@/components/ui/heading"
|
||||||
import {Input, InputField} from "@/components/ui/input"
|
import {Input, InputField} from "@/components/ui/input"
|
||||||
import {VStack} from "@/components/ui/vstack"
|
import {VStack} from "@/components/ui/vstack"
|
||||||
|
import {Link} from "expo-router"
|
||||||
|
|
||||||
export default function Registration() {
|
export default function Registration() {
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
@@ -44,9 +46,18 @@ export default function Registration() {
|
|||||||
return (
|
return (
|
||||||
<SafeAreaView style={styles.container}>
|
<SafeAreaView style={styles.container}>
|
||||||
<Center>
|
<Center>
|
||||||
|
|
||||||
<Box className="p-5 w-[80%] border border-background-300 rounded-lg">
|
<Box className="p-5 w-[80%] border border-background-300 rounded-lg">
|
||||||
<VStack className="pb-4" space="xs">
|
<VStack className="pb-4" space="xs">
|
||||||
<Heading className="leading-[30px]">Rejestracja</Heading>
|
<Heading className="leading-[30px]">Rejestracja</Heading>
|
||||||
|
<Box className="flex flex-row">
|
||||||
|
{/* <Link href="/login" asChild> */}
|
||||||
|
<Button variant="link" size="sm" className="p-0" onPress={() => router.replace("/login")}>
|
||||||
|
<ButtonText style={styles.signupbutton}>Masz już konto? Zaloguj się!</ButtonText>
|
||||||
|
<ButtonIcon className="mr-1" size="md" as={ArrowRightIcon}/>
|
||||||
|
</Button>
|
||||||
|
{/* </Link> */}
|
||||||
|
</Box>
|
||||||
</VStack>
|
</VStack>
|
||||||
<VStack space="xl" className="py-2">
|
<VStack space="xl" className="py-2">
|
||||||
<Input>
|
<Input>
|
||||||
@@ -69,6 +80,7 @@ export default function Registration() {
|
|||||||
</Button>
|
</Button>
|
||||||
</VStack>
|
</VStack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
</Center>
|
</Center>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
@@ -93,4 +105,8 @@ const styles = StyleSheet.create({
|
|||||||
color: 'red',
|
color: 'red',
|
||||||
marginBottom: 10,
|
marginBottom: 10,
|
||||||
},
|
},
|
||||||
|
signupbutton: {
|
||||||
|
fontWeight: '300',
|
||||||
|
textAlign: 'left',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
53
ArtisanConnect/components/CategorySection.jsx
Normal file
53
ArtisanConnect/components/CategorySection.jsx
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { View, FlatList} from 'react-native';
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { Heading } from '@/components/ui/heading';
|
||||||
|
import { Text } from '@/components/ui/text';
|
||||||
|
import { Link } from 'expo-router';
|
||||||
|
import { Pressable } from '@/components/ui/pressable';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
export function CategorySection({notices, title}) {
|
||||||
|
// const notices = useNoticesStore((state) => state.notices);
|
||||||
|
|
||||||
|
const [categoryMap, setCategoryMap] = useState({});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
axios.get('https://testowe.zikor.pl/api/v1/vars/categories')
|
||||||
|
.then(res => setCategoryMap(res.data))
|
||||||
|
.catch(() => setCategoryMap({}));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const categories = Array.from(
|
||||||
|
new Set(notices.map((notice) => notice.category))
|
||||||
|
).filter(Boolean);
|
||||||
|
|
||||||
|
|
||||||
|
const getCount = (category) =>
|
||||||
|
notices.filter((notice) => notice.category === category).length;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="mb-6">
|
||||||
|
<Heading className="text-2xl font-bold mb-4 mt-4">{title}</Heading>
|
||||||
|
<FlatList
|
||||||
|
data={categories}
|
||||||
|
keyExtractor={(item) => item}
|
||||||
|
horizontal
|
||||||
|
showsHorizontalScrollIndicator={false}
|
||||||
|
contentContainerStyle={{ paddingHorizontal: 8, gap: 12 }}
|
||||||
|
renderItem={({ item }) => {
|
||||||
|
const categoryObj = categoryMap.find((cat) => cat.value === item);
|
||||||
|
return (
|
||||||
|
<Link href={`/notices?category=${item}`} asChild>
|
||||||
|
<Pressable className="bg-gray-200 p-4 rounded-lg mr-2">
|
||||||
|
<Text>
|
||||||
|
{categoryObj ? categoryObj.label : item} ({getCount(item)})
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,8 +14,7 @@ import {useEffect, useState} from "react";
|
|||||||
export function NoticeCard({notice}) {
|
export function NoticeCard({notice}) {
|
||||||
const noticeId = notice?.noticeId;
|
const noticeId = notice?.noticeId;
|
||||||
|
|
||||||
const addNoticeToWishlist = useWishlist((state) => state.addNoticeToWishlist);
|
const toggleNoticeInWishlist = useWishlist((state) => state.toggleNoticeInWishlist);
|
||||||
const removeNoticeFromWishlist = useWishlist((state) => state.removeNoticeFromWishlist);
|
|
||||||
const isInWishlist = useWishlist((state) =>
|
const isInWishlist = useWishlist((state) =>
|
||||||
noticeId ? state.wishlistNotices.some((item) => item.noticeId === noticeId) : false
|
noticeId ? state.wishlistNotices.some((item) => item.noticeId === noticeId) : false
|
||||||
);
|
);
|
||||||
@@ -94,11 +93,7 @@ export function NoticeCard({notice}) {
|
|||||||
</Heading>
|
</Heading>
|
||||||
<Pressable
|
<Pressable
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (isInWishlist) {
|
toggleNoticeInWishlist(noticeId);
|
||||||
removeNoticeFromWishlist(noticeId);
|
|
||||||
} else {
|
|
||||||
addNoticeToWishlist(notice);
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
|
|||||||
35
ArtisanConnect/components/NoticeSection.jsx
Normal file
35
ArtisanConnect/components/NoticeSection.jsx
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { View} from 'react-native';
|
||||||
|
import { Heading } from '@/components/ui/heading';
|
||||||
|
import { Link } from 'expo-router';
|
||||||
|
import { FlatList } from 'react-native';
|
||||||
|
import {NoticeCard} from "@/components/NoticeCard";
|
||||||
|
import { Box } from '@/components/ui/box';
|
||||||
|
import { HStack } from "@/components/ui/hstack"
|
||||||
|
import { VStack } from '@/components/ui/vstack';
|
||||||
|
import { Button, ButtonText } from "@/components/ui/button"
|
||||||
|
|
||||||
|
export function NoticeSection({ notices, title, ctaLink=''}) {
|
||||||
|
const rows = [];
|
||||||
|
for (let i = 0; i < notices.length; i += 2) {
|
||||||
|
rows.push(
|
||||||
|
<HStack key={i} space="md">
|
||||||
|
<NoticeCard notice={notices[i]} />
|
||||||
|
{notices[i + 1] && <NoticeCard notice={notices[i + 1]} />}
|
||||||
|
</HStack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<View className="mb-6">
|
||||||
|
<Heading className="text-2xl font-bold mb-4 mt-4">{title}</Heading>
|
||||||
|
<VStack space="md">
|
||||||
|
{rows}
|
||||||
|
</VStack>
|
||||||
|
{ctaLink && (
|
||||||
|
<Link href={ctaLink} asChild>
|
||||||
|
<Button className="mt-6" size="md" variant="solid" action="primary">
|
||||||
|
<ButtonText>Zobacz więcej</ButtonText>
|
||||||
|
</Button>
|
||||||
|
</Link>)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
31
ArtisanConnect/components/SearchSection.jsx
Normal file
31
ArtisanConnect/components/SearchSection.jsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { Input, InputField, InputIcon, InputSlot } from "@/components/ui/input"
|
||||||
|
import { SearchIcon } from "@/components/ui/icon"
|
||||||
|
import { Box } from "@/components/ui/box"
|
||||||
|
import { useRouter } from "expo-router";
|
||||||
|
|
||||||
|
export function SearchSection({ searchQuery, setSearchQuery }) {
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const handleSubmit = (e) => {
|
||||||
|
const value = e.nativeEvent.text;
|
||||||
|
router.push({
|
||||||
|
pathname: "/notices",
|
||||||
|
params: { search: value }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Box className="m-2 bg-white">
|
||||||
|
<Input>
|
||||||
|
<InputSlot>
|
||||||
|
<InputIcon as={SearchIcon} />
|
||||||
|
</InputSlot>
|
||||||
|
<InputField placeholder="Wyszukaj.."
|
||||||
|
value={searchQuery}
|
||||||
|
onChangeText={setSearchQuery}
|
||||||
|
onSubmitEditing={handleSubmit}
|
||||||
|
returnKeyType="search" />
|
||||||
|
</Input>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
23
ArtisanConnect/components/UserBlock.jsx
Normal file
23
ArtisanConnect/components/UserBlock.jsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { VStack } from '@/components/ui/vstack';
|
||||||
|
import { Avatar, AvatarImage, AvatarFallbackText } from "@/components/ui/avatar";
|
||||||
|
import { Heading } from "@/components/ui/heading";
|
||||||
|
import { Box } from '@/components/ui/box';
|
||||||
|
|
||||||
|
export default function UserBlock({ user }) {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box className="rounded-md bg-white p-4 items-center justify-center mb-6" >
|
||||||
|
<VStack space="md" className='items-center'>
|
||||||
|
<Avatar>
|
||||||
|
<AvatarFallbackText>{user.firstName} {user.lastName}</AvatarFallbackText>
|
||||||
|
<AvatarImage
|
||||||
|
source={{
|
||||||
|
uri: user.image,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Avatar>
|
||||||
|
<Heading size="sm">{user.firstName} {user.lastName}</Heading>
|
||||||
|
</VStack>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
44
ArtisanConnect/components/UserSection.jsx
Normal file
44
ArtisanConnect/components/UserSection.jsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import { View} from 'react-native';
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { Heading } from '@/components/ui/heading';
|
||||||
|
import { FlatList } from 'react-native';
|
||||||
|
import axios from 'axios';
|
||||||
|
import UserBlock from '@/components/UserBlock';
|
||||||
|
|
||||||
|
export function UserSection({notices, title}) {
|
||||||
|
|
||||||
|
const [users, setUsers] = useState([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
axios.get('https://testowe.zikor.pl/api/v1/clients/get/all')
|
||||||
|
.then(res => setUsers(res.data))
|
||||||
|
.catch(() => setUsers([]));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const usersWithNoticeCount = users.map(user => {
|
||||||
|
const count = notices.filter(n => n.clientId === user.id).length;
|
||||||
|
return { ...user, noticeCount: count };
|
||||||
|
});
|
||||||
|
|
||||||
|
const topUsers = usersWithNoticeCount
|
||||||
|
.sort((a, b) => b.noticeCount - a.noticeCount)
|
||||||
|
.slice(0, 5);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="mb-6">
|
||||||
|
<Heading className="text-2xl font-bold mb-4 mt-4">{title}</Heading>
|
||||||
|
<FlatList
|
||||||
|
data={topUsers}
|
||||||
|
horizontal
|
||||||
|
showsHorizontalScrollIndicator={false}
|
||||||
|
contentContainerStyle={{ paddingHorizontal: 8, gap: 12 }}
|
||||||
|
renderItem={({ item }) => {
|
||||||
|
return (
|
||||||
|
<UserBlock user={item} />
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
569
ArtisanConnect/components/ui/actionsheet/index.tsx
Normal file
569
ArtisanConnect/components/ui/actionsheet/index.tsx
Normal file
@@ -0,0 +1,569 @@
|
|||||||
|
'use client';
|
||||||
|
import React from 'react';
|
||||||
|
import { H4 } from '@expo/html-elements';
|
||||||
|
import { createActionsheet } from '@gluestack-ui/actionsheet';
|
||||||
|
import {
|
||||||
|
Pressable,
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
ScrollView,
|
||||||
|
VirtualizedList,
|
||||||
|
FlatList,
|
||||||
|
SectionList,
|
||||||
|
PressableProps,
|
||||||
|
ViewStyle,
|
||||||
|
} from 'react-native';
|
||||||
|
import { PrimitiveIcon, UIIcon } from '@gluestack-ui/icon';
|
||||||
|
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
||||||
|
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
||||||
|
import { cssInterop } from 'nativewind';
|
||||||
|
import {
|
||||||
|
Motion,
|
||||||
|
AnimatePresence,
|
||||||
|
createMotionAnimatedComponent,
|
||||||
|
MotionComponentProps,
|
||||||
|
} from '@legendapp/motion';
|
||||||
|
|
||||||
|
const ItemWrapper = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof Pressable>,
|
||||||
|
PressableProps
|
||||||
|
>(function ItemWrapper({ ...props }, ref) {
|
||||||
|
return <Pressable {...props} ref={ref} />;
|
||||||
|
});
|
||||||
|
|
||||||
|
type IMotionViewProps = React.ComponentProps<typeof View> &
|
||||||
|
MotionComponentProps<typeof View, ViewStyle, unknown, unknown, unknown>;
|
||||||
|
|
||||||
|
const MotionView = Motion.View as React.ComponentType<IMotionViewProps>;
|
||||||
|
|
||||||
|
type IAnimatedPressableProps = React.ComponentProps<typeof Pressable> &
|
||||||
|
MotionComponentProps<typeof Pressable, ViewStyle, unknown, unknown, unknown>;
|
||||||
|
|
||||||
|
const AnimatedPressable = createMotionAnimatedComponent(
|
||||||
|
Pressable
|
||||||
|
) as React.ComponentType<IAnimatedPressableProps>;
|
||||||
|
|
||||||
|
export const UIActionsheet = createActionsheet({
|
||||||
|
Root: View,
|
||||||
|
Content: MotionView,
|
||||||
|
Item: ItemWrapper,
|
||||||
|
ItemText: Text,
|
||||||
|
DragIndicator: View,
|
||||||
|
IndicatorWrapper: View,
|
||||||
|
Backdrop: AnimatedPressable,
|
||||||
|
ScrollView: ScrollView,
|
||||||
|
VirtualizedList: VirtualizedList,
|
||||||
|
FlatList: FlatList,
|
||||||
|
SectionList: SectionList,
|
||||||
|
SectionHeaderText: H4,
|
||||||
|
Icon: UIIcon,
|
||||||
|
AnimatePresence: AnimatePresence,
|
||||||
|
});
|
||||||
|
|
||||||
|
cssInterop(UIActionsheet, { className: 'style' });
|
||||||
|
cssInterop(UIActionsheet.Content, { className: 'style' });
|
||||||
|
cssInterop(ItemWrapper, { className: 'style' });
|
||||||
|
cssInterop(UIActionsheet.ItemText, { className: 'style' });
|
||||||
|
cssInterop(UIActionsheet.DragIndicator, { className: 'style' });
|
||||||
|
cssInterop(UIActionsheet.DragIndicatorWrapper, { className: 'style' });
|
||||||
|
cssInterop(UIActionsheet.Backdrop, { className: 'style' });
|
||||||
|
cssInterop(UIActionsheet.ScrollView, {
|
||||||
|
className: 'style',
|
||||||
|
contentContainerClassName: 'contentContainerStyle',
|
||||||
|
indicatorClassName: 'indicatorStyle',
|
||||||
|
});
|
||||||
|
cssInterop(UIActionsheet.VirtualizedList, {
|
||||||
|
className: 'style',
|
||||||
|
ListFooterComponentClassName: 'ListFooterComponentStyle',
|
||||||
|
ListHeaderComponentClassName: 'ListHeaderComponentStyle',
|
||||||
|
contentContainerClassName: 'contentContainerStyle',
|
||||||
|
indicatorClassName: 'indicatorStyle',
|
||||||
|
});
|
||||||
|
cssInterop(UIActionsheet.FlatList, {
|
||||||
|
className: 'style',
|
||||||
|
ListFooterComponentClassName: 'ListFooterComponentStyle',
|
||||||
|
ListHeaderComponentClassName: 'ListHeaderComponentStyle',
|
||||||
|
columnWrapperClassName: 'columnWrapperStyle',
|
||||||
|
contentContainerClassName: 'contentContainerStyle',
|
||||||
|
indicatorClassName: 'indicatorStyle',
|
||||||
|
});
|
||||||
|
cssInterop(UIActionsheet.SectionList, { className: 'style' });
|
||||||
|
cssInterop(UIActionsheet.SectionHeaderText, { className: 'style' });
|
||||||
|
|
||||||
|
cssInterop(PrimitiveIcon, {
|
||||||
|
className: {
|
||||||
|
target: 'style',
|
||||||
|
nativeStyleToProp: {
|
||||||
|
height: true,
|
||||||
|
width: true,
|
||||||
|
fill: true,
|
||||||
|
color: 'classNameColor',
|
||||||
|
stroke: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetStyle = tva({ base: 'w-full h-full web:pointer-events-none' });
|
||||||
|
|
||||||
|
const actionsheetContentStyle = tva({
|
||||||
|
base: 'items-center rounded-tl-3xl rounded-tr-3xl p-5 pt-2 bg-background-0 web:pointer-events-auto web:select-none shadow-hard-5 border border-b-0 border-outline-100',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetItemStyle = tva({
|
||||||
|
base: 'w-full flex-row items-center p-3 rounded-sm data-[disabled=true]:opacity-40 data-[disabled=true]:web:pointer-events-auto data-[disabled=true]:web:cursor-not-allowed hover:bg-background-50 active:bg-background-100 data-[focus=true]:bg-background-100 web:data-[focus-visible=true]:bg-background-100 web:data-[focus-visible=true]:outline-indicator-primary gap-2',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetItemTextStyle = tva({
|
||||||
|
base: 'text-typography-700 font-normal font-body',
|
||||||
|
variants: {
|
||||||
|
isTruncated: {
|
||||||
|
true: '',
|
||||||
|
},
|
||||||
|
bold: {
|
||||||
|
true: 'font-bold',
|
||||||
|
},
|
||||||
|
underline: {
|
||||||
|
true: 'underline',
|
||||||
|
},
|
||||||
|
strikeThrough: {
|
||||||
|
true: 'line-through',
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
'2xs': 'text-2xs',
|
||||||
|
'xs': 'text-xs',
|
||||||
|
'sm': 'text-sm',
|
||||||
|
'md': 'text-base',
|
||||||
|
'lg': 'text-lg',
|
||||||
|
'xl': 'text-xl',
|
||||||
|
'2xl': 'text-2xl',
|
||||||
|
'3xl': 'text-3xl',
|
||||||
|
'4xl': 'text-4xl',
|
||||||
|
'5xl': 'text-5xl',
|
||||||
|
'6xl': 'text-6xl',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetDragIndicatorStyle = tva({
|
||||||
|
base: 'w-16 h-1 bg-background-400 rounded-full',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetDragIndicatorWrapperStyle = tva({
|
||||||
|
base: 'w-full py-1 items-center',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetBackdropStyle = tva({
|
||||||
|
base: 'absolute left-0 top-0 right-0 bottom-0 bg-background-dark web:cursor-default web:pointer-events-auto',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetScrollViewStyle = tva({
|
||||||
|
base: 'w-full h-auto',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetVirtualizedListStyle = tva({
|
||||||
|
base: 'w-full h-auto',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetFlatListStyle = tva({
|
||||||
|
base: 'w-full h-auto',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetSectionListStyle = tva({
|
||||||
|
base: 'w-full h-auto',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetSectionHeaderTextStyle = tva({
|
||||||
|
base: 'leading-5 font-bold font-heading my-0 text-typography-500 p-3 uppercase',
|
||||||
|
variants: {
|
||||||
|
isTruncated: {
|
||||||
|
true: '',
|
||||||
|
},
|
||||||
|
bold: {
|
||||||
|
true: 'font-bold',
|
||||||
|
},
|
||||||
|
underline: {
|
||||||
|
true: 'underline',
|
||||||
|
},
|
||||||
|
strikeThrough: {
|
||||||
|
true: 'line-through',
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
'5xl': 'text-5xl',
|
||||||
|
'4xl': 'text-4xl',
|
||||||
|
'3xl': 'text-3xl',
|
||||||
|
'2xl': 'text-2xl',
|
||||||
|
'xl': 'text-xl',
|
||||||
|
'lg': 'text-lg',
|
||||||
|
'md': 'text-base',
|
||||||
|
'sm': 'text-sm',
|
||||||
|
'xs': 'text-xs',
|
||||||
|
},
|
||||||
|
|
||||||
|
sub: {
|
||||||
|
true: 'text-xs',
|
||||||
|
},
|
||||||
|
italic: {
|
||||||
|
true: 'italic',
|
||||||
|
},
|
||||||
|
highlight: {
|
||||||
|
true: 'bg-yellow500',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
size: 'xs',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const actionsheetIconStyle = tva({
|
||||||
|
base: 'text-background-500 fill-none',
|
||||||
|
variants: {
|
||||||
|
size: {
|
||||||
|
'2xs': 'h-3 w-3',
|
||||||
|
'xs': 'h-3.5 w-3.5',
|
||||||
|
'sm': 'h-4 w-4',
|
||||||
|
'md': 'w-[18px] h-[18px]',
|
||||||
|
'lg': 'h-5 w-5',
|
||||||
|
'xl': 'h-6 w-6',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
type IActionsheetProps = VariantProps<typeof actionsheetStyle> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet>;
|
||||||
|
|
||||||
|
type IActionsheetContentProps = VariantProps<typeof actionsheetContentStyle> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.Content> & {
|
||||||
|
className?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type IActionsheetItemProps = VariantProps<typeof actionsheetItemStyle> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.Item>;
|
||||||
|
|
||||||
|
type IActionsheetItemTextProps = VariantProps<typeof actionsheetItemTextStyle> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.ItemText>;
|
||||||
|
|
||||||
|
type IActionsheetDragIndicatorProps = VariantProps<
|
||||||
|
typeof actionsheetDragIndicatorStyle
|
||||||
|
> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.DragIndicator>;
|
||||||
|
|
||||||
|
type IActionsheetDragIndicatorWrapperProps = VariantProps<
|
||||||
|
typeof actionsheetDragIndicatorWrapperStyle
|
||||||
|
> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.DragIndicatorWrapper>;
|
||||||
|
|
||||||
|
type IActionsheetBackdropProps = VariantProps<typeof actionsheetBackdropStyle> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.Backdrop> & {
|
||||||
|
className?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type IActionsheetScrollViewProps = VariantProps<
|
||||||
|
typeof actionsheetScrollViewStyle
|
||||||
|
> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.ScrollView>;
|
||||||
|
|
||||||
|
type IActionsheetVirtualizedListProps = VariantProps<
|
||||||
|
typeof actionsheetVirtualizedListStyle
|
||||||
|
> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.VirtualizedList>;
|
||||||
|
|
||||||
|
type IActionsheetFlatListProps = VariantProps<typeof actionsheetFlatListStyle> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.FlatList>;
|
||||||
|
|
||||||
|
type IActionsheetSectionListProps = VariantProps<
|
||||||
|
typeof actionsheetSectionListStyle
|
||||||
|
> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.SectionList>;
|
||||||
|
|
||||||
|
type IActionsheetSectionHeaderTextProps = VariantProps<
|
||||||
|
typeof actionsheetSectionHeaderTextStyle
|
||||||
|
> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.SectionHeaderText>;
|
||||||
|
|
||||||
|
type IActionsheetIconProps = VariantProps<typeof actionsheetIconStyle> &
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIActionsheet.Icon> & {
|
||||||
|
className?: string;
|
||||||
|
as?: React.ElementType;
|
||||||
|
height?: number;
|
||||||
|
width?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const Actionsheet = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet>,
|
||||||
|
IActionsheetProps
|
||||||
|
>(function Actionsheet({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet
|
||||||
|
className={actionsheetStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetContent = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.Content>,
|
||||||
|
IActionsheetContentProps
|
||||||
|
>(function ActionsheetContent({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.Content
|
||||||
|
className={actionsheetContentStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetItem = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.Item>,
|
||||||
|
IActionsheetItemProps
|
||||||
|
>(function ActionsheetItem({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.Item
|
||||||
|
className={actionsheetItemStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetItemText = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.ItemText>,
|
||||||
|
IActionsheetItemTextProps
|
||||||
|
>(function ActionsheetItemText(
|
||||||
|
{
|
||||||
|
isTruncated,
|
||||||
|
bold,
|
||||||
|
underline,
|
||||||
|
strikeThrough,
|
||||||
|
size = 'sm',
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
},
|
||||||
|
ref
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.ItemText
|
||||||
|
className={actionsheetItemTextStyle({
|
||||||
|
class: className,
|
||||||
|
isTruncated,
|
||||||
|
bold,
|
||||||
|
underline,
|
||||||
|
strikeThrough,
|
||||||
|
size,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetDragIndicator = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.DragIndicator>,
|
||||||
|
IActionsheetDragIndicatorProps
|
||||||
|
>(function ActionsheetDragIndicator({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.DragIndicator
|
||||||
|
className={actionsheetDragIndicatorStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetDragIndicatorWrapper = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.DragIndicatorWrapper>,
|
||||||
|
IActionsheetDragIndicatorWrapperProps
|
||||||
|
>(function ActionsheetDragIndicatorWrapper({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.DragIndicatorWrapper
|
||||||
|
className={actionsheetDragIndicatorWrapperStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetBackdrop = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.Backdrop>,
|
||||||
|
IActionsheetBackdropProps
|
||||||
|
>(function ActionsheetBackdrop({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.Backdrop
|
||||||
|
initial={{
|
||||||
|
opacity: 0,
|
||||||
|
}}
|
||||||
|
animate={{
|
||||||
|
opacity: 0.5,
|
||||||
|
}}
|
||||||
|
exit={{
|
||||||
|
opacity: 0,
|
||||||
|
}}
|
||||||
|
{...props}
|
||||||
|
className={actionsheetBackdropStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetScrollView = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.ScrollView>,
|
||||||
|
IActionsheetScrollViewProps
|
||||||
|
>(function ActionsheetScrollView({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.ScrollView
|
||||||
|
className={actionsheetScrollViewStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetVirtualizedList = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.VirtualizedList>,
|
||||||
|
IActionsheetVirtualizedListProps
|
||||||
|
>(function ActionsheetVirtualizedList({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.VirtualizedList
|
||||||
|
className={actionsheetVirtualizedListStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetFlatList = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.FlatList>,
|
||||||
|
IActionsheetFlatListProps
|
||||||
|
>(function ActionsheetFlatList({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.FlatList
|
||||||
|
className={actionsheetFlatListStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetSectionList = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.SectionList>,
|
||||||
|
IActionsheetSectionListProps
|
||||||
|
>(function ActionsheetSectionList({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.SectionList
|
||||||
|
className={actionsheetSectionListStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetSectionHeaderText = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.SectionHeaderText>,
|
||||||
|
IActionsheetSectionHeaderTextProps
|
||||||
|
>(function ActionsheetSectionHeaderText(
|
||||||
|
{
|
||||||
|
className,
|
||||||
|
isTruncated,
|
||||||
|
bold,
|
||||||
|
underline,
|
||||||
|
strikeThrough,
|
||||||
|
size,
|
||||||
|
sub,
|
||||||
|
italic,
|
||||||
|
highlight,
|
||||||
|
...props
|
||||||
|
},
|
||||||
|
ref
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.SectionHeaderText
|
||||||
|
className={actionsheetSectionHeaderTextStyle({
|
||||||
|
class: className,
|
||||||
|
isTruncated,
|
||||||
|
bold,
|
||||||
|
underline,
|
||||||
|
strikeThrough,
|
||||||
|
size,
|
||||||
|
sub,
|
||||||
|
italic,
|
||||||
|
highlight,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ActionsheetIcon = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIActionsheet.Icon>,
|
||||||
|
IActionsheetIconProps
|
||||||
|
>(function ActionsheetIcon({ className, size = 'sm', ...props }, ref) {
|
||||||
|
if (typeof size === 'number') {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.Icon
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
className={actionsheetIconStyle({ class: className })}
|
||||||
|
size={size}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
(props.height !== undefined || props.width !== undefined) &&
|
||||||
|
size === undefined
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<UIActionsheet.Icon
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
className={actionsheetIconStyle({ class: className })}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<UIActionsheet.Icon
|
||||||
|
className={actionsheetIconStyle({
|
||||||
|
class: className,
|
||||||
|
size,
|
||||||
|
})}
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export {
|
||||||
|
Actionsheet,
|
||||||
|
ActionsheetContent,
|
||||||
|
ActionsheetItem,
|
||||||
|
ActionsheetItemText,
|
||||||
|
ActionsheetDragIndicator,
|
||||||
|
ActionsheetDragIndicatorWrapper,
|
||||||
|
ActionsheetBackdrop,
|
||||||
|
ActionsheetScrollView,
|
||||||
|
ActionsheetVirtualizedList,
|
||||||
|
ActionsheetFlatList,
|
||||||
|
ActionsheetSectionList,
|
||||||
|
ActionsheetSectionHeaderText,
|
||||||
|
ActionsheetIcon,
|
||||||
|
};
|
||||||
185
ArtisanConnect/components/ui/avatar/index.tsx
Normal file
185
ArtisanConnect/components/ui/avatar/index.tsx
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
'use client';
|
||||||
|
import React from 'react';
|
||||||
|
import { createAvatar } from '@gluestack-ui/avatar';
|
||||||
|
|
||||||
|
import { View, Text, Image, Platform } from 'react-native';
|
||||||
|
|
||||||
|
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
||||||
|
import {
|
||||||
|
withStyleContext,
|
||||||
|
useStyleContext,
|
||||||
|
} from '@gluestack-ui/nativewind-utils/withStyleContext';
|
||||||
|
const SCOPE = 'AVATAR';
|
||||||
|
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
||||||
|
|
||||||
|
const UIAvatar = createAvatar({
|
||||||
|
Root: withStyleContext(View, SCOPE),
|
||||||
|
Badge: View,
|
||||||
|
Group: View,
|
||||||
|
Image: Image,
|
||||||
|
FallbackText: Text,
|
||||||
|
});
|
||||||
|
|
||||||
|
const avatarStyle = tva({
|
||||||
|
base: 'rounded-full justify-center items-center relative bg-primary-600 group-[.avatar-group]/avatar-group:-ml-2.5',
|
||||||
|
variants: {
|
||||||
|
size: {
|
||||||
|
'xs': 'w-6 h-6',
|
||||||
|
'sm': 'w-8 h-8',
|
||||||
|
'md': 'w-12 h-12',
|
||||||
|
'lg': 'w-16 h-16',
|
||||||
|
'xl': 'w-24 h-24',
|
||||||
|
'2xl': 'w-32 h-32',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const avatarFallbackTextStyle = tva({
|
||||||
|
base: 'text-typography-0 font-semibold overflow-hidden text-transform:uppercase web:cursor-default',
|
||||||
|
|
||||||
|
parentVariants: {
|
||||||
|
size: {
|
||||||
|
'xs': 'text-2xs',
|
||||||
|
'sm': 'text-xs',
|
||||||
|
'md': 'text-base',
|
||||||
|
'lg': 'text-xl',
|
||||||
|
'xl': 'text-3xl',
|
||||||
|
'2xl': 'text-5xl',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const avatarGroupStyle = tva({
|
||||||
|
base: 'group/avatar-group flex-row-reverse relative avatar-group',
|
||||||
|
});
|
||||||
|
|
||||||
|
const avatarBadgeStyle = tva({
|
||||||
|
base: 'w-5 h-5 bg-success-500 rounded-full absolute right-0 bottom-0 border-background-0 border-2',
|
||||||
|
parentVariants: {
|
||||||
|
size: {
|
||||||
|
'xs': 'w-2 h-2',
|
||||||
|
'sm': 'w-2 h-2',
|
||||||
|
'md': 'w-3 h-3',
|
||||||
|
'lg': 'w-4 h-4',
|
||||||
|
'xl': 'w-6 h-6',
|
||||||
|
'2xl': 'w-8 h-8',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const avatarImageStyle = tva({
|
||||||
|
base: 'h-full w-full rounded-full absolute',
|
||||||
|
});
|
||||||
|
|
||||||
|
type IAvatarProps = Omit<
|
||||||
|
React.ComponentPropsWithoutRef<typeof UIAvatar>,
|
||||||
|
'context'
|
||||||
|
> &
|
||||||
|
VariantProps<typeof avatarStyle>;
|
||||||
|
|
||||||
|
const Avatar = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIAvatar>,
|
||||||
|
IAvatarProps
|
||||||
|
>(function Avatar({ className, size = 'md', ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIAvatar
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
className={avatarStyle({ size, class: className })}
|
||||||
|
context={{ size }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
type IAvatarBadgeProps = React.ComponentPropsWithoutRef<typeof UIAvatar.Badge> &
|
||||||
|
VariantProps<typeof avatarBadgeStyle>;
|
||||||
|
|
||||||
|
const AvatarBadge = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIAvatar.Badge>,
|
||||||
|
IAvatarBadgeProps
|
||||||
|
>(function AvatarBadge({ className, size, ...props }, ref) {
|
||||||
|
const { size: parentSize } = useStyleContext(SCOPE);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<UIAvatar.Badge
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
className={avatarBadgeStyle({
|
||||||
|
parentVariants: {
|
||||||
|
size: parentSize,
|
||||||
|
},
|
||||||
|
size,
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
type IAvatarFallbackTextProps = React.ComponentPropsWithoutRef<
|
||||||
|
typeof UIAvatar.FallbackText
|
||||||
|
> &
|
||||||
|
VariantProps<typeof avatarFallbackTextStyle>;
|
||||||
|
const AvatarFallbackText = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIAvatar.FallbackText>,
|
||||||
|
IAvatarFallbackTextProps
|
||||||
|
>(function AvatarFallbackText({ className, size, ...props }, ref) {
|
||||||
|
const { size: parentSize } = useStyleContext(SCOPE);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<UIAvatar.FallbackText
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
className={avatarFallbackTextStyle({
|
||||||
|
parentVariants: {
|
||||||
|
size: parentSize,
|
||||||
|
},
|
||||||
|
size,
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
type IAvatarImageProps = React.ComponentPropsWithoutRef<typeof UIAvatar.Image> &
|
||||||
|
VariantProps<typeof avatarImageStyle>;
|
||||||
|
|
||||||
|
const AvatarImage = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIAvatar.Image>,
|
||||||
|
IAvatarImageProps
|
||||||
|
>(function AvatarImage({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIAvatar.Image
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
className={avatarImageStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
// @ts-expect-error : This is a workaround to fix the issue with the image style on web.
|
||||||
|
style={
|
||||||
|
Platform.OS === 'web'
|
||||||
|
? { height: 'revert-layer', width: 'revert-layer' }
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
type IAvatarGroupProps = React.ComponentPropsWithoutRef<typeof UIAvatar.Group> &
|
||||||
|
VariantProps<typeof avatarGroupStyle>;
|
||||||
|
|
||||||
|
const AvatarGroup = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIAvatar.Group>,
|
||||||
|
IAvatarGroupProps
|
||||||
|
>(function AvatarGroup({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIAvatar.Group
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
className={avatarGroupStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export { Avatar, AvatarBadge, AvatarFallbackText, AvatarImage, AvatarGroup };
|
||||||
22
ArtisanConnect/components/ui/center/index.tsx
Normal file
22
ArtisanConnect/components/ui/center/index.tsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { View, ViewProps } from 'react-native';
|
||||||
|
import React from 'react';
|
||||||
|
import { centerStyle } from './styles';
|
||||||
|
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
||||||
|
|
||||||
|
type ICenterProps = ViewProps & VariantProps<typeof centerStyle>;
|
||||||
|
|
||||||
|
const Center = React.forwardRef<React.ComponentRef<typeof View>, ICenterProps>(
|
||||||
|
function Center({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
className={centerStyle({ class: className })}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Center.displayName = 'Center';
|
||||||
|
|
||||||
|
export { Center };
|
||||||
20
ArtisanConnect/components/ui/center/index.web.tsx
Normal file
20
ArtisanConnect/components/ui/center/index.web.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { centerStyle } from './styles';
|
||||||
|
|
||||||
|
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
||||||
|
|
||||||
|
type ICenterProps = React.ComponentPropsWithoutRef<'div'> &
|
||||||
|
VariantProps<typeof centerStyle>;
|
||||||
|
|
||||||
|
const Center = React.forwardRef<HTMLDivElement, ICenterProps>(function Center(
|
||||||
|
{ className, ...props },
|
||||||
|
ref
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<div className={centerStyle({ class: className })} {...props} ref={ref} />
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Center.displayName = 'Center';
|
||||||
|
|
||||||
|
export { Center };
|
||||||
8
ArtisanConnect/components/ui/center/styles.tsx
Normal file
8
ArtisanConnect/components/ui/center/styles.tsx
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
||||||
|
import { isWeb } from '@gluestack-ui/nativewind-utils/IsWeb';
|
||||||
|
|
||||||
|
const baseStyle = isWeb ? 'flex flex-col relative z-0' : '';
|
||||||
|
|
||||||
|
export const centerStyle = tva({
|
||||||
|
base: `justify-center items-center ${baseStyle}`,
|
||||||
|
});
|
||||||
40
ArtisanConnect/components/ui/divider/index.tsx
Normal file
40
ArtisanConnect/components/ui/divider/index.tsx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
'use client';
|
||||||
|
import React from 'react';
|
||||||
|
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
||||||
|
import { Platform, View } from 'react-native';
|
||||||
|
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
||||||
|
|
||||||
|
const dividerStyle = tva({
|
||||||
|
base: 'bg-background-200',
|
||||||
|
variants: {
|
||||||
|
orientation: {
|
||||||
|
vertical: 'w-px h-full',
|
||||||
|
horizontal: 'h-px w-full',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
type IUIDividerProps = React.ComponentPropsWithoutRef<typeof View> &
|
||||||
|
VariantProps<typeof dividerStyle>;
|
||||||
|
|
||||||
|
const Divider = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof View>,
|
||||||
|
IUIDividerProps
|
||||||
|
>(function Divider({ className, orientation = 'horizontal', ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
aria-orientation={orientation}
|
||||||
|
role={Platform.OS === 'web' ? 'separator' : undefined}
|
||||||
|
className={dividerStyle({
|
||||||
|
orientation,
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Divider.displayName = 'Divider';
|
||||||
|
|
||||||
|
export { Divider };
|
||||||
23
ArtisanConnect/components/ui/hstack/index.tsx
Normal file
23
ArtisanConnect/components/ui/hstack/index.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
||||||
|
import { View } from 'react-native';
|
||||||
|
import type { ViewProps } from 'react-native';
|
||||||
|
import { hstackStyle } from './styles';
|
||||||
|
|
||||||
|
type IHStackProps = ViewProps & VariantProps<typeof hstackStyle>;
|
||||||
|
|
||||||
|
const HStack = React.forwardRef<React.ComponentRef<typeof View>, IHStackProps>(
|
||||||
|
function HStack({ className, space, reversed, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
className={hstackStyle({ space, reversed, class: className })}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
HStack.displayName = 'HStack';
|
||||||
|
|
||||||
|
export { HStack };
|
||||||
22
ArtisanConnect/components/ui/hstack/index.web.tsx
Normal file
22
ArtisanConnect/components/ui/hstack/index.web.tsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
||||||
|
import { hstackStyle } from './styles';
|
||||||
|
|
||||||
|
type IHStackProps = React.ComponentPropsWithoutRef<'div'> &
|
||||||
|
VariantProps<typeof hstackStyle>;
|
||||||
|
|
||||||
|
const HStack = React.forwardRef<React.ComponentRef<'div'>, IHStackProps>(
|
||||||
|
function HStack({ className, space, reversed, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={hstackStyle({ space, reversed, class: className })}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
HStack.displayName = 'HStack';
|
||||||
|
|
||||||
|
export { HStack };
|
||||||
25
ArtisanConnect/components/ui/hstack/styles.tsx
Normal file
25
ArtisanConnect/components/ui/hstack/styles.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { isWeb } from '@gluestack-ui/nativewind-utils/IsWeb';
|
||||||
|
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
||||||
|
|
||||||
|
const baseStyle = isWeb
|
||||||
|
? 'flex relative z-0 box-border border-0 list-none min-w-0 min-h-0 bg-transparent items-stretch m-0 p-0 text-decoration-none'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
export const hstackStyle = tva({
|
||||||
|
base: `flex-row ${baseStyle}`,
|
||||||
|
variants: {
|
||||||
|
space: {
|
||||||
|
'xs': 'gap-1',
|
||||||
|
'sm': 'gap-2',
|
||||||
|
'md': 'gap-3',
|
||||||
|
'lg': 'gap-4',
|
||||||
|
'xl': 'gap-5',
|
||||||
|
'2xl': 'gap-6',
|
||||||
|
'3xl': 'gap-7',
|
||||||
|
'4xl': 'gap-8',
|
||||||
|
},
|
||||||
|
reversed: {
|
||||||
|
true: 'flex-row-reverse',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
39
ArtisanConnect/components/ui/pressable/index.tsx
Normal file
39
ArtisanConnect/components/ui/pressable/index.tsx
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
'use client';
|
||||||
|
import React from 'react';
|
||||||
|
import { createPressable } from '@gluestack-ui/pressable';
|
||||||
|
import { Pressable as RNPressable } from 'react-native';
|
||||||
|
|
||||||
|
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
||||||
|
import { withStyleContext } from '@gluestack-ui/nativewind-utils/withStyleContext';
|
||||||
|
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
||||||
|
|
||||||
|
const UIPressable = createPressable({
|
||||||
|
Root: withStyleContext(RNPressable),
|
||||||
|
});
|
||||||
|
|
||||||
|
const pressableStyle = tva({
|
||||||
|
base: 'data-[focus-visible=true]:outline-none data-[focus-visible=true]:ring-indicator-info data-[focus-visible=true]:ring-2 data-[disabled=true]:opacity-40',
|
||||||
|
});
|
||||||
|
|
||||||
|
type IPressableProps = Omit<
|
||||||
|
React.ComponentProps<typeof UIPressable>,
|
||||||
|
'context'
|
||||||
|
> &
|
||||||
|
VariantProps<typeof pressableStyle>;
|
||||||
|
const Pressable = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UIPressable>,
|
||||||
|
IPressableProps
|
||||||
|
>(function Pressable({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<UIPressable
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
className={pressableStyle({
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Pressable.displayName = 'Pressable';
|
||||||
|
export { Pressable };
|
||||||
264
ArtisanConnect/components/ui/slider/index.tsx
Normal file
264
ArtisanConnect/components/ui/slider/index.tsx
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
'use client';
|
||||||
|
import { createSlider } from '@gluestack-ui/slider';
|
||||||
|
import { Pressable } from 'react-native';
|
||||||
|
import { View } from 'react-native';
|
||||||
|
import React from 'react';
|
||||||
|
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
||||||
|
import {
|
||||||
|
withStyleContext,
|
||||||
|
useStyleContext,
|
||||||
|
} from '@gluestack-ui/nativewind-utils/withStyleContext';
|
||||||
|
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
||||||
|
import { cssInterop } from 'nativewind';
|
||||||
|
|
||||||
|
const SCOPE = 'SLIDER';
|
||||||
|
const Root = withStyleContext(View, SCOPE);
|
||||||
|
export const UISlider = createSlider({
|
||||||
|
Root: Root,
|
||||||
|
Thumb: View,
|
||||||
|
Track: Pressable,
|
||||||
|
FilledTrack: View,
|
||||||
|
ThumbInteraction: View,
|
||||||
|
});
|
||||||
|
|
||||||
|
cssInterop(UISlider.Track, { className: 'style' });
|
||||||
|
|
||||||
|
const sliderStyle = tva({
|
||||||
|
base: 'justify-center items-center data-[disabled=true]:opacity-40 data-[disabled=true]:web:pointer-events-none',
|
||||||
|
variants: {
|
||||||
|
orientation: {
|
||||||
|
horizontal: 'w-full',
|
||||||
|
vertical: 'h-full',
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
sm: '',
|
||||||
|
md: '',
|
||||||
|
lg: '',
|
||||||
|
},
|
||||||
|
isReversed: {
|
||||||
|
true: '',
|
||||||
|
false: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const sliderThumbStyle = tva({
|
||||||
|
base: 'bg-primary-500 absolute rounded-full data-[focus=true]:bg-primary-600 data-[active=true]:bg-primary-600 data-[hover=true]:bg-primary-600 data-[disabled=true]:bg-primary-500 web:cursor-pointer web:data-[active=true]:outline web:data-[active=true]:outline-4 web:data-[active=true]:outline-primary-400 shadow-hard-1',
|
||||||
|
|
||||||
|
parentVariants: {
|
||||||
|
size: {
|
||||||
|
sm: 'h-4 w-4',
|
||||||
|
md: 'h-5 w-5',
|
||||||
|
lg: 'h-6 w-6',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const sliderTrackStyle = tva({
|
||||||
|
base: 'bg-background-300 rounded-lg overflow-hidden',
|
||||||
|
parentVariants: {
|
||||||
|
orientation: {
|
||||||
|
horizontal: 'w-full',
|
||||||
|
vertical: 'h-full',
|
||||||
|
},
|
||||||
|
isReversed: {
|
||||||
|
true: '',
|
||||||
|
false: '',
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
sm: '',
|
||||||
|
md: '',
|
||||||
|
lg: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
parentCompoundVariants: [
|
||||||
|
{
|
||||||
|
orientation: 'horizontal',
|
||||||
|
size: 'sm',
|
||||||
|
class: 'h-1 flex-row',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'horizontal',
|
||||||
|
size: 'sm',
|
||||||
|
isReversed: true,
|
||||||
|
class: 'h-1 flex-row-reverse',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'horizontal',
|
||||||
|
size: 'md',
|
||||||
|
class: 'h-1 flex-row',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'horizontal',
|
||||||
|
size: 'md',
|
||||||
|
isReversed: true,
|
||||||
|
class: 'h-[5px] flex-row-reverse',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'horizontal',
|
||||||
|
size: 'lg',
|
||||||
|
class: 'h-1.5 flex-row',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'horizontal',
|
||||||
|
size: 'lg',
|
||||||
|
isReversed: true,
|
||||||
|
class: 'h-1.5 flex-row-reverse',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'vertical',
|
||||||
|
size: 'sm',
|
||||||
|
class: 'w-1 flex-col-reverse',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'vertical',
|
||||||
|
size: 'sm',
|
||||||
|
isReversed: true,
|
||||||
|
class: 'w-1 flex-col',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'vertical',
|
||||||
|
size: 'md',
|
||||||
|
class: 'w-[5px] flex-col-reverse',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'vertical',
|
||||||
|
size: 'md',
|
||||||
|
isReversed: true,
|
||||||
|
class: 'w-[5px] flex-col',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'vertical',
|
||||||
|
size: 'lg',
|
||||||
|
class: 'w-1.5 flex-col-reverse',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
orientation: 'vertical',
|
||||||
|
size: 'lg',
|
||||||
|
isReversed: true,
|
||||||
|
class: 'w-1.5 flex-col',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const sliderFilledTrackStyle = tva({
|
||||||
|
base: 'bg-primary-500 data-[focus=true]:bg-primary-600 data-[active=true]:bg-primary-600 data-[hover=true]:bg-primary-600',
|
||||||
|
parentVariants: {
|
||||||
|
orientation: {
|
||||||
|
horizontal: 'h-full',
|
||||||
|
vertical: 'w-full',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
type ISliderProps = React.ComponentProps<typeof UISlider> &
|
||||||
|
VariantProps<typeof sliderStyle>;
|
||||||
|
|
||||||
|
const Slider = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UISlider>,
|
||||||
|
ISliderProps
|
||||||
|
>(function Slider(
|
||||||
|
{
|
||||||
|
className,
|
||||||
|
size = 'md',
|
||||||
|
orientation = 'horizontal',
|
||||||
|
isReversed = false,
|
||||||
|
...props
|
||||||
|
},
|
||||||
|
ref
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<UISlider
|
||||||
|
ref={ref}
|
||||||
|
isReversed={isReversed}
|
||||||
|
orientation={orientation}
|
||||||
|
{...props}
|
||||||
|
className={sliderStyle({
|
||||||
|
orientation,
|
||||||
|
isReversed,
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
context={{ size, orientation, isReversed }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
type ISliderThumbProps = React.ComponentProps<typeof UISlider.Thumb> &
|
||||||
|
VariantProps<typeof sliderThumbStyle>;
|
||||||
|
|
||||||
|
const SliderThumb = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UISlider.Thumb>,
|
||||||
|
ISliderThumbProps
|
||||||
|
>(function SliderThumb({ className, size, ...props }, ref) {
|
||||||
|
const { size: parentSize } = useStyleContext(SCOPE);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<UISlider.Thumb
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
className={sliderThumbStyle({
|
||||||
|
parentVariants: {
|
||||||
|
size: parentSize,
|
||||||
|
},
|
||||||
|
size,
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
type ISliderTrackProps = React.ComponentProps<typeof UISlider.Track> &
|
||||||
|
VariantProps<typeof sliderTrackStyle>;
|
||||||
|
|
||||||
|
const SliderTrack = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UISlider.Track>,
|
||||||
|
ISliderTrackProps
|
||||||
|
>(function SliderTrack({ className, ...props }, ref) {
|
||||||
|
const {
|
||||||
|
orientation: parentOrientation,
|
||||||
|
size: parentSize,
|
||||||
|
isReversed,
|
||||||
|
} = useStyleContext(SCOPE);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<UISlider.Track
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
className={sliderTrackStyle({
|
||||||
|
parentVariants: {
|
||||||
|
orientation: parentOrientation,
|
||||||
|
size: parentSize,
|
||||||
|
isReversed,
|
||||||
|
},
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
type ISliderFilledTrackProps = React.ComponentProps<
|
||||||
|
typeof UISlider.FilledTrack
|
||||||
|
> &
|
||||||
|
VariantProps<typeof sliderFilledTrackStyle>;
|
||||||
|
|
||||||
|
const SliderFilledTrack = React.forwardRef<
|
||||||
|
React.ComponentRef<typeof UISlider.FilledTrack>,
|
||||||
|
ISliderFilledTrackProps
|
||||||
|
>(function SliderFilledTrack({ className, ...props }, ref) {
|
||||||
|
const { orientation: parentOrientation } = useStyleContext(SCOPE);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<UISlider.FilledTrack
|
||||||
|
ref={ref}
|
||||||
|
{...props}
|
||||||
|
className={sliderFilledTrackStyle({
|
||||||
|
parentVariants: {
|
||||||
|
orientation: parentOrientation,
|
||||||
|
},
|
||||||
|
class: className,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export { Slider, SliderThumb, SliderTrack, SliderFilledTrack };
|
||||||
12009
ArtisanConnect/package-lock.json
generated
Normal file
12009
ArtisanConnect/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,7 @@
|
|||||||
"@expo/vector-icons": "^14.1.0",
|
"@expo/vector-icons": "^14.1.0",
|
||||||
"@gluestack-style/react": "^1.0.57",
|
"@gluestack-style/react": "^1.0.57",
|
||||||
"@gluestack-ui/actionsheet": "^0.2.53",
|
"@gluestack-ui/actionsheet": "^0.2.53",
|
||||||
|
"@gluestack-ui/avatar": "^0.1.18",
|
||||||
"@gluestack-ui/button": "^1.0.14",
|
"@gluestack-ui/button": "^1.0.14",
|
||||||
"@gluestack-ui/divider": "^0.1.10",
|
"@gluestack-ui/divider": "^0.1.10",
|
||||||
"@gluestack-ui/form-control": "^0.1.19",
|
"@gluestack-ui/form-control": "^0.1.19",
|
||||||
@@ -22,7 +23,9 @@
|
|||||||
"@gluestack-ui/input": "^0.1.38",
|
"@gluestack-ui/input": "^0.1.38",
|
||||||
"@gluestack-ui/nativewind-utils": "^1.0.26",
|
"@gluestack-ui/nativewind-utils": "^1.0.26",
|
||||||
"@gluestack-ui/overlay": "^0.1.22",
|
"@gluestack-ui/overlay": "^0.1.22",
|
||||||
|
"@gluestack-ui/pressable": "^0.1.23",
|
||||||
"@gluestack-ui/select": "^0.1.31",
|
"@gluestack-ui/select": "^0.1.31",
|
||||||
|
"@gluestack-ui/slider": "^0.1.32",
|
||||||
"@gluestack-ui/textarea": "^0.1.25",
|
"@gluestack-ui/textarea": "^0.1.25",
|
||||||
"@gluestack-ui/themed": "^1.1.73",
|
"@gluestack-ui/themed": "^1.1.73",
|
||||||
"@gluestack-ui/toast": "^1.0.9",
|
"@gluestack-ui/toast": "^1.0.9",
|
||||||
@@ -51,6 +54,7 @@
|
|||||||
"react-native": "0.79.2",
|
"react-native": "0.79.2",
|
||||||
"react-native-css-interop": "^0.1.22",
|
"react-native-css-interop": "^0.1.22",
|
||||||
"react-native-gesture-handler": "~2.24.0",
|
"react-native-gesture-handler": "~2.24.0",
|
||||||
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
||||||
"react-native-reanimated": "~3.17.4",
|
"react-native-reanimated": "~3.17.4",
|
||||||
"react-native-safe-area-context": "5.4.0",
|
"react-native-safe-area-context": "5.4.0",
|
||||||
"react-native-screens": "~4.10.0",
|
"react-native-screens": "~4.10.0",
|
||||||
|
|||||||
@@ -1,15 +1,38 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
|
import * as api from "@/api/wishlist";
|
||||||
|
|
||||||
export const useWishlist = create((set) => ({
|
export const useWishlist = create((set) => ({
|
||||||
wishlistNotices: [],
|
wishlistNotices: [],
|
||||||
addNoticeToWishlist: (wishlistNotice) =>
|
toggleNoticeInWishlist: async (noticeId) => {
|
||||||
set((state) => ({
|
try {
|
||||||
wishlistNotices: [...state.wishlistNotices, wishlistNotice],
|
await api.toggleNoticeStatus(noticeId);
|
||||||
})),
|
set((state) => {
|
||||||
removeNoticeFromWishlist: (noticeId) =>
|
const exists = state.wishlistNotices.some(
|
||||||
set((state) => ({
|
(item) => item.noticeId == noticeId
|
||||||
wishlistNotices: state.wishlistNotices.filter(
|
);
|
||||||
(item) => item.noticeId !== noticeId
|
return exists
|
||||||
),
|
? {
|
||||||
})),
|
wishlistNotices: state.wishlistNotices.filter(
|
||||||
|
(item) => item.noticeId != noticeId
|
||||||
|
),
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
wishlistNotices: [
|
||||||
|
...state.wishlistNotices,
|
||||||
|
{ noticeId },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error toggling wishlist notice:", error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fetchWishlist: async () => {
|
||||||
|
try {
|
||||||
|
const data = await api.getWishlist();
|
||||||
|
set({ wishlistNotices: data });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching wishlist:", error);
|
||||||
|
}
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user