@umituz/react-native-ai-generation-content 1.17.284 → 1.17.285

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-generation-content",
3
- "version": "1.17.284",
3
+ "version": "1.17.285",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -5,8 +5,8 @@
5
5
 
6
6
  import { useState, useCallback } from "react";
7
7
  import { Alert } from "react-native";
8
- import * as ImagePicker from "expo-image-picker";
9
8
  import * as FileSystem from "expo-file-system";
9
+ import { useMedia, MediaLibraryPermission } from "@umituz/react-native-design-system";
10
10
  import type { UploadedImage } from "../../domain/types";
11
11
 
12
12
  export interface UsePartnerStepConfig {
@@ -20,6 +20,8 @@ export interface UsePartnerStepTranslations {
20
20
  readonly maxFileSize: string;
21
21
  readonly error: string;
22
22
  readonly uploadFailed: string;
23
+ readonly permissionDenied?: string;
24
+ readonly permissionRequired?: string;
23
25
  }
24
26
 
25
27
  export interface UsePartnerStepOptions {
@@ -42,6 +44,7 @@ const DEFAULT_CONFIG: UsePartnerStepConfig = {
42
44
 
43
45
  export const usePartnerStep = (options: UsePartnerStepOptions) => {
44
46
  const { initialName = "", config = DEFAULT_CONFIG, translations } = options;
47
+ const { pickImage, requestMediaLibraryPermission, getMediaLibraryPermissionStatus, isLoading: isPickerLoading } = useMedia();
45
48
 
46
49
  const [state, setState] = useState<PartnerStepState>({
47
50
  image: null,
@@ -59,9 +62,21 @@ export const usePartnerStep = (options: UsePartnerStepOptions) => {
59
62
 
60
63
  const handlePickImage = useCallback(async () => {
61
64
  try {
65
+ // Check permission first
66
+ let permission = await getMediaLibraryPermissionStatus();
67
+ if (permission !== MediaLibraryPermission.GRANTED) {
68
+ permission = await requestMediaLibraryPermission();
69
+ if (permission !== MediaLibraryPermission.GRANTED) {
70
+ Alert.alert(
71
+ translations.error,
72
+ translations.permissionDenied ?? "Photo library access is required to upload images.",
73
+ );
74
+ return;
75
+ }
76
+ }
77
+
62
78
  const maxFileSizeMB = config.maxFileSizeMB ?? 10;
63
- const result = await ImagePicker.launchImageLibraryAsync({
64
- mediaTypes: ImagePicker.MediaTypeOptions.Images,
79
+ const result = await pickImage({
65
80
  allowsEditing: config.allowsEditing ?? true,
66
81
  quality: config.imageQuality ?? 0.7,
67
82
  });
@@ -97,7 +112,7 @@ export const usePartnerStep = (options: UsePartnerStepOptions) => {
97
112
  } catch {
98
113
  Alert.alert(translations.error, translations.uploadFailed);
99
114
  }
100
- }, [config, translations]);
115
+ }, [config, translations, pickImage, requestMediaLibraryPermission, getMediaLibraryPermissionStatus]);
101
116
 
102
117
  const canContinue = state.image !== null;
103
118
 
@@ -107,6 +122,7 @@ export const usePartnerStep = (options: UsePartnerStepOptions) => {
107
122
  setDescription,
108
123
  handlePickImage,
109
124
  canContinue,
125
+ isLoading: isPickerLoading,
110
126
  };
111
127
  };
112
128