@umituz/react-native-ai-generation-content 1.12.4 → 1.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +29 -6
- package/src/domains/creations/application/services/CreationsService.ts +71 -0
- package/src/domains/creations/domain/entities/Creation.ts +51 -0
- package/src/domains/creations/domain/entities/index.ts +6 -0
- package/src/domains/creations/domain/repositories/ICreationsRepository.ts +23 -0
- package/src/domains/creations/domain/repositories/index.ts +5 -0
- package/src/domains/creations/domain/services/ICreationsStorageService.ts +13 -0
- package/src/domains/creations/domain/value-objects/CreationsConfig.ts +76 -0
- package/src/domains/creations/domain/value-objects/index.ts +12 -0
- package/src/domains/creations/index.ts +84 -0
- package/src/domains/creations/infrastructure/adapters/createRepository.ts +54 -0
- package/src/domains/creations/infrastructure/adapters/index.ts +5 -0
- package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +233 -0
- package/src/domains/creations/infrastructure/repositories/index.ts +8 -0
- package/src/domains/creations/infrastructure/services/CreationsStorageService.ts +48 -0
- package/src/domains/creations/presentation/components/CreationCard.tsx +136 -0
- package/src/domains/creations/presentation/components/CreationDetail/DetailActions.tsx +76 -0
- package/src/domains/creations/presentation/components/CreationDetail/DetailHeader.tsx +81 -0
- package/src/domains/creations/presentation/components/CreationDetail/DetailImage.tsx +41 -0
- package/src/domains/creations/presentation/components/CreationDetail/DetailStory.tsx +67 -0
- package/src/domains/creations/presentation/components/CreationDetail/index.ts +4 -0
- package/src/domains/creations/presentation/components/CreationImageViewer.tsx +43 -0
- package/src/domains/creations/presentation/components/CreationThumbnail.tsx +63 -0
- package/src/domains/creations/presentation/components/CreationsGrid.tsx +75 -0
- package/src/domains/creations/presentation/components/CreationsHomeCard.tsx +176 -0
- package/src/domains/creations/presentation/components/EmptyState.tsx +75 -0
- package/src/domains/creations/presentation/components/FilterBottomSheet.tsx +158 -0
- package/src/domains/creations/presentation/components/FilterChips.tsx +105 -0
- package/src/domains/creations/presentation/components/GalleryHeader.tsx +106 -0
- package/src/domains/creations/presentation/components/index.ts +19 -0
- package/src/domains/creations/presentation/hooks/index.ts +7 -0
- package/src/domains/creations/presentation/hooks/useCreations.ts +33 -0
- package/src/domains/creations/presentation/hooks/useCreationsFilter.ts +70 -0
- package/src/domains/creations/presentation/hooks/useDeleteCreation.ts +51 -0
- package/src/domains/creations/presentation/screens/CreationDetailScreen.tsx +71 -0
- package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +217 -0
- package/src/domains/creations/presentation/screens/index.ts +5 -0
- package/src/domains/creations/presentation/utils/filterUtils.ts +52 -0
- package/src/domains/creations/types.d.ts +107 -0
- package/src/domains/face-detection/domain/constants/faceDetectionConstants.ts +16 -0
- package/src/domains/face-detection/domain/entities/FaceDetection.ts +19 -0
- package/src/domains/face-detection/index.ts +26 -0
- package/src/domains/face-detection/infrastructure/analyzers/faceAnalyzer.ts +36 -0
- package/src/domains/face-detection/infrastructure/validators/faceValidator.ts +52 -0
- package/src/domains/face-detection/presentation/components/FaceValidationStatus.tsx +111 -0
- package/src/domains/face-detection/presentation/hooks/useFaceDetection.ts +58 -0
- package/src/domains/feature-background/domain/entities/background.types.ts +77 -0
- package/src/domains/feature-background/domain/entities/component.types.ts +96 -0
- package/src/domains/feature-background/domain/entities/config.types.ts +41 -0
- package/src/domains/feature-background/domain/entities/index.ts +31 -0
- package/src/domains/feature-background/index.ts +72 -0
- package/src/domains/feature-background/infrastructure/constants/index.ts +5 -0
- package/src/domains/feature-background/infrastructure/constants/prompts.constants.ts +15 -0
- package/src/domains/feature-background/presentation/components/BackgroundFeature.tsx +145 -0
- package/src/domains/feature-background/presentation/components/ComparisonSlider.tsx +199 -0
- package/src/domains/feature-background/presentation/components/ErrorDisplay.tsx +58 -0
- package/src/domains/feature-background/presentation/components/FeatureHeader.tsx +80 -0
- package/src/domains/feature-background/presentation/components/GenerateButton.tsx +86 -0
- package/src/domains/feature-background/presentation/components/ImagePicker.tsx +136 -0
- package/src/domains/feature-background/presentation/components/ModeSelector.tsx +78 -0
- package/src/domains/feature-background/presentation/components/ProcessingModal.tsx +113 -0
- package/src/domains/feature-background/presentation/components/PromptInput.tsx +142 -0
- package/src/domains/feature-background/presentation/components/ResultDisplay.tsx +123 -0
- package/src/domains/feature-background/presentation/components/index.ts +16 -0
- package/src/domains/feature-background/presentation/hooks/index.ts +7 -0
- package/src/domains/feature-background/presentation/hooks/useBackgroundFeature.ts +118 -0
- package/src/index.ts +18 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ImageGallery } from "@umituz/react-native-image";
|
|
3
|
+
import type { Creation } from "../../domain/entities/Creation";
|
|
4
|
+
|
|
5
|
+
interface CreationImageViewerProps {
|
|
6
|
+
readonly creations: Creation[];
|
|
7
|
+
readonly visible: boolean;
|
|
8
|
+
readonly index: number;
|
|
9
|
+
readonly enableEditing?: boolean;
|
|
10
|
+
readonly onDismiss: () => void;
|
|
11
|
+
readonly onIndexChange: (index: number) => void;
|
|
12
|
+
readonly onImageEdit?: (uri: string, creationId: string) => void | Promise<void>;
|
|
13
|
+
readonly selectedCreationId?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const CreationImageViewer: React.FC<CreationImageViewerProps> = ({
|
|
17
|
+
creations,
|
|
18
|
+
visible,
|
|
19
|
+
index,
|
|
20
|
+
enableEditing = false,
|
|
21
|
+
onDismiss,
|
|
22
|
+
onIndexChange,
|
|
23
|
+
onImageEdit,
|
|
24
|
+
selectedCreationId,
|
|
25
|
+
}) => {
|
|
26
|
+
const handleImageChange = async (uri: string) => {
|
|
27
|
+
if (selectedCreationId && onImageEdit) {
|
|
28
|
+
await onImageEdit(uri, selectedCreationId);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<ImageGallery
|
|
34
|
+
images={creations.map((c) => ({ uri: c.uri }))}
|
|
35
|
+
visible={visible}
|
|
36
|
+
index={index}
|
|
37
|
+
onDismiss={onDismiss}
|
|
38
|
+
onIndexChange={onIndexChange}
|
|
39
|
+
{...(enableEditing && { enableEditing } as any)}
|
|
40
|
+
{...(onImageEdit && { onImageChange: handleImageChange } as any)}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CreationThumbnail Component
|
|
3
|
+
* Displays a single creation thumbnail
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useMemo, useState } from "react";
|
|
7
|
+
import { Image, TouchableOpacity, StyleSheet, View } from "react-native";
|
|
8
|
+
import {
|
|
9
|
+
useAppDesignTokens,
|
|
10
|
+
AtomicIcon,
|
|
11
|
+
} from "@umituz/react-native-design-system";
|
|
12
|
+
|
|
13
|
+
interface CreationThumbnailProps {
|
|
14
|
+
readonly uri: string;
|
|
15
|
+
readonly size?: number;
|
|
16
|
+
readonly onPress?: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function CreationThumbnail({
|
|
20
|
+
uri,
|
|
21
|
+
size = 72,
|
|
22
|
+
onPress,
|
|
23
|
+
}: CreationThumbnailProps) {
|
|
24
|
+
const tokens = useAppDesignTokens();
|
|
25
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
26
|
+
|
|
27
|
+
const styles = useMemo(
|
|
28
|
+
() =>
|
|
29
|
+
StyleSheet.create({
|
|
30
|
+
thumbnail: {
|
|
31
|
+
width: size,
|
|
32
|
+
height: size,
|
|
33
|
+
borderRadius: tokens.spacing.sm,
|
|
34
|
+
backgroundColor: tokens.colors.backgroundSecondary,
|
|
35
|
+
},
|
|
36
|
+
overlay: {
|
|
37
|
+
...StyleSheet.absoluteFillObject,
|
|
38
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
39
|
+
borderRadius: tokens.spacing.sm,
|
|
40
|
+
justifyContent: "center",
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
[tokens, size]
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<TouchableOpacity
|
|
49
|
+
onPress={onPress}
|
|
50
|
+
disabled={!onPress}
|
|
51
|
+
onPressIn={() => setIsPressed(true)}
|
|
52
|
+
onPressOut={() => setIsPressed(false)}
|
|
53
|
+
activeOpacity={1}
|
|
54
|
+
>
|
|
55
|
+
<Image source={{ uri }} style={styles.thumbnail} />
|
|
56
|
+
{isPressed && onPress && (
|
|
57
|
+
<View style={styles.overlay}>
|
|
58
|
+
<AtomicIcon name="eye" size="lg" color="textInverse" />
|
|
59
|
+
</View>
|
|
60
|
+
)}
|
|
61
|
+
</TouchableOpacity>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlatList, RefreshControl, StyleSheet } from 'react-native';
|
|
3
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
4
|
+
import type { Creation } from "../../domain/entities/Creation";
|
|
5
|
+
import type { CreationType } from "../../domain/value-objects/CreationsConfig";
|
|
6
|
+
import { CreationCard } from "./CreationCard";
|
|
7
|
+
|
|
8
|
+
interface CreationsGridProps {
|
|
9
|
+
readonly creations: Creation[];
|
|
10
|
+
readonly types: readonly CreationType[];
|
|
11
|
+
readonly isLoading: boolean;
|
|
12
|
+
readonly onRefresh: () => void;
|
|
13
|
+
readonly onView: (creation: Creation) => void;
|
|
14
|
+
readonly onShare: (creation: Creation) => void;
|
|
15
|
+
readonly onDelete: (creation: Creation) => void;
|
|
16
|
+
readonly contentContainerStyle?: any;
|
|
17
|
+
readonly ListEmptyComponent?: React.ReactElement | null;
|
|
18
|
+
readonly ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const CreationsGrid: React.FC<CreationsGridProps> = ({
|
|
22
|
+
creations,
|
|
23
|
+
types,
|
|
24
|
+
isLoading,
|
|
25
|
+
onRefresh,
|
|
26
|
+
onView,
|
|
27
|
+
onShare,
|
|
28
|
+
onDelete,
|
|
29
|
+
contentContainerStyle,
|
|
30
|
+
ListEmptyComponent,
|
|
31
|
+
ListHeaderComponent,
|
|
32
|
+
}) => {
|
|
33
|
+
const tokens = useAppDesignTokens();
|
|
34
|
+
const styles = useStyles(tokens);
|
|
35
|
+
|
|
36
|
+
const renderItem = ({ item }: { item: Creation }) => (
|
|
37
|
+
<CreationCard
|
|
38
|
+
creation={item}
|
|
39
|
+
types={types as CreationType[]}
|
|
40
|
+
onView={() => onView(item)}
|
|
41
|
+
onShare={() => onShare(item)}
|
|
42
|
+
onDelete={() => onDelete(item)}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<FlatList
|
|
48
|
+
data={creations}
|
|
49
|
+
renderItem={renderItem}
|
|
50
|
+
keyExtractor={(item) => item.id}
|
|
51
|
+
ListHeaderComponent={ListHeaderComponent}
|
|
52
|
+
ListEmptyComponent={ListEmptyComponent}
|
|
53
|
+
contentContainerStyle={[
|
|
54
|
+
styles.list,
|
|
55
|
+
contentContainerStyle,
|
|
56
|
+
(!creations || creations.length === 0) && { flexGrow: 1 }
|
|
57
|
+
]}
|
|
58
|
+
showsVerticalScrollIndicator={false}
|
|
59
|
+
refreshControl={
|
|
60
|
+
<RefreshControl
|
|
61
|
+
refreshing={isLoading}
|
|
62
|
+
onRefresh={onRefresh}
|
|
63
|
+
tintColor={tokens.colors.primary}
|
|
64
|
+
/>
|
|
65
|
+
}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const useStyles = (tokens: any) => StyleSheet.create({
|
|
71
|
+
list: {
|
|
72
|
+
padding: tokens.spacing.md,
|
|
73
|
+
paddingBottom: 100, // Space for fab or bottom tab
|
|
74
|
+
},
|
|
75
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CreationsHomeCard Component
|
|
3
|
+
* Shows user's creations preview on home screen
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
declare const __DEV__: boolean;
|
|
7
|
+
|
|
8
|
+
import React, { useMemo, useCallback } from "react";
|
|
9
|
+
import { View, TouchableOpacity, FlatList, StyleSheet } from "react-native";
|
|
10
|
+
import {
|
|
11
|
+
AtomicText,
|
|
12
|
+
AtomicIcon,
|
|
13
|
+
useAppDesignTokens,
|
|
14
|
+
} from "@umituz/react-native-design-system";
|
|
15
|
+
import type { Creation } from "../../domain/entities/Creation";
|
|
16
|
+
import { CreationThumbnail } from "./CreationThumbnail";
|
|
17
|
+
|
|
18
|
+
interface CreationsHomeCardProps {
|
|
19
|
+
readonly creations: Creation[] | undefined;
|
|
20
|
+
readonly isLoading: boolean;
|
|
21
|
+
readonly title: string;
|
|
22
|
+
readonly countLabel: string;
|
|
23
|
+
readonly loadingLabel: string;
|
|
24
|
+
readonly maxThumbnails?: number;
|
|
25
|
+
readonly onPress: () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function CreationsHomeCard({
|
|
29
|
+
creations,
|
|
30
|
+
isLoading,
|
|
31
|
+
title,
|
|
32
|
+
countLabel,
|
|
33
|
+
loadingLabel,
|
|
34
|
+
maxThumbnails = 4,
|
|
35
|
+
onPress,
|
|
36
|
+
}: CreationsHomeCardProps) {
|
|
37
|
+
const tokens = useAppDesignTokens();
|
|
38
|
+
|
|
39
|
+
if (__DEV__) {
|
|
40
|
+
console.log("[CreationsHomeCard] Render:", {
|
|
41
|
+
isLoading,
|
|
42
|
+
count: creations?.length ?? 0,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const styles = useMemo(
|
|
47
|
+
() =>
|
|
48
|
+
StyleSheet.create({
|
|
49
|
+
container: {
|
|
50
|
+
backgroundColor: tokens.colors.surface,
|
|
51
|
+
borderRadius: tokens.spacing.md,
|
|
52
|
+
padding: tokens.spacing.md,
|
|
53
|
+
},
|
|
54
|
+
header: {
|
|
55
|
+
flexDirection: "row",
|
|
56
|
+
justifyContent: "space-between",
|
|
57
|
+
alignItems: "center",
|
|
58
|
+
marginBottom: tokens.spacing.md,
|
|
59
|
+
},
|
|
60
|
+
headerLeft: {
|
|
61
|
+
flexDirection: "row",
|
|
62
|
+
alignItems: "center",
|
|
63
|
+
gap: tokens.spacing.sm,
|
|
64
|
+
},
|
|
65
|
+
icon: {
|
|
66
|
+
fontSize: 20,
|
|
67
|
+
},
|
|
68
|
+
title: {
|
|
69
|
+
...tokens.typography.bodyLarge,
|
|
70
|
+
fontWeight: "600",
|
|
71
|
+
color: tokens.colors.textPrimary,
|
|
72
|
+
},
|
|
73
|
+
viewAll: {
|
|
74
|
+
flexDirection: "row",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
gap: tokens.spacing.xs,
|
|
77
|
+
},
|
|
78
|
+
count: {
|
|
79
|
+
...tokens.typography.bodySmall,
|
|
80
|
+
color: tokens.colors.textSecondary,
|
|
81
|
+
},
|
|
82
|
+
thumbnailList: {
|
|
83
|
+
gap: tokens.spacing.sm,
|
|
84
|
+
},
|
|
85
|
+
loadingText: {
|
|
86
|
+
...tokens.typography.bodySmall,
|
|
87
|
+
color: tokens.colors.textSecondary,
|
|
88
|
+
textAlign: "center",
|
|
89
|
+
padding: tokens.spacing.md,
|
|
90
|
+
},
|
|
91
|
+
moreBadge: {
|
|
92
|
+
width: 72,
|
|
93
|
+
height: 72,
|
|
94
|
+
borderRadius: tokens.spacing.sm,
|
|
95
|
+
backgroundColor: tokens.colors.backgroundSecondary,
|
|
96
|
+
justifyContent: "center",
|
|
97
|
+
alignItems: "center",
|
|
98
|
+
},
|
|
99
|
+
moreText: {
|
|
100
|
+
...tokens.typography.bodySmall,
|
|
101
|
+
fontWeight: "600",
|
|
102
|
+
color: tokens.colors.primary,
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
[tokens],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const displayItems = useMemo(() => {
|
|
109
|
+
if (!creations) return [];
|
|
110
|
+
return creations.slice(0, maxThumbnails);
|
|
111
|
+
}, [creations, maxThumbnails]);
|
|
112
|
+
|
|
113
|
+
const renderItem = useCallback(
|
|
114
|
+
({ item, index }: { item: Creation; index: number }) => {
|
|
115
|
+
const isLast = index === maxThumbnails - 1;
|
|
116
|
+
const hasMore = creations && creations.length > maxThumbnails;
|
|
117
|
+
|
|
118
|
+
if (isLast && hasMore) {
|
|
119
|
+
return (
|
|
120
|
+
<TouchableOpacity style={styles.moreBadge} onPress={onPress}>
|
|
121
|
+
<AtomicText style={styles.moreText}>
|
|
122
|
+
+{creations.length - maxThumbnails + 1}
|
|
123
|
+
</AtomicText>
|
|
124
|
+
</TouchableOpacity>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return <CreationThumbnail uri={item.uri} onPress={onPress} />;
|
|
129
|
+
},
|
|
130
|
+
[styles, creations, maxThumbnails, onPress],
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
if (isLoading) {
|
|
134
|
+
return (
|
|
135
|
+
<View style={styles.container}>
|
|
136
|
+
<AtomicText style={styles.loadingText}>{loadingLabel}</AtomicText>
|
|
137
|
+
</View>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (!creations || creations.length === 0) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const count = creations.length;
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<TouchableOpacity
|
|
149
|
+
style={styles.container}
|
|
150
|
+
onPress={onPress}
|
|
151
|
+
activeOpacity={0.8}
|
|
152
|
+
>
|
|
153
|
+
<View style={styles.header}>
|
|
154
|
+
<View style={styles.headerLeft}>
|
|
155
|
+
<AtomicText style={styles.icon}>🎨</AtomicText>
|
|
156
|
+
<AtomicText style={styles.title}>{title}</AtomicText>
|
|
157
|
+
</View>
|
|
158
|
+
<TouchableOpacity style={styles.viewAll} onPress={onPress}>
|
|
159
|
+
<AtomicText style={styles.count}>
|
|
160
|
+
{countLabel.replace("{{count}}", String(count))}
|
|
161
|
+
</AtomicText>
|
|
162
|
+
<AtomicIcon name="chevron-forward" size="sm" color="primary" />
|
|
163
|
+
</TouchableOpacity>
|
|
164
|
+
</View>
|
|
165
|
+
<FlatList
|
|
166
|
+
data={displayItems}
|
|
167
|
+
renderItem={renderItem}
|
|
168
|
+
keyExtractor={(item) => item.id}
|
|
169
|
+
horizontal
|
|
170
|
+
showsHorizontalScrollIndicator={false}
|
|
171
|
+
contentContainerStyle={styles.thumbnailList}
|
|
172
|
+
scrollEnabled={false}
|
|
173
|
+
/>
|
|
174
|
+
</TouchableOpacity>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmptyState Component
|
|
3
|
+
* Displays when no creations exist
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useMemo } from "react";
|
|
7
|
+
import { View, StyleSheet } from "react-native";
|
|
8
|
+
import { AtomicText, AtomicButton, AtomicIcon, useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
|
+
|
|
10
|
+
interface EmptyStateProps {
|
|
11
|
+
readonly title: string;
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly iconName?: string;
|
|
14
|
+
readonly actionLabel?: string;
|
|
15
|
+
readonly onAction?: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function EmptyState({
|
|
19
|
+
title,
|
|
20
|
+
description,
|
|
21
|
+
iconName = "images-outline",
|
|
22
|
+
actionLabel,
|
|
23
|
+
onAction,
|
|
24
|
+
}: EmptyStateProps) {
|
|
25
|
+
const tokens = useAppDesignTokens();
|
|
26
|
+
|
|
27
|
+
const styles = useMemo(
|
|
28
|
+
() =>
|
|
29
|
+
StyleSheet.create({
|
|
30
|
+
container: {
|
|
31
|
+
flex: 1,
|
|
32
|
+
justifyContent: "center",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
padding: tokens.spacing.xl,
|
|
35
|
+
},
|
|
36
|
+
iconContainer: {
|
|
37
|
+
marginBottom: tokens.spacing.lg,
|
|
38
|
+
},
|
|
39
|
+
title: {
|
|
40
|
+
...tokens.typography.headingSmall,
|
|
41
|
+
color: tokens.colors.textPrimary,
|
|
42
|
+
textAlign: "center",
|
|
43
|
+
marginBottom: tokens.spacing.sm,
|
|
44
|
+
},
|
|
45
|
+
description: {
|
|
46
|
+
...tokens.typography.bodyMedium,
|
|
47
|
+
color: tokens.colors.textSecondary,
|
|
48
|
+
textAlign: "center",
|
|
49
|
+
marginBottom: onAction ? tokens.spacing.xl : 0,
|
|
50
|
+
},
|
|
51
|
+
button: {
|
|
52
|
+
minWidth: 160,
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
[tokens, onAction],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<View style={styles.container}>
|
|
60
|
+
<View style={styles.iconContainer}>
|
|
61
|
+
<AtomicIcon name={iconName} size={64} color="secondary" />
|
|
62
|
+
</View>
|
|
63
|
+
<AtomicText style={styles.title}>{title}</AtomicText>
|
|
64
|
+
<AtomicText style={styles.description}>{description}</AtomicText>
|
|
65
|
+
{onAction && actionLabel && (
|
|
66
|
+
<AtomicButton
|
|
67
|
+
title={actionLabel}
|
|
68
|
+
onPress={onAction}
|
|
69
|
+
variant="primary"
|
|
70
|
+
style={styles.button}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</View>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
2
|
+
import { View, StyleSheet, TouchableOpacity, ScrollView } from 'react-native';
|
|
3
|
+
import { BottomSheetModal, BottomSheetModalRef } from '@umituz/react-native-bottom-sheet';
|
|
4
|
+
import { useAppDesignTokens, AtomicText, AtomicIcon } from '@umituz/react-native-design-system';
|
|
5
|
+
|
|
6
|
+
export interface FilterOption {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface FilterCategory {
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
multiSelect?: boolean;
|
|
16
|
+
options: FilterOption[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface FilterBottomSheetProps {
|
|
20
|
+
categories: FilterCategory[];
|
|
21
|
+
selectedIds: string[];
|
|
22
|
+
onFilterPress: (id: string, categoryId: string) => void;
|
|
23
|
+
onClearFilters: () => void;
|
|
24
|
+
title: string;
|
|
25
|
+
snapPoints?: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const FilterBottomSheet = forwardRef<BottomSheetModalRef, FilterBottomSheetProps>((props, ref) => {
|
|
29
|
+
const { categories, selectedIds, onFilterPress, onClearFilters, title, snapPoints: propSnapPoints } = props;
|
|
30
|
+
const tokens = useAppDesignTokens();
|
|
31
|
+
const styles = useStyles(tokens);
|
|
32
|
+
|
|
33
|
+
const snapPoints = useMemo(() => propSnapPoints || ['50%', '75%'], [propSnapPoints]);
|
|
34
|
+
|
|
35
|
+
const renderOption = useCallback((option: FilterOption, category: FilterCategory) => {
|
|
36
|
+
const isSelected = selectedIds.includes(option.id);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<TouchableOpacity
|
|
40
|
+
key={option.id}
|
|
41
|
+
style={[styles.option, isSelected && styles.optionSelected]}
|
|
42
|
+
onPress={() => onFilterPress(option.id, category.id)}
|
|
43
|
+
>
|
|
44
|
+
<View style={styles.optionContent}>
|
|
45
|
+
{option.icon && (
|
|
46
|
+
<View style={styles.optionIcon}>
|
|
47
|
+
<AtomicIcon
|
|
48
|
+
name={option.icon as any}
|
|
49
|
+
size="sm"
|
|
50
|
+
color={isSelected ? "primary" : "onSurface"}
|
|
51
|
+
/>
|
|
52
|
+
</View>
|
|
53
|
+
)}
|
|
54
|
+
<AtomicText
|
|
55
|
+
style={[styles.optionLabel, isSelected && styles.optionLabelSelected]}
|
|
56
|
+
>
|
|
57
|
+
{option.label}
|
|
58
|
+
</AtomicText>
|
|
59
|
+
</View>
|
|
60
|
+
{isSelected && (
|
|
61
|
+
<AtomicIcon name="check" size="sm" color="primary" />
|
|
62
|
+
)}
|
|
63
|
+
</TouchableOpacity>
|
|
64
|
+
);
|
|
65
|
+
}, [onFilterPress, selectedIds, styles]);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<BottomSheetModal
|
|
69
|
+
ref={ref}
|
|
70
|
+
snapPoints={snapPoints}
|
|
71
|
+
>
|
|
72
|
+
<View style={styles.header}>
|
|
73
|
+
<AtomicText style={styles.headerTitle}>{title}</AtomicText>
|
|
74
|
+
<TouchableOpacity onPress={onClearFilters}>
|
|
75
|
+
<AtomicText style={styles.clearButton}>Clear</AtomicText>
|
|
76
|
+
</TouchableOpacity>
|
|
77
|
+
</View>
|
|
78
|
+
|
|
79
|
+
<ScrollView contentContainerStyle={styles.content}>
|
|
80
|
+
{categories.map(category => (
|
|
81
|
+
<View key={category.id} style={styles.categoryContainer}>
|
|
82
|
+
<AtomicText style={styles.categoryTitle}>{category.title}</AtomicText>
|
|
83
|
+
<View style={styles.optionsContainer}>
|
|
84
|
+
{category.options.map(option => renderOption(option, category))}
|
|
85
|
+
</View>
|
|
86
|
+
</View>
|
|
87
|
+
))}
|
|
88
|
+
</ScrollView>
|
|
89
|
+
</BottomSheetModal>
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const useStyles = (tokens: any) => StyleSheet.create({
|
|
94
|
+
content: {
|
|
95
|
+
padding: tokens.spacing.md,
|
|
96
|
+
paddingBottom: tokens.spacing.xl,
|
|
97
|
+
},
|
|
98
|
+
header: {
|
|
99
|
+
flexDirection: 'row',
|
|
100
|
+
justifyContent: 'space-between',
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
paddingHorizontal: tokens.spacing.md,
|
|
103
|
+
paddingBottom: tokens.spacing.sm,
|
|
104
|
+
borderBottomWidth: 1,
|
|
105
|
+
borderBottomColor: tokens.colors.outline,
|
|
106
|
+
},
|
|
107
|
+
headerTitle: {
|
|
108
|
+
fontSize: 20,
|
|
109
|
+
fontWeight: '700',
|
|
110
|
+
color: tokens.colors.textPrimary,
|
|
111
|
+
},
|
|
112
|
+
clearButton: {
|
|
113
|
+
color: tokens.colors.primary,
|
|
114
|
+
fontSize: 14,
|
|
115
|
+
fontWeight: '600',
|
|
116
|
+
},
|
|
117
|
+
categoryContainer: {
|
|
118
|
+
marginTop: tokens.spacing.md,
|
|
119
|
+
},
|
|
120
|
+
categoryTitle: {
|
|
121
|
+
marginBottom: tokens.spacing.xs,
|
|
122
|
+
color: tokens.colors.textSecondary,
|
|
123
|
+
fontSize: 16,
|
|
124
|
+
fontWeight: '600',
|
|
125
|
+
},
|
|
126
|
+
optionsContainer: {
|
|
127
|
+
backgroundColor: tokens.colors.background,
|
|
128
|
+
borderRadius: tokens.borderRadius.md,
|
|
129
|
+
overflow: 'hidden',
|
|
130
|
+
},
|
|
131
|
+
option: {
|
|
132
|
+
flexDirection: 'row',
|
|
133
|
+
alignItems: 'center',
|
|
134
|
+
justifyContent: 'space-between',
|
|
135
|
+
padding: tokens.spacing.md,
|
|
136
|
+
backgroundColor: tokens.colors.background,
|
|
137
|
+
borderBottomWidth: 1,
|
|
138
|
+
borderBottomColor: tokens.colors.surface,
|
|
139
|
+
},
|
|
140
|
+
optionSelected: {
|
|
141
|
+
backgroundColor: tokens.colors.surface,
|
|
142
|
+
},
|
|
143
|
+
optionContent: {
|
|
144
|
+
flexDirection: 'row',
|
|
145
|
+
alignItems: 'center',
|
|
146
|
+
},
|
|
147
|
+
optionIcon: {
|
|
148
|
+
marginRight: tokens.spacing.sm,
|
|
149
|
+
},
|
|
150
|
+
optionLabel: {
|
|
151
|
+
color: tokens.colors.text,
|
|
152
|
+
fontSize: 14,
|
|
153
|
+
},
|
|
154
|
+
optionLabelSelected: {
|
|
155
|
+
color: tokens.colors.primary,
|
|
156
|
+
fontWeight: 'bold',
|
|
157
|
+
},
|
|
158
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FilterChips Component
|
|
3
|
+
* Displays filter chips for creation types
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useMemo } from "react";
|
|
7
|
+
import { View, TouchableOpacity, StyleSheet, ScrollView } from "react-native";
|
|
8
|
+
import { AtomicText, useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
|
+
import type { CreationType } from "../../domain/value-objects/CreationsConfig";
|
|
10
|
+
|
|
11
|
+
interface FilterChipsProps {
|
|
12
|
+
readonly types: readonly CreationType[];
|
|
13
|
+
readonly availableTypes: string[];
|
|
14
|
+
readonly selectedType: string;
|
|
15
|
+
readonly allLabel: string;
|
|
16
|
+
readonly onSelect: (type: string) => void;
|
|
17
|
+
readonly style?: any;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function FilterChips({
|
|
21
|
+
types,
|
|
22
|
+
availableTypes,
|
|
23
|
+
selectedType,
|
|
24
|
+
allLabel,
|
|
25
|
+
onSelect,
|
|
26
|
+
style,
|
|
27
|
+
}: FilterChipsProps) {
|
|
28
|
+
const tokens = useAppDesignTokens();
|
|
29
|
+
|
|
30
|
+
const styles = useMemo(
|
|
31
|
+
() =>
|
|
32
|
+
StyleSheet.create({
|
|
33
|
+
container: {
|
|
34
|
+
marginBottom: tokens.spacing.md,
|
|
35
|
+
},
|
|
36
|
+
scrollContent: {
|
|
37
|
+
paddingHorizontal: tokens.spacing.md,
|
|
38
|
+
gap: tokens.spacing.sm,
|
|
39
|
+
flexDirection: "row",
|
|
40
|
+
},
|
|
41
|
+
chip: {
|
|
42
|
+
paddingHorizontal: tokens.spacing.md,
|
|
43
|
+
paddingVertical: tokens.spacing.sm,
|
|
44
|
+
borderRadius: tokens.spacing.lg,
|
|
45
|
+
backgroundColor: tokens.colors.backgroundSecondary,
|
|
46
|
+
},
|
|
47
|
+
chipSelected: {
|
|
48
|
+
backgroundColor: tokens.colors.primary,
|
|
49
|
+
},
|
|
50
|
+
chipText: {
|
|
51
|
+
...tokens.typography.bodySmall,
|
|
52
|
+
color: tokens.colors.textSecondary,
|
|
53
|
+
},
|
|
54
|
+
chipTextSelected: {
|
|
55
|
+
color: tokens.colors.textInverse,
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
[tokens],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const visibleTypes = types.filter((t) => availableTypes.includes(t.id));
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<View style={[styles.container, style]}>
|
|
65
|
+
<ScrollView
|
|
66
|
+
horizontal
|
|
67
|
+
showsHorizontalScrollIndicator={false}
|
|
68
|
+
contentContainerStyle={styles.scrollContent}
|
|
69
|
+
>
|
|
70
|
+
<TouchableOpacity
|
|
71
|
+
style={[styles.chip, selectedType === "all" && styles.chipSelected]}
|
|
72
|
+
onPress={() => onSelect("all")}
|
|
73
|
+
>
|
|
74
|
+
<AtomicText
|
|
75
|
+
style={[
|
|
76
|
+
styles.chipText,
|
|
77
|
+
selectedType === "all" && styles.chipTextSelected,
|
|
78
|
+
]}
|
|
79
|
+
>
|
|
80
|
+
{allLabel}
|
|
81
|
+
</AtomicText>
|
|
82
|
+
</TouchableOpacity>
|
|
83
|
+
{visibleTypes.map((type) => (
|
|
84
|
+
<TouchableOpacity
|
|
85
|
+
key={type.id}
|
|
86
|
+
style={[
|
|
87
|
+
styles.chip,
|
|
88
|
+
selectedType === type.id && styles.chipSelected,
|
|
89
|
+
]}
|
|
90
|
+
onPress={() => onSelect(type.id)}
|
|
91
|
+
>
|
|
92
|
+
<AtomicText
|
|
93
|
+
style={[
|
|
94
|
+
styles.chipText,
|
|
95
|
+
selectedType === type.id && styles.chipTextSelected,
|
|
96
|
+
]}
|
|
97
|
+
>
|
|
98
|
+
{type.icon} {type.labelKey}
|
|
99
|
+
</AtomicText>
|
|
100
|
+
</TouchableOpacity>
|
|
101
|
+
))}
|
|
102
|
+
</ScrollView>
|
|
103
|
+
</View>
|
|
104
|
+
);
|
|
105
|
+
}
|