@umituz/react-native-design-system 2.11.9 → 4.23.40

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-design-system",
3
- "version": "2.11.9",
3
+ "version": "4.23.40",
4
4
  "description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, onboarding, and loading utilities",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -86,6 +86,9 @@ export {
86
86
  toDataUrl,
87
87
  saveBase64ToFile,
88
88
  downloadMediaToFile,
89
+ saveImageToGallery,
90
+ saveVideoToGallery,
91
+ type SaveToGalleryResult,
89
92
  } from "./infrastructure/utils/file-media-utils";
90
93
 
91
94
  // Multimedia Flashcard Support
@@ -85,3 +85,58 @@ export const downloadMediaToFile = async (url: string, isVideo: boolean): Promis
85
85
 
86
86
  return file.uri;
87
87
  };
88
+
89
+ export interface SaveToGalleryResult {
90
+ readonly success: boolean;
91
+ readonly error?: string;
92
+ }
93
+
94
+ /**
95
+ * Save image to device gallery
96
+ * Downloads from URL if needed, then saves to media library
97
+ */
98
+ export const saveImageToGallery = async (uri: string): Promise<SaveToGalleryResult> => {
99
+ try {
100
+ const MediaLibrary = require("expo-media-library");
101
+
102
+ const { status } = await MediaLibrary.requestPermissionsAsync();
103
+ if (status !== "granted") {
104
+ return { success: false, error: "Permission denied" };
105
+ }
106
+
107
+ // Download if URL, otherwise use local path
108
+ const localUri = uri.startsWith("http") ? await downloadMediaToFile(uri, false) : uri;
109
+ await MediaLibrary.saveToLibraryAsync(localUri);
110
+
111
+ return { success: true };
112
+ } catch (error) {
113
+ return {
114
+ success: false,
115
+ error: error instanceof Error ? error.message : "Failed to save",
116
+ };
117
+ }
118
+ };
119
+
120
+ /**
121
+ * Save video to device gallery
122
+ */
123
+ export const saveVideoToGallery = async (uri: string): Promise<SaveToGalleryResult> => {
124
+ try {
125
+ const MediaLibrary = require("expo-media-library");
126
+
127
+ const { status } = await MediaLibrary.requestPermissionsAsync();
128
+ if (status !== "granted") {
129
+ return { success: false, error: "Permission denied" };
130
+ }
131
+
132
+ const localUri = uri.startsWith("http") ? await downloadMediaToFile(uri, true) : uri;
133
+ await MediaLibrary.saveToLibraryAsync(localUri);
134
+
135
+ return { success: true };
136
+ } catch (error) {
137
+ return {
138
+ success: false,
139
+ error: error instanceof Error ? error.message : "Failed to save",
140
+ };
141
+ }
142
+ };