@umituz/react-native-ai-creations 1.3.11 → 1.3.12

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-creations",
3
- "version": "1.3.11",
3
+ "version": "1.3.12",
4
4
  "description": "AI-generated creations gallery with filtering, sharing, and management for React Native apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -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
+ };
@@ -8,6 +8,7 @@ export { FilterChips } from "./FilterChips";
8
8
  export { CreationsHomeCard } from "./CreationsHomeCard";
9
9
  export { CreationCard } from "./CreationCard";
10
10
  export { CreationThumbnail } from "./CreationThumbnail";
11
+ export { CreationImageViewer } from "./CreationImageViewer";
11
12
  export { CreationsGrid } from "./CreationsGrid";
12
13
  export { FilterBottomSheet, type FilterCategory, type FilterOption } from "./FilterBottomSheet";
13
14
 
@@ -2,7 +2,6 @@ import React, { useMemo, useCallback, useState } from "react";
2
2
  import { View, StyleSheet } from "react-native";
3
3
  import { useAppDesignTokens } from "@umituz/react-native-design-system";
4
4
  import { useSharing } from "@umituz/react-native-sharing";
5
- import { ImageGallery } from "@umituz/react-native-image";
6
5
  import { useSafeAreaInsets } from "react-native-safe-area-context";
7
6
  import { useFocusEffect } from "@react-navigation/native";
8
7
  import { useCreations } from "../hooks/useCreations";
@@ -10,7 +9,8 @@ import { useDeleteCreation } from "../hooks/useDeleteCreation";
10
9
  import { useCreationsFilter } from "../hooks/useCreationsFilter";
11
10
  import { useAlert } from "@umituz/react-native-alert";
12
11
  import { BottomSheetModalRef } from "@umituz/react-native-bottom-sheet";
13
- import { GalleryHeader, EmptyState, CreationsGrid, FilterBottomSheet, type FilterCategory } from "../components";
12
+ import { GalleryHeader, EmptyState, CreationsGrid, FilterBottomSheet, CreationImageViewer, type FilterCategory } from "../components";
13
+ import { getTranslatedTypes, getFilterCategoriesFromConfig } from "../utils/filterUtils";
14
14
  import type { Creation } from "../../domain/entities/Creation";
15
15
  import type { CreationsConfig } from "../../domain/value-objects/CreationsConfig";
16
16
  import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
@@ -0,0 +1,52 @@
1
+ import { CreationsConfig } from "../../domain/value-objects/CreationsConfig";
2
+ import { FilterCategory } from "../components/FilterBottomSheet";
3
+
4
+ /**
5
+ * Transforms the creations configuration into filter categories for the UI.
6
+ *
7
+ * @param config The creations configuration object
8
+ * @param t Translation function
9
+ * @returns Array of FilterCategory
10
+ */
11
+ export const getFilterCategoriesFromConfig = (
12
+ config: CreationsConfig,
13
+ t: (key: string) => string
14
+ ): FilterCategory[] => {
15
+ const categories: FilterCategory[] = [];
16
+
17
+ if (config.types.length > 0) {
18
+ categories.push({
19
+ id: 'type',
20
+ title: t(config.translations.filterTitle),
21
+ multiSelect: false,
22
+ options: config.types.map(type => ({
23
+ id: type.id,
24
+ label: t(type.labelKey),
25
+ icon: type.icon || 'image'
26
+ }))
27
+ });
28
+ }
29
+
30
+ if (config.filterCategories) {
31
+ categories.push(...config.filterCategories);
32
+ }
33
+
34
+ return categories;
35
+ };
36
+
37
+ /**
38
+ * Translates the creation types for display.
39
+ *
40
+ * @param config The creations configuration object
41
+ * @param t Translation function
42
+ * @returns Array of types with translated labels
43
+ */
44
+ export const getTranslatedTypes = (
45
+ config: CreationsConfig,
46
+ t: (key: string) => string
47
+ ) => {
48
+ return config.types.map(type => ({
49
+ ...type,
50
+ labelKey: t(type.labelKey)
51
+ }));
52
+ };