@umituz/react-native-ai-generation-content 1.12.21 → 1.12.24

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.
Files changed (132) hide show
  1. package/package.json +33 -15
  2. package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts +4 -32
  3. package/src/domains/content-moderation/infrastructure/services/moderators/base.moderator.ts +1 -1
  4. package/src/domains/face-detection/infrastructure/validators/faceValidator.ts +1 -1
  5. package/src/domains/face-detection/presentation/components/FaceValidationStatus.tsx +3 -3
  6. package/src/domains/prompts/domain/entities/FuturePredictionConfig.ts +2 -1
  7. package/src/domains/prompts/domain/entities/GeneratedPrompt.ts +0 -1
  8. package/src/domains/prompts/domain/repositories/IAIPromptServices.ts +6 -12
  9. package/src/domains/prompts/infrastructure/repositories/PromptHistoryRepository.ts +42 -42
  10. package/src/domains/prompts/infrastructure/repositories/TemplateRepository.ts +42 -42
  11. package/src/domains/prompts/infrastructure/services/BackgroundRemovalService.ts +7 -7
  12. package/src/domains/prompts/infrastructure/services/ColorizationService.ts +7 -7
  13. package/src/domains/prompts/infrastructure/services/FaceSwapService.ts +19 -20
  14. package/src/domains/prompts/infrastructure/services/FuturePredictionService.ts +11 -31
  15. package/src/domains/prompts/infrastructure/services/ImageEnhancementService.ts +7 -7
  16. package/src/domains/prompts/infrastructure/services/PhotoRestorationService.ts +7 -7
  17. package/src/domains/prompts/infrastructure/services/PromptGenerationService.ts +13 -13
  18. package/src/domains/prompts/infrastructure/services/StyleTransferService.ts +8 -8
  19. package/src/domains/prompts/infrastructure/services/TextGenerationService.ts +7 -7
  20. package/src/domains/prompts/presentation/hooks/useAIServices.ts +30 -28
  21. package/src/domains/prompts/presentation/hooks/useFaceSwap.ts +1 -2
  22. package/src/domains/prompts/presentation/hooks/usePromptGeneration.ts +4 -5
  23. package/src/domains/prompts/presentation/hooks/useStyleTransfer.ts +1 -1
  24. package/src/domains/prompts/presentation/hooks/useTemplateRepository.ts +3 -3
  25. package/src/domains/prompts/presentation/theme/utils.ts +1 -1
  26. package/src/features/audio-generation/domain/entities.ts +39 -0
  27. package/src/features/audio-generation/index.ts +2 -0
  28. package/src/features/audio-generation/presentation/hooks.ts +39 -0
  29. package/src/{domains/feature-background → features/background}/presentation/components/BackgroundFeature.tsx +5 -4
  30. package/src/{domains/feature-background → features/background}/presentation/components/ComparisonSlider.tsx +45 -51
  31. package/src/{domains/feature-background → features/background}/presentation/components/ErrorDisplay.tsx +5 -3
  32. package/src/{domains/feature-background → features/background}/presentation/components/ModeSelector.tsx +2 -2
  33. package/src/{domains/feature-background → features/background}/presentation/hooks/useBackgroundFeature.ts +3 -2
  34. package/src/features/colorization/domain/entities.ts +46 -0
  35. package/src/features/colorization/index.ts +2 -0
  36. package/src/features/colorization/presentation/hooks.ts +39 -0
  37. package/src/features/face-swap/domain/entities.ts +48 -0
  38. package/src/features/face-swap/index.ts +2 -0
  39. package/src/features/face-swap/presentation/hooks.ts +41 -0
  40. package/src/features/future-prediction/domain/entities.ts +45 -0
  41. package/src/features/future-prediction/index.ts +2 -0
  42. package/src/features/future-prediction/presentation/hooks.ts +39 -0
  43. package/src/features/image-captioning/domain/entities.ts +47 -0
  44. package/src/features/image-captioning/index.ts +2 -0
  45. package/src/features/image-captioning/presentation/hooks.ts +39 -0
  46. package/src/features/inpainting/domain/entities.ts +58 -0
  47. package/src/features/inpainting/index.ts +2 -0
  48. package/src/features/inpainting/presentation/hooks.ts +39 -0
  49. package/src/features/photo-restoration/domain/entities.ts +48 -0
  50. package/src/features/photo-restoration/index.ts +2 -0
  51. package/src/features/photo-restoration/presentation/hooks.ts +39 -0
  52. package/src/features/sketch-to-image/domain/entities.ts +47 -0
  53. package/src/features/sketch-to-image/index.ts +2 -0
  54. package/src/features/sketch-to-image/presentation/hooks.ts +39 -0
  55. package/src/features/style-transfer/domain/entities.ts +52 -0
  56. package/src/features/style-transfer/index.ts +2 -0
  57. package/src/features/style-transfer/presentation/hooks.ts +39 -0
  58. package/src/features/text-to-image/domain/entities.ts +58 -0
  59. package/src/features/text-to-image/index.ts +2 -0
  60. package/src/features/text-to-image/presentation/hooks.ts +39 -0
  61. package/src/features/text-to-video/domain/entities.ts +52 -0
  62. package/src/features/text-to-video/index.ts +2 -0
  63. package/src/features/text-to-video/presentation/hooks.ts +39 -0
  64. package/src/features/upscaling/domain/entities.ts +42 -0
  65. package/src/features/upscaling/index.ts +2 -0
  66. package/src/features/upscaling/presentation/hooks.ts +39 -0
  67. package/src/index.ts +3 -6
  68. package/src/infrastructure/utils/status-checker.util.ts +4 -4
  69. package/src/infrastructure/wrappers/synchronous-generation.wrapper.ts +3 -3
  70. package/src/presentation/components/result/GenerationResultContent.tsx +21 -22
  71. package/src/presentation/components/result/ResultActions.tsx +51 -52
  72. package/src/presentation/components/result/ResultHeader.tsx +24 -25
  73. package/src/presentation/components/result/ResultImageCard.tsx +19 -20
  74. package/src/presentation/components/result/ResultStoryCard.tsx +23 -24
  75. package/src/presentation/hooks/photo-generation.types.ts +13 -4
  76. package/src/presentation/hooks/usePhotoGeneration.ts +30 -13
  77. package/src/domains/creations/application/services/CreationsService.ts +0 -72
  78. package/src/domains/creations/domain/entities/Creation.ts +0 -54
  79. package/src/domains/creations/domain/entities/index.ts +0 -6
  80. package/src/domains/creations/domain/repositories/ICreationsRepository.ts +0 -25
  81. package/src/domains/creations/domain/repositories/index.ts +0 -5
  82. package/src/domains/creations/domain/services/ICreationsStorageService.ts +0 -13
  83. package/src/domains/creations/domain/value-objects/CreationsConfig.ts +0 -77
  84. package/src/domains/creations/domain/value-objects/index.ts +0 -12
  85. package/src/domains/creations/index.ts +0 -84
  86. package/src/domains/creations/infrastructure/adapters/createRepository.ts +0 -54
  87. package/src/domains/creations/infrastructure/adapters/index.ts +0 -5
  88. package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +0 -263
  89. package/src/domains/creations/infrastructure/repositories/index.ts +0 -8
  90. package/src/domains/creations/infrastructure/services/CreationsStorageService.ts +0 -48
  91. package/src/domains/creations/presentation/components/CreationCard.tsx +0 -196
  92. package/src/domains/creations/presentation/components/CreationDetail/DetailActions.tsx +0 -76
  93. package/src/domains/creations/presentation/components/CreationDetail/DetailHeader.tsx +0 -81
  94. package/src/domains/creations/presentation/components/CreationDetail/DetailImage.tsx +0 -41
  95. package/src/domains/creations/presentation/components/CreationDetail/DetailStory.tsx +0 -67
  96. package/src/domains/creations/presentation/components/CreationDetail/index.ts +0 -4
  97. package/src/domains/creations/presentation/components/CreationImageViewer.tsx +0 -101
  98. package/src/domains/creations/presentation/components/CreationThumbnail.tsx +0 -63
  99. package/src/domains/creations/presentation/components/CreationsGalleryEmptyState.tsx +0 -77
  100. package/src/domains/creations/presentation/components/CreationsGrid.tsx +0 -87
  101. package/src/domains/creations/presentation/components/CreationsHomeCard.tsx +0 -176
  102. package/src/domains/creations/presentation/components/EmptyState.tsx +0 -75
  103. package/src/domains/creations/presentation/components/FilterBottomSheet.tsx +0 -157
  104. package/src/domains/creations/presentation/components/FilterChips.tsx +0 -105
  105. package/src/domains/creations/presentation/components/GalleryHeader.tsx +0 -157
  106. package/src/domains/creations/presentation/components/index.ts +0 -20
  107. package/src/domains/creations/presentation/hooks/index.ts +0 -9
  108. package/src/domains/creations/presentation/hooks/useCreations.ts +0 -33
  109. package/src/domains/creations/presentation/hooks/useCreationsFilter.ts +0 -90
  110. package/src/domains/creations/presentation/hooks/useDeleteCreation.ts +0 -51
  111. package/src/domains/creations/presentation/hooks/useDeleteMultipleCreations.ts +0 -57
  112. package/src/domains/creations/presentation/hooks/useToggleFavorite.ts +0 -59
  113. package/src/domains/creations/presentation/screens/CreationDetailScreen.tsx +0 -71
  114. package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +0 -264
  115. package/src/domains/creations/presentation/screens/index.ts +0 -5
  116. package/src/domains/creations/presentation/utils/filterUtils.ts +0 -52
  117. package/src/domains/creations/types.d.ts +0 -107
  118. /package/src/{domains/feature-background → features/background}/domain/entities/background.types.ts +0 -0
  119. /package/src/{domains/feature-background → features/background}/domain/entities/component.types.ts +0 -0
  120. /package/src/{domains/feature-background → features/background}/domain/entities/config.types.ts +0 -0
  121. /package/src/{domains/feature-background → features/background}/domain/entities/index.ts +0 -0
  122. /package/src/{domains/feature-background → features/background}/index.ts +0 -0
  123. /package/src/{domains/feature-background → features/background}/infrastructure/constants/index.ts +0 -0
  124. /package/src/{domains/feature-background → features/background}/infrastructure/constants/prompts.constants.ts +0 -0
  125. /package/src/{domains/feature-background → features/background}/presentation/components/FeatureHeader.tsx +0 -0
  126. /package/src/{domains/feature-background → features/background}/presentation/components/GenerateButton.tsx +0 -0
  127. /package/src/{domains/feature-background → features/background}/presentation/components/ImagePicker.tsx +0 -0
  128. /package/src/{domains/feature-background → features/background}/presentation/components/ProcessingModal.tsx +0 -0
  129. /package/src/{domains/feature-background → features/background}/presentation/components/PromptInput.tsx +0 -0
  130. /package/src/{domains/feature-background → features/background}/presentation/components/ResultDisplay.tsx +0 -0
  131. /package/src/{domains/feature-background → features/background}/presentation/components/index.ts +0 -0
  132. /package/src/{domains/feature-background → features/background}/presentation/hooks/index.ts +0 -0
@@ -1,157 +0,0 @@
1
- import React from 'react';
2
- import { View, TouchableOpacity, StyleSheet } from 'react-native';
3
- import { AtomicText, AtomicIcon, useAppDesignTokens } from "@umituz/react-native-design-system";
4
-
5
- interface GalleryHeaderProps {
6
- readonly title: string;
7
- readonly count: number;
8
- readonly countLabel: string;
9
- readonly isFiltered: boolean;
10
- readonly onFilterPress: () => void;
11
- readonly filterLabel?: string;
12
- readonly filterIcon?: any;
13
- readonly onFavoritesPress?: () => void;
14
- readonly showOnlyFavorites?: boolean;
15
- readonly style?: any;
16
- readonly subtitle?: string;
17
- readonly isFilterEnabled?: boolean;
18
- readonly showCount?: boolean;
19
- }
20
-
21
- export const GalleryHeader: React.FC<GalleryHeaderProps> = ({
22
- title,
23
- count,
24
- countLabel,
25
- isFiltered,
26
- onFilterPress,
27
- filterLabel = 'Filter',
28
- filterIcon = 'filter-outline',
29
- onFavoritesPress,
30
- showOnlyFavorites = false,
31
- subtitle,
32
- isFilterEnabled = true,
33
- showCount = true,
34
- style,
35
- }) => {
36
- const tokens = useAppDesignTokens();
37
- const styles = useStyles(tokens);
38
-
39
- return (
40
- <View style={[styles.headerArea, style]}>
41
- <View style={styles.titleArea}>
42
- {!!title && <AtomicText style={styles.title}>{title}</AtomicText>}
43
- <AtomicText style={styles.subtitle}>
44
- {subtitle || (showCount ? `${count} ${countLabel}` : '')}
45
- </AtomicText>
46
- </View>
47
- <View style={styles.actions}>
48
- {onFavoritesPress && (
49
- <TouchableOpacity
50
- onPress={onFavoritesPress}
51
- style={[styles.actionButton, showOnlyFavorites && styles.actionButtonActive]}
52
- activeOpacity={0.7}
53
- >
54
- <AtomicIcon
55
- name={showOnlyFavorites ? "heart" : "heart-outline"}
56
- size="sm"
57
- color={showOnlyFavorites ? "error" : "secondary"}
58
- />
59
- </TouchableOpacity>
60
- )}
61
- {isFilterEnabled && (
62
- <TouchableOpacity
63
- onPress={onFilterPress}
64
- style={[styles.filterButton, isFiltered && styles.filterButtonActive]}
65
- activeOpacity={0.7}
66
- >
67
- <AtomicIcon
68
- name={filterIcon}
69
- size="sm"
70
- color={isFiltered ? "primary" : "secondary"}
71
- />
72
- <AtomicText style={[styles.filterText, { color: isFiltered ? tokens.colors.primary : tokens.colors.textSecondary }]}>
73
- {filterLabel}
74
- </AtomicText>
75
- {isFiltered && (
76
- <View style={styles.badge} />
77
- )}
78
- </TouchableOpacity>
79
- )}
80
- </View>
81
- </View>
82
- );
83
- };
84
-
85
- const useStyles = (tokens: any) => StyleSheet.create({
86
- headerArea: {
87
- flexDirection: "row",
88
- alignItems: "center",
89
- justifyContent: 'space-between',
90
- paddingHorizontal: tokens.spacing.md,
91
- paddingVertical: tokens.spacing.sm,
92
- marginBottom: tokens.spacing.sm,
93
- },
94
- titleArea: {
95
- flex: 1,
96
- marginRight: tokens.spacing.md,
97
- },
98
- title: {
99
- fontSize: 20,
100
- fontWeight: "700",
101
- color: tokens.colors.textPrimary,
102
- marginBottom: 4,
103
- },
104
- subtitle: {
105
- fontSize: 14,
106
- color: tokens.colors.textSecondary,
107
- opacity: 0.6
108
- },
109
- actions: {
110
- flexDirection: 'row',
111
- alignItems: 'center',
112
- gap: tokens.spacing.sm,
113
- },
114
- actionButton: {
115
- width: 40,
116
- height: 40,
117
- borderRadius: 20,
118
- backgroundColor: tokens.colors.surfaceVariant,
119
- justifyContent: 'center',
120
- alignItems: 'center',
121
- borderWidth: 1,
122
- borderColor: 'transparent',
123
- },
124
- actionButtonActive: {
125
- backgroundColor: tokens.colors.primary + "15",
126
- borderColor: tokens.colors.primary + "30",
127
- },
128
- filterButton: {
129
- flexDirection: 'row',
130
- alignItems: 'center',
131
- gap: tokens.spacing.xs,
132
- paddingVertical: tokens.spacing.xs,
133
- paddingHorizontal: tokens.spacing.md,
134
- borderRadius: 999,
135
- backgroundColor: tokens.colors.surfaceVariant,
136
- borderWidth: 1,
137
- borderColor: 'transparent',
138
- height: 40,
139
- },
140
- filterButtonActive: {
141
- backgroundColor: tokens.colors.primary + "15",
142
- borderColor: tokens.colors.primary + "30",
143
- },
144
- filterText: {
145
- fontSize: 14,
146
- fontWeight: "500",
147
- },
148
- badge: {
149
- width: 8,
150
- height: 8,
151
- borderRadius: 4,
152
- backgroundColor: tokens.colors.primary,
153
- position: 'absolute',
154
- top: 6,
155
- right: 6,
156
- },
157
- });
@@ -1,20 +0,0 @@
1
- /**
2
- * Presentation Components
3
- */
4
-
5
- export { GalleryHeader } from "./GalleryHeader";
6
- export { EmptyState } from "./EmptyState";
7
- export { FilterChips } from "./FilterChips";
8
- export { CreationsHomeCard } from "./CreationsHomeCard";
9
- export { CreationCard } from "./CreationCard";
10
- export { CreationThumbnail } from "./CreationThumbnail";
11
- export { CreationImageViewer } from "./CreationImageViewer";
12
- export { CreationsGrid } from "./CreationsGrid";
13
- export { CreationsGalleryEmptyState } from "./CreationsGalleryEmptyState";
14
- export { FilterBottomSheet, type FilterCategory, type FilterOption } from "./FilterBottomSheet";
15
-
16
- // Detail Components
17
- export { DetailHeader } from "./CreationDetail/DetailHeader";
18
- export { DetailImage } from "./CreationDetail/DetailImage";
19
- export { DetailStory } from "./CreationDetail/DetailStory";
20
- export { DetailActions } from "./CreationDetail/DetailActions";
@@ -1,9 +0,0 @@
1
- /**
2
- * Presentation Hooks
3
- */
4
-
5
- export { useCreations } from "./useCreations";
6
- export { useDeleteCreation } from "./useDeleteCreation";
7
- export { useCreationsFilter } from "./useCreationsFilter";
8
- export { useToggleFavorite } from "./useToggleFavorite";
9
- export { useDeleteMultipleCreations } from "./useDeleteMultipleCreations";
@@ -1,33 +0,0 @@
1
- /**
2
- * useCreations Hook
3
- * Fetches user's creations from repository
4
- */
5
-
6
- import { useQuery } from "@tanstack/react-query";
7
- import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
8
- import type { Creation } from "../../domain/entities/Creation";
9
-
10
- const CACHE_CONFIG = {
11
- staleTime: 5 * 60 * 1000, // 5 minutes - use cache invalidation on mutations
12
- gcTime: 30 * 60 * 1000,
13
- };
14
-
15
- interface UseCreationsProps {
16
- readonly userId: string | null;
17
- readonly repository: ICreationsRepository;
18
- readonly enabled?: boolean;
19
- }
20
-
21
- export function useCreations({
22
- userId,
23
- repository,
24
- enabled = true,
25
- }: UseCreationsProps) {
26
- return useQuery<Creation[]>({
27
- queryKey: ["creations", userId ?? ""],
28
- queryFn: () => repository.getAll(userId!),
29
- enabled: !!userId && enabled,
30
- staleTime: CACHE_CONFIG.staleTime,
31
- gcTime: CACHE_CONFIG.gcTime,
32
- });
33
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * useCreationsFilter Hook
3
- * Handles filtering of creations by type, search, and favorites
4
- */
5
-
6
- import { useState, useMemo, useCallback } from "react";
7
- import type { Creation } from "../../domain/entities/Creation";
8
-
9
- interface UseCreationsFilterProps {
10
- readonly creations: Creation[] | undefined;
11
- readonly defaultFilterId?: string;
12
- }
13
-
14
- export function useCreationsFilter({
15
- creations,
16
- defaultFilterId = "all"
17
- }: UseCreationsFilterProps) {
18
- const [selectedIds, setSelectedIds] = useState<string[]>([defaultFilterId]);
19
- const [searchQuery, setSearchQuery] = useState("");
20
- const [showOnlyFavorites, setShowOnlyFavorites] = useState(false);
21
-
22
- const filtered = useMemo(() => {
23
- if (!creations) return [];
24
-
25
- let result = creations;
26
-
27
- // 1. Filter by Favorites
28
- if (showOnlyFavorites) {
29
- result = result.filter(c => c.isFavorite);
30
- }
31
-
32
- // 2. Filter by Category/Type
33
- if (!selectedIds.includes(defaultFilterId)) {
34
- result = result.filter((c) =>
35
- selectedIds.includes(c.type) ||
36
- selectedIds.some(id => (c as any).metadata?.tags?.includes(id))
37
- );
38
- }
39
-
40
- // 3. Filter by Search Query
41
- if (searchQuery.trim()) {
42
- const query = searchQuery.toLowerCase();
43
- result = result.filter(c =>
44
- c.prompt?.toLowerCase().includes(query) ||
45
- c.type.toLowerCase().includes(query)
46
- );
47
- }
48
-
49
- return result;
50
- }, [creations, selectedIds, defaultFilterId, searchQuery, showOnlyFavorites]);
51
-
52
- const toggleFilter = useCallback((filterId: string, multiSelect: boolean = false) => {
53
- setSelectedIds(prev => {
54
- if (filterId === defaultFilterId) return [defaultFilterId];
55
-
56
- let newIds: string[];
57
- if (!multiSelect) {
58
- if (prev.includes(filterId) && prev.length === 1) return prev;
59
- newIds = [filterId];
60
- } else {
61
- if (prev.includes(filterId)) {
62
- newIds = prev.filter(id => id !== filterId);
63
- } else {
64
- newIds = [...prev.filter(id => id !== defaultFilterId), filterId];
65
- }
66
- }
67
-
68
- if (newIds.length === 0) return [defaultFilterId];
69
- return newIds;
70
- });
71
- }, [defaultFilterId]);
72
-
73
- const clearFilters = useCallback(() => {
74
- setSelectedIds([defaultFilterId]);
75
- setSearchQuery("");
76
- setShowOnlyFavorites(false);
77
- }, [defaultFilterId]);
78
-
79
- return {
80
- filtered,
81
- selectedIds,
82
- searchQuery,
83
- setSearchQuery,
84
- showOnlyFavorites,
85
- setShowOnlyFavorites,
86
- toggleFilter,
87
- clearFilters,
88
- isFiltered: !selectedIds.includes(defaultFilterId) || !!searchQuery || showOnlyFavorites,
89
- };
90
- }
@@ -1,51 +0,0 @@
1
- /**
2
- * useDeleteCreation Hook
3
- * Handles deletion of user creations with optimistic update
4
- */
5
-
6
- import { useMutation, useQueryClient } from "@tanstack/react-query";
7
- import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
8
- import type { Creation } from "../../domain/entities/Creation";
9
-
10
- interface UseDeleteCreationProps {
11
- readonly userId: string | null;
12
- readonly repository: ICreationsRepository;
13
- }
14
-
15
- export function useDeleteCreation({
16
- userId,
17
- repository,
18
- }: UseDeleteCreationProps) {
19
- const queryClient = useQueryClient();
20
-
21
- return useMutation({
22
- mutationFn: async (creationId: string) => {
23
- if (!userId) return false;
24
- return repository.delete(userId, creationId);
25
- },
26
- onMutate: async (creationId) => {
27
- if (!userId) return;
28
-
29
- await queryClient.cancelQueries({
30
- queryKey: ["creations", userId],
31
- });
32
-
33
- const previous = queryClient.getQueryData<Creation[]>([
34
- "creations",
35
- userId,
36
- ]);
37
-
38
- queryClient.setQueryData<Creation[]>(
39
- ["creations", userId],
40
- (old) => old?.filter((c) => c.id !== creationId) ?? [],
41
- );
42
-
43
- return { previous };
44
- },
45
- onError: (_err, _id, rollback) => {
46
- if (userId && rollback?.previous) {
47
- queryClient.setQueryData(["creations", userId], rollback.previous);
48
- }
49
- },
50
- });
51
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * useDeleteMultipleCreations Hook
3
- * Handles batch deletion of user creations with optimistic update
4
- */
5
-
6
- import { useMutation, useQueryClient } from "@tanstack/react-query";
7
- import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
8
- import type { Creation } from "../../domain/entities/Creation";
9
-
10
- interface UseDeleteMultipleCreationsProps {
11
- readonly userId: string | null;
12
- readonly repository: ICreationsRepository;
13
- }
14
-
15
- export function useDeleteMultipleCreations({
16
- userId,
17
- repository,
18
- }: UseDeleteMultipleCreationsProps) {
19
- const queryClient = useQueryClient();
20
-
21
- return useMutation({
22
- mutationFn: async (creationIds: string[]) => {
23
- if (!userId) return false;
24
- return repository.deleteMultiple(userId, creationIds);
25
- },
26
- onMutate: async (creationIds) => {
27
- if (!userId) return;
28
-
29
- await queryClient.cancelQueries({
30
- queryKey: ["creations", userId],
31
- });
32
-
33
- const previous = queryClient.getQueryData<Creation[]>([
34
- "creations",
35
- userId,
36
- ]);
37
-
38
- queryClient.setQueryData<Creation[]>(
39
- ["creations", userId],
40
- (old) =>
41
- old?.filter((c) => !creationIds.includes(c.id)) ?? [],
42
- );
43
-
44
- return { previous };
45
- },
46
- onError: (_err, _ids, rollback) => {
47
- if (userId && rollback?.previous) {
48
- queryClient.setQueryData(["creations", userId], rollback.previous);
49
- }
50
- },
51
- onSettled: () => {
52
- if (userId) {
53
- queryClient.invalidateQueries({ queryKey: ["creations", userId] });
54
- }
55
- },
56
- });
57
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * useToggleFavorite Hook
3
- * Handles favoriting/unfavoriting of user creations with optimistic update
4
- */
5
-
6
- import { useMutation, useQueryClient } from "@tanstack/react-query";
7
- import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
8
- import type { Creation } from "../../domain/entities/Creation";
9
-
10
- interface UseToggleFavoriteProps {
11
- readonly userId: string | null;
12
- readonly repository: ICreationsRepository;
13
- }
14
-
15
- export function useToggleFavorite({
16
- userId,
17
- repository,
18
- }: UseToggleFavoriteProps) {
19
- const queryClient = useQueryClient();
20
-
21
- return useMutation({
22
- mutationFn: async (creationId: string) => {
23
- if (!userId) return false;
24
- return repository.toggleFavorite(userId, creationId);
25
- },
26
- onMutate: async (creationId) => {
27
- if (!userId) return;
28
-
29
- await queryClient.cancelQueries({
30
- queryKey: ["creations", userId],
31
- });
32
-
33
- const previous = queryClient.getQueryData<Creation[]>([
34
- "creations",
35
- userId,
36
- ]);
37
-
38
- queryClient.setQueryData<Creation[]>(
39
- ["creations", userId],
40
- (old) =>
41
- old?.map((c) =>
42
- c.id === creationId ? { ...c, isFavorite: !c.isFavorite } : c,
43
- ) ?? [],
44
- );
45
-
46
- return { previous };
47
- },
48
- onError: (_err, _id, rollback) => {
49
- if (userId && rollback?.previous) {
50
- queryClient.setQueryData(["creations", userId], rollback.previous);
51
- }
52
- },
53
- onSettled: () => {
54
- if (userId) {
55
- queryClient.invalidateQueries({ queryKey: ["creations", userId] });
56
- }
57
- },
58
- });
59
- }
@@ -1,71 +0,0 @@
1
-
2
- import React from 'react';
3
- import { View, StyleSheet, ScrollView } from 'react-native';
4
- import { useAppDesignTokens } from "@umituz/react-native-design-system";
5
- import type { Creation } from '../../domain/entities/Creation';
6
- import { DetailHeader } from '../components/CreationDetail/DetailHeader';
7
- import { DetailImage } from '../components/CreationDetail/DetailImage';
8
- import { DetailStory } from '../components/CreationDetail/DetailStory';
9
- import { DetailActions } from '../components/CreationDetail/DetailActions';
10
-
11
- interface CreationDetailScreenProps {
12
- readonly creation: Creation;
13
- readonly onClose: () => void;
14
- readonly onShare: (creation: Creation) => void;
15
- readonly onDelete: (creation: Creation) => void;
16
- readonly t: (key: string) => string;
17
- }
18
-
19
- export const CreationDetailScreen: React.FC<CreationDetailScreenProps> = ({
20
- creation,
21
- onClose,
22
- onShare,
23
- onDelete,
24
- t
25
- }) => {
26
- const tokens = useAppDesignTokens();
27
-
28
- // Extract data
29
- const metadata = (creation as any).metadata || {};
30
- const title = metadata.names || creation.type;
31
- const story = metadata.story || metadata.description || "";
32
- const date = metadata.date || new Date(creation.createdAt).toLocaleDateString();
33
-
34
- const styles = useStyles(tokens);
35
-
36
- return (
37
- <View style={styles.container}>
38
- <DetailHeader
39
- title={title}
40
- date={date}
41
- onClose={onClose}
42
- />
43
-
44
- <ScrollView
45
- contentContainerStyle={styles.scrollContent}
46
- showsVerticalScrollIndicator={false}
47
- >
48
- <DetailImage uri={creation.uri} />
49
-
50
- <DetailStory story={story} />
51
-
52
- <DetailActions
53
- onShare={() => onShare(creation)}
54
- onDelete={() => onDelete(creation)}
55
- shareLabel={t("result.shareButton") || "Share"}
56
- deleteLabel={t("common.delete") || "Delete"}
57
- />
58
- </ScrollView>
59
- </View>
60
- );
61
- };
62
-
63
- const useStyles = (tokens: any) => StyleSheet.create({
64
- container: {
65
- flex: 1,
66
- backgroundColor: tokens.colors.backgroundPrimary,
67
- },
68
- scrollContent: {
69
- paddingBottom: tokens.spacing.xxl,
70
- },
71
- });