@tradly/asset 1.0.15 → 1.0.17
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/dist/core/MediaApiService.js +59 -33
- package/dist/esm/core/MediaApiService.js +59 -33
- package/dist/esm/native/FileUpload.native.js +44 -11
- package/dist/esm/native/MediaGallery.native.js +3 -1
- package/dist/esm/native/MediaPopup.native.js +18 -19
- package/dist/esm/native/MediaTab.native.js +29 -25
- package/dist/esm/native/VideosGallery.native.js +3 -1
- package/dist/native/FileUpload.native.js +44 -11
- package/dist/native/MediaGallery.native.js +3 -1
- package/dist/native/MediaPopup.native.js +13 -14
- package/dist/native/MediaTab.native.js +24 -20
- package/dist/native/VideosGallery.native.js +3 -1
- package/package.json +1 -1
|
@@ -249,7 +249,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
249
249
|
key: "uploadMedia",
|
|
250
250
|
value: (function () {
|
|
251
251
|
var _uploadMedia = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(files, authKey) {
|
|
252
|
-
var auth_key, all_files_uri, upload_files, upload_full_files, i, element, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, fileResponse, blob, res, mediaData, _t3, _t4;
|
|
252
|
+
var auth_key, all_files_uri, upload_files, upload_full_files, i, element, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, uri, fileResponse, blob, res, mediaData, _t3, _t4, _t5;
|
|
253
253
|
return _regenerator().w(function (_context4) {
|
|
254
254
|
while (1) switch (_context4.p = _context4.n) {
|
|
255
255
|
case 0:
|
|
@@ -266,7 +266,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
266
266
|
i = 0;
|
|
267
267
|
case 2:
|
|
268
268
|
if (!(i < files.length)) {
|
|
269
|
-
_context4.n =
|
|
269
|
+
_context4.n = 21;
|
|
270
270
|
break;
|
|
271
271
|
}
|
|
272
272
|
element = files[i]; // Check if file already has a path (from previous upload)
|
|
@@ -284,7 +284,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
284
284
|
|
|
285
285
|
// Upload files when we've processed all files
|
|
286
286
|
if (!(files.length === i + 1 && upload_files.length > 0)) {
|
|
287
|
-
_context4.n =
|
|
287
|
+
_context4.n = 20;
|
|
288
288
|
break;
|
|
289
289
|
}
|
|
290
290
|
_context4.p = 3;
|
|
@@ -295,7 +295,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
295
295
|
index = 0;
|
|
296
296
|
case 5:
|
|
297
297
|
if (!(index < responseFiles.length)) {
|
|
298
|
-
_context4.n =
|
|
298
|
+
_context4.n = 17;
|
|
299
299
|
break;
|
|
300
300
|
}
|
|
301
301
|
path = responseFiles[index].signedUrl;
|
|
@@ -305,20 +305,46 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
305
305
|
fileBody = originalFile; // Handle React Native file URIs
|
|
306
306
|
// If file has a uri property, it's from React Native - fetch it first
|
|
307
307
|
if (!(originalFile.uri && typeof originalFile.uri === "string")) {
|
|
308
|
-
_context4.n =
|
|
308
|
+
_context4.n = 13;
|
|
309
309
|
break;
|
|
310
310
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
fileResponse = _context4.v;
|
|
311
|
+
// For React Native, handle file://, content://, or http:// URIs
|
|
312
|
+
uri = originalFile.uri;
|
|
313
|
+
_context4.p = 7;
|
|
315
314
|
_context4.n = 8;
|
|
316
|
-
return
|
|
315
|
+
return fetch(uri);
|
|
317
316
|
case 8:
|
|
317
|
+
fileResponse = _context4.v;
|
|
318
|
+
if (!fileResponse.blob) {
|
|
319
|
+
_context4.n = 10;
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
_context4.n = 9;
|
|
323
|
+
return fileResponse.blob();
|
|
324
|
+
case 9:
|
|
318
325
|
blob = _context4.v;
|
|
319
326
|
fileBody = blob;
|
|
320
|
-
|
|
321
|
-
|
|
327
|
+
_context4.n = 11;
|
|
328
|
+
break;
|
|
329
|
+
case 10:
|
|
330
|
+
// Fallback: use the response as-is if blob() is not available
|
|
331
|
+
// Some React Native versions might need different handling
|
|
332
|
+
fileBody = fileResponse;
|
|
333
|
+
case 11:
|
|
334
|
+
_context4.n = 13;
|
|
335
|
+
break;
|
|
336
|
+
case 12:
|
|
337
|
+
_context4.p = 12;
|
|
338
|
+
_t3 = _context4.v;
|
|
339
|
+
// If fetch fails, try using the URI directly
|
|
340
|
+
// Some React Native environments might handle this differently
|
|
341
|
+
console.warn("Fetch failed for URI, trying direct upload:", _t3);
|
|
342
|
+
// For S3 PUT, we need the actual file content
|
|
343
|
+
// If fetch fails, we'll try to use the file object directly
|
|
344
|
+
// This might require additional React Native file handling libraries
|
|
345
|
+
throw new Error("Failed to read file from URI: ".concat(uri, ". Make sure the file URI is accessible. Error: ").concat(_t3.message));
|
|
346
|
+
case 13:
|
|
347
|
+
_context4.n = 14;
|
|
322
348
|
return fetch(path, {
|
|
323
349
|
method: "PUT",
|
|
324
350
|
headers: {
|
|
@@ -326,26 +352,26 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
326
352
|
},
|
|
327
353
|
body: fileBody
|
|
328
354
|
});
|
|
329
|
-
case
|
|
355
|
+
case 14:
|
|
330
356
|
res = _context4.v;
|
|
331
357
|
if (res.ok) {
|
|
332
358
|
all_files_uri.push(fileURI);
|
|
333
359
|
} else {
|
|
334
360
|
console.error("Failed to upload file ".concat(index + 1));
|
|
335
361
|
}
|
|
336
|
-
_context4.n =
|
|
362
|
+
_context4.n = 16;
|
|
337
363
|
break;
|
|
338
|
-
case
|
|
339
|
-
_context4.p =
|
|
340
|
-
|
|
341
|
-
console.error("Error uploading file ".concat(index + 1, ":"),
|
|
342
|
-
case
|
|
364
|
+
case 15:
|
|
365
|
+
_context4.p = 15;
|
|
366
|
+
_t4 = _context4.v;
|
|
367
|
+
console.error("Error uploading file ".concat(index + 1, ":"), _t4);
|
|
368
|
+
case 16:
|
|
343
369
|
index++;
|
|
344
370
|
_context4.n = 5;
|
|
345
371
|
break;
|
|
346
|
-
case
|
|
372
|
+
case 17:
|
|
347
373
|
if (!(all_files_uri.length > 0)) {
|
|
348
|
-
_context4.n =
|
|
374
|
+
_context4.n = 18;
|
|
349
375
|
break;
|
|
350
376
|
}
|
|
351
377
|
mediaData = all_files_uri.map(function (url, index) {
|
|
@@ -358,7 +384,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
358
384
|
mime_type: originalFile.type
|
|
359
385
|
};
|
|
360
386
|
}); // Save to media API - POST /v1/media with { media: [...] }
|
|
361
|
-
_context4.n =
|
|
387
|
+
_context4.n = 18;
|
|
362
388
|
return this.apiCall({
|
|
363
389
|
method: "POST",
|
|
364
390
|
path: "/v1/media",
|
|
@@ -366,25 +392,25 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
366
392
|
media: mediaData
|
|
367
393
|
}
|
|
368
394
|
});
|
|
369
|
-
case
|
|
370
|
-
_context4.n =
|
|
395
|
+
case 18:
|
|
396
|
+
_context4.n = 20;
|
|
371
397
|
break;
|
|
372
|
-
case
|
|
373
|
-
_context4.p =
|
|
374
|
-
|
|
375
|
-
console.error("Upload error:",
|
|
398
|
+
case 19:
|
|
399
|
+
_context4.p = 19;
|
|
400
|
+
_t5 = _context4.v;
|
|
401
|
+
console.error("Upload error:", _t5);
|
|
376
402
|
if (this.onError) {
|
|
377
|
-
this.onError(
|
|
403
|
+
this.onError(_t5);
|
|
378
404
|
}
|
|
379
|
-
throw
|
|
380
|
-
case
|
|
405
|
+
throw _t5;
|
|
406
|
+
case 20:
|
|
381
407
|
i++;
|
|
382
408
|
_context4.n = 2;
|
|
383
409
|
break;
|
|
384
|
-
case
|
|
410
|
+
case 21:
|
|
385
411
|
return _context4.a(2, all_files_uri);
|
|
386
412
|
}
|
|
387
|
-
}, _callee4, this, [[6,
|
|
413
|
+
}, _callee4, this, [[7, 12], [6, 15], [3, 19]]);
|
|
388
414
|
}));
|
|
389
415
|
function uploadMedia(_x5, _x6) {
|
|
390
416
|
return _uploadMedia.apply(this, arguments);
|
|
@@ -243,7 +243,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
243
243
|
key: "uploadMedia",
|
|
244
244
|
value: (function () {
|
|
245
245
|
var _uploadMedia = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(files, authKey) {
|
|
246
|
-
var auth_key, all_files_uri, upload_files, upload_full_files, i, element, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, fileResponse, blob, res, mediaData, _t3, _t4;
|
|
246
|
+
var auth_key, all_files_uri, upload_files, upload_full_files, i, element, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, uri, fileResponse, blob, res, mediaData, _t3, _t4, _t5;
|
|
247
247
|
return _regenerator().w(function (_context4) {
|
|
248
248
|
while (1) switch (_context4.p = _context4.n) {
|
|
249
249
|
case 0:
|
|
@@ -260,7 +260,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
260
260
|
i = 0;
|
|
261
261
|
case 2:
|
|
262
262
|
if (!(i < files.length)) {
|
|
263
|
-
_context4.n =
|
|
263
|
+
_context4.n = 21;
|
|
264
264
|
break;
|
|
265
265
|
}
|
|
266
266
|
element = files[i]; // Check if file already has a path (from previous upload)
|
|
@@ -278,7 +278,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
278
278
|
|
|
279
279
|
// Upload files when we've processed all files
|
|
280
280
|
if (!(files.length === i + 1 && upload_files.length > 0)) {
|
|
281
|
-
_context4.n =
|
|
281
|
+
_context4.n = 20;
|
|
282
282
|
break;
|
|
283
283
|
}
|
|
284
284
|
_context4.p = 3;
|
|
@@ -289,7 +289,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
289
289
|
index = 0;
|
|
290
290
|
case 5:
|
|
291
291
|
if (!(index < responseFiles.length)) {
|
|
292
|
-
_context4.n =
|
|
292
|
+
_context4.n = 17;
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
path = responseFiles[index].signedUrl;
|
|
@@ -299,20 +299,46 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
299
299
|
fileBody = originalFile; // Handle React Native file URIs
|
|
300
300
|
// If file has a uri property, it's from React Native - fetch it first
|
|
301
301
|
if (!(originalFile.uri && typeof originalFile.uri === "string")) {
|
|
302
|
-
_context4.n =
|
|
302
|
+
_context4.n = 13;
|
|
303
303
|
break;
|
|
304
304
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
fileResponse = _context4.v;
|
|
305
|
+
// For React Native, handle file://, content://, or http:// URIs
|
|
306
|
+
uri = originalFile.uri;
|
|
307
|
+
_context4.p = 7;
|
|
309
308
|
_context4.n = 8;
|
|
310
|
-
return
|
|
309
|
+
return fetch(uri);
|
|
311
310
|
case 8:
|
|
311
|
+
fileResponse = _context4.v;
|
|
312
|
+
if (!fileResponse.blob) {
|
|
313
|
+
_context4.n = 10;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
_context4.n = 9;
|
|
317
|
+
return fileResponse.blob();
|
|
318
|
+
case 9:
|
|
312
319
|
blob = _context4.v;
|
|
313
320
|
fileBody = blob;
|
|
314
|
-
|
|
315
|
-
|
|
321
|
+
_context4.n = 11;
|
|
322
|
+
break;
|
|
323
|
+
case 10:
|
|
324
|
+
// Fallback: use the response as-is if blob() is not available
|
|
325
|
+
// Some React Native versions might need different handling
|
|
326
|
+
fileBody = fileResponse;
|
|
327
|
+
case 11:
|
|
328
|
+
_context4.n = 13;
|
|
329
|
+
break;
|
|
330
|
+
case 12:
|
|
331
|
+
_context4.p = 12;
|
|
332
|
+
_t3 = _context4.v;
|
|
333
|
+
// If fetch fails, try using the URI directly
|
|
334
|
+
// Some React Native environments might handle this differently
|
|
335
|
+
console.warn("Fetch failed for URI, trying direct upload:", _t3);
|
|
336
|
+
// For S3 PUT, we need the actual file content
|
|
337
|
+
// If fetch fails, we'll try to use the file object directly
|
|
338
|
+
// This might require additional React Native file handling libraries
|
|
339
|
+
throw new Error("Failed to read file from URI: ".concat(uri, ". Make sure the file URI is accessible. Error: ").concat(_t3.message));
|
|
340
|
+
case 13:
|
|
341
|
+
_context4.n = 14;
|
|
316
342
|
return fetch(path, {
|
|
317
343
|
method: "PUT",
|
|
318
344
|
headers: {
|
|
@@ -320,26 +346,26 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
320
346
|
},
|
|
321
347
|
body: fileBody
|
|
322
348
|
});
|
|
323
|
-
case
|
|
349
|
+
case 14:
|
|
324
350
|
res = _context4.v;
|
|
325
351
|
if (res.ok) {
|
|
326
352
|
all_files_uri.push(fileURI);
|
|
327
353
|
} else {
|
|
328
354
|
console.error("Failed to upload file ".concat(index + 1));
|
|
329
355
|
}
|
|
330
|
-
_context4.n =
|
|
356
|
+
_context4.n = 16;
|
|
331
357
|
break;
|
|
332
|
-
case
|
|
333
|
-
_context4.p =
|
|
334
|
-
|
|
335
|
-
console.error("Error uploading file ".concat(index + 1, ":"),
|
|
336
|
-
case
|
|
358
|
+
case 15:
|
|
359
|
+
_context4.p = 15;
|
|
360
|
+
_t4 = _context4.v;
|
|
361
|
+
console.error("Error uploading file ".concat(index + 1, ":"), _t4);
|
|
362
|
+
case 16:
|
|
337
363
|
index++;
|
|
338
364
|
_context4.n = 5;
|
|
339
365
|
break;
|
|
340
|
-
case
|
|
366
|
+
case 17:
|
|
341
367
|
if (!(all_files_uri.length > 0)) {
|
|
342
|
-
_context4.n =
|
|
368
|
+
_context4.n = 18;
|
|
343
369
|
break;
|
|
344
370
|
}
|
|
345
371
|
mediaData = all_files_uri.map(function (url, index) {
|
|
@@ -352,7 +378,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
352
378
|
mime_type: originalFile.type
|
|
353
379
|
};
|
|
354
380
|
}); // Save to media API - POST /v1/media with { media: [...] }
|
|
355
|
-
_context4.n =
|
|
381
|
+
_context4.n = 18;
|
|
356
382
|
return this.apiCall({
|
|
357
383
|
method: "POST",
|
|
358
384
|
path: "/v1/media",
|
|
@@ -360,25 +386,25 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
360
386
|
media: mediaData
|
|
361
387
|
}
|
|
362
388
|
});
|
|
363
|
-
case
|
|
364
|
-
_context4.n =
|
|
389
|
+
case 18:
|
|
390
|
+
_context4.n = 20;
|
|
365
391
|
break;
|
|
366
|
-
case
|
|
367
|
-
_context4.p =
|
|
368
|
-
|
|
369
|
-
console.error("Upload error:",
|
|
392
|
+
case 19:
|
|
393
|
+
_context4.p = 19;
|
|
394
|
+
_t5 = _context4.v;
|
|
395
|
+
console.error("Upload error:", _t5);
|
|
370
396
|
if (this.onError) {
|
|
371
|
-
this.onError(
|
|
397
|
+
this.onError(_t5);
|
|
372
398
|
}
|
|
373
|
-
throw
|
|
374
|
-
case
|
|
399
|
+
throw _t5;
|
|
400
|
+
case 20:
|
|
375
401
|
i++;
|
|
376
402
|
_context4.n = 2;
|
|
377
403
|
break;
|
|
378
|
-
case
|
|
404
|
+
case 21:
|
|
379
405
|
return _context4.a(2, all_files_uri);
|
|
380
406
|
}
|
|
381
|
-
}, _callee4, this, [[6,
|
|
407
|
+
}, _callee4, this, [[7, 12], [6, 15], [3, 19]]);
|
|
382
408
|
}));
|
|
383
409
|
function uploadMedia(_x5, _x6) {
|
|
384
410
|
return _uploadMedia.apply(this, arguments);
|
|
@@ -79,6 +79,7 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
79
79
|
onUploadError = _ref.onUploadError,
|
|
80
80
|
picker = _ref.picker,
|
|
81
81
|
pickerOptions = _ref.pickerOptions,
|
|
82
|
+
icon = _ref.icon,
|
|
82
83
|
_ref$theme = _ref.theme,
|
|
83
84
|
theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
|
|
84
85
|
containerStyle = _ref.containerStyle,
|
|
@@ -97,14 +98,44 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
97
98
|
|
|
98
99
|
// Convert file picker result to File-like object for apiService
|
|
99
100
|
var convertToFile = function convertToFile(pickerResult) {
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
//
|
|
101
|
+
// Handle different picker formats:
|
|
102
|
+
// react-native-image-picker: { uri, fileName, mimeType, fileSize, ... }
|
|
103
|
+
// expo-image-picker: { uri, fileName, mimeType, ... }
|
|
104
|
+
// Custom: { uri, name, type, ... }
|
|
105
|
+
|
|
106
|
+
// Extract URI (can be file://, content://, or http://)
|
|
107
|
+
var uri = pickerResult.uri || pickerResult.path;
|
|
108
|
+
|
|
109
|
+
// Extract file name (handle different property names)
|
|
110
|
+
var fileName = pickerResult.fileName || pickerResult.name;
|
|
111
|
+
|
|
112
|
+
// If no fileName, try to extract from URI
|
|
113
|
+
if (!fileName && uri) {
|
|
114
|
+
var uriParts = uri.split("/");
|
|
115
|
+
var lastPart = uriParts[uriParts.length - 1];
|
|
116
|
+
fileName = lastPart ? lastPart.split("?")[0] : null; // Remove query params if any
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Final fallback
|
|
120
|
+
if (!fileName) {
|
|
121
|
+
// Try to guess from mimeType
|
|
122
|
+
var _mimeType = pickerResult.mimeType || pickerResult.type || "";
|
|
123
|
+
if (_mimeType.includes("image")) {
|
|
124
|
+
fileName = _mimeType.includes("jpeg") || _mimeType.includes("jpg") ? "image.jpg" : _mimeType.includes("png") ? "image.png" : _mimeType.includes("gif") ? "image.gif" : "image.jpg";
|
|
125
|
+
} else if (_mimeType.includes("video")) {
|
|
126
|
+
fileName = "video.mp4";
|
|
127
|
+
} else {
|
|
128
|
+
fileName = "file";
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Extract MIME type (handle different property names)
|
|
133
|
+
var mimeType = pickerResult.mimeType || pickerResult.type || "image/jpeg"; // Default fallback
|
|
103
134
|
|
|
104
135
|
return {
|
|
105
|
-
uri:
|
|
106
|
-
name:
|
|
107
|
-
type:
|
|
136
|
+
uri: uri,
|
|
137
|
+
name: fileName,
|
|
138
|
+
type: mimeType,
|
|
108
139
|
// Keep original picker result for potential use
|
|
109
140
|
_pickerResult: pickerResult
|
|
110
141
|
};
|
|
@@ -195,7 +226,8 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
195
226
|
case 2:
|
|
196
227
|
result = _context2.v;
|
|
197
228
|
// Handle different picker response formats
|
|
198
|
-
// react-native-image-picker: { assets: [...] }
|
|
229
|
+
// react-native-image-picker: { assets: [{ uri, fileName, mimeType, ... }] }
|
|
230
|
+
// Example: { assets: [{ uri: "file:///...", fileName: "image.jpg", mimeType: "image/jpeg" }] }
|
|
199
231
|
// expo-image-picker: { assets: [...] }
|
|
200
232
|
// Custom: could be array directly or { assets: [...] }
|
|
201
233
|
assets = Array.isArray(result) ? result : (result === null || result === void 0 ? void 0 : result.assets) || result || [];
|
|
@@ -256,19 +288,20 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
256
288
|
borderRadius: theme.radius.md
|
|
257
289
|
}, buttonStyle],
|
|
258
290
|
disabled: isLoading,
|
|
259
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
291
|
+
children: [icon && /*#__PURE__*/_jsx(View, {
|
|
260
292
|
style: [styles.iconContainer, {
|
|
261
293
|
backgroundColor: theme.colors.uploadIconBackground,
|
|
262
294
|
borderRadius: theme.radius.xl,
|
|
263
295
|
marginBottom: theme.spacing.sm,
|
|
264
296
|
padding: theme.spacing.md
|
|
265
297
|
}, iconContainerStyle],
|
|
266
|
-
children:
|
|
298
|
+
children: icon
|
|
267
299
|
}), /*#__PURE__*/_jsx(Text, {
|
|
268
300
|
style: [styles.title, {
|
|
269
301
|
color: theme.colors.uploadText,
|
|
270
|
-
|
|
271
|
-
|
|
302
|
+
fontSize: theme.typography.body.fontSize,
|
|
303
|
+
fontWeight: theme.typography.body.fontWeight,
|
|
304
|
+
marginTop: icon ? theme.spacing.sm : 0
|
|
272
305
|
}, titleStyle],
|
|
273
306
|
children: title
|
|
274
307
|
})]
|
|
@@ -17,6 +17,7 @@ import { View, FlatList, Image, TouchableOpacity, StyleSheet, Dimensions } from
|
|
|
17
17
|
import FileUpload from './FileUpload.native';
|
|
18
18
|
import ImagesSkeleton from './ImagesSkeleton.native';
|
|
19
19
|
import Pagination from './Pagination.native';
|
|
20
|
+
import { CameraIcon } from './Icons.native';
|
|
20
21
|
import { defaultTheme } from './theme';
|
|
21
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
23
|
var _Dimensions$get = Dimensions.get('window'),
|
|
@@ -134,7 +135,8 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
134
135
|
onUploadError: onError,
|
|
135
136
|
picker: picker,
|
|
136
137
|
pickerOptions: pickerOptions,
|
|
137
|
-
theme: theme
|
|
138
|
+
theme: theme,
|
|
139
|
+
icon: /*#__PURE__*/_jsx(CameraIcon, {})
|
|
138
140
|
})
|
|
139
141
|
});
|
|
140
142
|
}
|
|
@@ -4,13 +4,13 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
4
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
-
import React from
|
|
8
|
-
import { Modal, View, Text, TouchableOpacity, StyleSheet, Dimensions, Animated, TouchableWithoutFeedback } from
|
|
9
|
-
import MediaTab from
|
|
10
|
-
import { CloseIcon } from
|
|
11
|
-
import { createTheme } from
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { Modal, View, Text, TouchableOpacity, StyleSheet, Dimensions, Animated, TouchableWithoutFeedback } from "react-native";
|
|
9
|
+
import MediaTab from "./MediaTab.native";
|
|
10
|
+
import { CloseIcon } from "./Icons.native";
|
|
11
|
+
import { createTheme } from "./theme";
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
var _Dimensions$get = Dimensions.get(
|
|
13
|
+
var _Dimensions$get = Dimensions.get("window"),
|
|
14
14
|
SCREEN_HEIGHT = _Dimensions$get.height;
|
|
15
15
|
var MediaPopup = function MediaPopup(_ref) {
|
|
16
16
|
var isOpen = _ref.isOpen,
|
|
@@ -18,11 +18,11 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
18
18
|
onSelect = _ref.onSelect,
|
|
19
19
|
currentData = _ref.currentData,
|
|
20
20
|
_ref$options = _ref.options,
|
|
21
|
-
options = _ref$options === void 0 ? [
|
|
21
|
+
options = _ref$options === void 0 ? ["image"] : _ref$options,
|
|
22
22
|
apiService = _ref.apiService,
|
|
23
23
|
onError = _ref.onError,
|
|
24
24
|
_ref$title = _ref.title,
|
|
25
|
-
title = _ref$title === void 0 ?
|
|
25
|
+
title = _ref$title === void 0 ? "Media Gallery" : _ref$title,
|
|
26
26
|
picker = _ref.picker,
|
|
27
27
|
pickerOptions = _ref.pickerOptions,
|
|
28
28
|
theme = _ref.theme,
|
|
@@ -84,6 +84,7 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
84
84
|
backgroundColor: currentTheme.colors.background,
|
|
85
85
|
borderTopLeftRadius: currentTheme.radius.xxl,
|
|
86
86
|
borderTopRightRadius: currentTheme.radius.xxl,
|
|
87
|
+
height: SCREEN_HEIGHT * sheetHeight,
|
|
87
88
|
maxHeight: SCREEN_HEIGHT * sheetHeight,
|
|
88
89
|
padding: currentTheme.spacing.xl
|
|
89
90
|
}, containerStyle, {
|
|
@@ -93,9 +94,7 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
93
94
|
}],
|
|
94
95
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
95
96
|
style: [styles.header, {
|
|
96
|
-
|
|
97
|
-
marginBottom: currentTheme.spacing.lg,
|
|
98
|
-
paddingBottom: currentTheme.spacing.md
|
|
97
|
+
marginBottom: currentTheme.spacing.md
|
|
99
98
|
}, headerStyle],
|
|
100
99
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
101
100
|
style: [styles.title, {
|
|
@@ -139,24 +138,24 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
139
138
|
var styles = StyleSheet.create({
|
|
140
139
|
overlay: {
|
|
141
140
|
flex: 1,
|
|
142
|
-
justifyContent:
|
|
141
|
+
justifyContent: "flex-end"
|
|
143
142
|
},
|
|
144
143
|
container: {
|
|
145
|
-
|
|
146
|
-
shadowColor:
|
|
144
|
+
width: "100%",
|
|
145
|
+
shadowColor: "#000",
|
|
147
146
|
shadowOffset: {
|
|
148
147
|
width: 0,
|
|
149
148
|
height: -2
|
|
150
149
|
},
|
|
151
150
|
shadowOpacity: 0.25,
|
|
152
151
|
shadowRadius: 3.84,
|
|
153
|
-
elevation: 5
|
|
152
|
+
elevation: 5,
|
|
153
|
+
overflow: "hidden" // Ensure content doesn't overflow
|
|
154
154
|
},
|
|
155
155
|
header: {
|
|
156
|
-
flexDirection:
|
|
157
|
-
alignItems:
|
|
158
|
-
justifyContent:
|
|
159
|
-
borderBottomWidth: 1
|
|
156
|
+
flexDirection: "row",
|
|
157
|
+
alignItems: "center",
|
|
158
|
+
justifyContent: "space-between"
|
|
160
159
|
},
|
|
161
160
|
title: {
|
|
162
161
|
flex: 1
|
|
@@ -4,11 +4,11 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
4
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
-
import React, { useMemo, useState } from
|
|
8
|
-
import { View, Text, TouchableOpacity, StyleSheet } from
|
|
9
|
-
import ImagesGallery from
|
|
10
|
-
import VideosGallery from
|
|
11
|
-
import { defaultTheme } from
|
|
7
|
+
import React, { useMemo, useState } from "react";
|
|
8
|
+
import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
|
|
9
|
+
import ImagesGallery from "./MediaGallery.native";
|
|
10
|
+
import VideosGallery from "./VideosGallery.native";
|
|
11
|
+
import { defaultTheme } from "./theme";
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
var MediaTab = function MediaTab(_ref) {
|
|
14
14
|
var imagePopup = _ref.imagePopup,
|
|
@@ -35,9 +35,9 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
35
35
|
// Build a stable list of enabled tabs in order
|
|
36
36
|
var availableTabs = useMemo(function () {
|
|
37
37
|
var tabs = [];
|
|
38
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
39
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
40
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
38
|
+
if (options !== null && options !== void 0 && options.includes("image")) tabs.push("image");
|
|
39
|
+
if (options !== null && options !== void 0 && options.includes("video")) tabs.push("video");
|
|
40
|
+
if (options !== null && options !== void 0 && options.includes("file")) tabs.push("file");
|
|
41
41
|
return tabs;
|
|
42
42
|
}, [options]);
|
|
43
43
|
var _useState = useState(0),
|
|
@@ -50,13 +50,13 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
52
|
var renderTabLabel = function renderTabLabel(type) {
|
|
53
|
-
if (type ===
|
|
54
|
-
if (type ===
|
|
55
|
-
if (type ===
|
|
53
|
+
if (type === "image") return "Images";
|
|
54
|
+
if (type === "video") return "Videos";
|
|
55
|
+
if (type === "file") return "Files";
|
|
56
56
|
return type;
|
|
57
57
|
};
|
|
58
58
|
var renderPanel = function renderPanel(type) {
|
|
59
|
-
if (type ===
|
|
59
|
+
if (type === "image") {
|
|
60
60
|
return /*#__PURE__*/_jsx(ImagesGallery, {
|
|
61
61
|
imagePopup: imagePopup,
|
|
62
62
|
update_data: update_data,
|
|
@@ -65,10 +65,11 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
65
65
|
apiService: apiService,
|
|
66
66
|
onError: onError,
|
|
67
67
|
picker: picker,
|
|
68
|
-
pickerOptions: pickerOptions
|
|
68
|
+
pickerOptions: pickerOptions,
|
|
69
|
+
theme: theme
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
|
-
if (type ===
|
|
72
|
+
if (type === "video") {
|
|
72
73
|
return /*#__PURE__*/_jsx(VideosGallery, {
|
|
73
74
|
imagePopup: imagePopup,
|
|
74
75
|
update_data: update_data,
|
|
@@ -81,7 +82,7 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
81
82
|
theme: theme
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
|
-
if (type ===
|
|
85
|
+
if (type === "file") {
|
|
85
86
|
// Reuse ImagesGallery for files as in original implementation
|
|
86
87
|
return /*#__PURE__*/_jsx(ImagesGallery, {
|
|
87
88
|
imagePopup: imagePopup,
|
|
@@ -91,7 +92,8 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
91
92
|
apiService: apiService,
|
|
92
93
|
onError: onError,
|
|
93
94
|
picker: picker,
|
|
94
|
-
pickerOptions: pickerOptions
|
|
95
|
+
pickerOptions: pickerOptions,
|
|
96
|
+
theme: theme
|
|
95
97
|
});
|
|
96
98
|
}
|
|
97
99
|
return null;
|
|
@@ -102,7 +104,9 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
102
104
|
style: [styles.tabList, {
|
|
103
105
|
backgroundColor: theme.colors.tabBackground,
|
|
104
106
|
borderBottomColor: theme.colors.border,
|
|
105
|
-
paddingHorizontal: theme.spacing.xs
|
|
107
|
+
paddingHorizontal: theme.spacing.xs,
|
|
108
|
+
// Always left align
|
|
109
|
+
justifyContent: "flex-start"
|
|
106
110
|
}, tabListStyle],
|
|
107
111
|
children: availableTabs.map(function (type, index) {
|
|
108
112
|
var isSelected = index === selectedIndex;
|
|
@@ -112,7 +116,8 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
112
116
|
},
|
|
113
117
|
style: [styles.tabButton, {
|
|
114
118
|
paddingVertical: theme.spacing.md,
|
|
115
|
-
paddingHorizontal: theme.spacing.lg
|
|
119
|
+
paddingHorizontal: theme.spacing.lg,
|
|
120
|
+
flex: 1
|
|
116
121
|
}, tabButtonStyle, isSelected ? [styles.tabButtonActive, tabButtonActiveStyle] : [styles.tabButtonInactive, tabButtonInactiveStyle]],
|
|
117
122
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
118
123
|
style: [styles.tabButtonText, {
|
|
@@ -148,14 +153,13 @@ var styles = StyleSheet.create({
|
|
|
148
153
|
flex: 1
|
|
149
154
|
},
|
|
150
155
|
tabList: {
|
|
151
|
-
flexDirection:
|
|
156
|
+
flexDirection: "row",
|
|
152
157
|
borderBottomWidth: 2
|
|
153
158
|
},
|
|
154
159
|
tabButton: {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
position: 'relative'
|
|
160
|
+
alignItems: "center",
|
|
161
|
+
justifyContent: "center",
|
|
162
|
+
position: "relative"
|
|
159
163
|
},
|
|
160
164
|
tabButtonActive: {
|
|
161
165
|
// Active state styling applied via theme
|
|
@@ -173,7 +177,7 @@ var styles = StyleSheet.create({
|
|
|
173
177
|
// Inactive text color applied via theme
|
|
174
178
|
},
|
|
175
179
|
tabIndicator: {
|
|
176
|
-
position:
|
|
180
|
+
position: "absolute",
|
|
177
181
|
bottom: -2,
|
|
178
182
|
left: 0,
|
|
179
183
|
right: 0,
|
|
@@ -186,7 +190,7 @@ var styles = StyleSheet.create({
|
|
|
186
190
|
flex: 1
|
|
187
191
|
},
|
|
188
192
|
panelHidden: {
|
|
189
|
-
display:
|
|
193
|
+
display: "none"
|
|
190
194
|
}
|
|
191
195
|
});
|
|
192
196
|
export default MediaTab;
|
|
@@ -17,6 +17,7 @@ import { View, FlatList, TouchableOpacity, StyleSheet, Dimensions, Text } from '
|
|
|
17
17
|
import FileUpload from './FileUpload.native';
|
|
18
18
|
import ImagesSkeleton from './ImagesSkeleton.native';
|
|
19
19
|
import Pagination from './Pagination.native';
|
|
20
|
+
import { CameraIcon } from './Icons.native';
|
|
20
21
|
import { defaultTheme } from './theme';
|
|
21
22
|
// Note: You'll need to install react-native-video for video playback
|
|
22
23
|
// import Video from 'react-native-video'
|
|
@@ -135,7 +136,8 @@ var VideosGallery = function VideosGallery(_ref) {
|
|
|
135
136
|
onUploadError: onError,
|
|
136
137
|
picker: picker,
|
|
137
138
|
pickerOptions: pickerOptions,
|
|
138
|
-
theme: theme
|
|
139
|
+
theme: theme,
|
|
140
|
+
icon: /*#__PURE__*/_jsx(CameraIcon, {})
|
|
139
141
|
})
|
|
140
142
|
});
|
|
141
143
|
}
|
|
@@ -85,6 +85,7 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
85
85
|
onUploadError = _ref.onUploadError,
|
|
86
86
|
picker = _ref.picker,
|
|
87
87
|
pickerOptions = _ref.pickerOptions,
|
|
88
|
+
icon = _ref.icon,
|
|
88
89
|
_ref$theme = _ref.theme,
|
|
89
90
|
theme = _ref$theme === void 0 ? _theme.defaultTheme : _ref$theme,
|
|
90
91
|
containerStyle = _ref.containerStyle,
|
|
@@ -103,14 +104,44 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
103
104
|
|
|
104
105
|
// Convert file picker result to File-like object for apiService
|
|
105
106
|
var convertToFile = function convertToFile(pickerResult) {
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
//
|
|
107
|
+
// Handle different picker formats:
|
|
108
|
+
// react-native-image-picker: { uri, fileName, mimeType, fileSize, ... }
|
|
109
|
+
// expo-image-picker: { uri, fileName, mimeType, ... }
|
|
110
|
+
// Custom: { uri, name, type, ... }
|
|
111
|
+
|
|
112
|
+
// Extract URI (can be file://, content://, or http://)
|
|
113
|
+
var uri = pickerResult.uri || pickerResult.path;
|
|
114
|
+
|
|
115
|
+
// Extract file name (handle different property names)
|
|
116
|
+
var fileName = pickerResult.fileName || pickerResult.name;
|
|
117
|
+
|
|
118
|
+
// If no fileName, try to extract from URI
|
|
119
|
+
if (!fileName && uri) {
|
|
120
|
+
var uriParts = uri.split("/");
|
|
121
|
+
var lastPart = uriParts[uriParts.length - 1];
|
|
122
|
+
fileName = lastPart ? lastPart.split("?")[0] : null; // Remove query params if any
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Final fallback
|
|
126
|
+
if (!fileName) {
|
|
127
|
+
// Try to guess from mimeType
|
|
128
|
+
var _mimeType = pickerResult.mimeType || pickerResult.type || "";
|
|
129
|
+
if (_mimeType.includes("image")) {
|
|
130
|
+
fileName = _mimeType.includes("jpeg") || _mimeType.includes("jpg") ? "image.jpg" : _mimeType.includes("png") ? "image.png" : _mimeType.includes("gif") ? "image.gif" : "image.jpg";
|
|
131
|
+
} else if (_mimeType.includes("video")) {
|
|
132
|
+
fileName = "video.mp4";
|
|
133
|
+
} else {
|
|
134
|
+
fileName = "file";
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Extract MIME type (handle different property names)
|
|
139
|
+
var mimeType = pickerResult.mimeType || pickerResult.type || "image/jpeg"; // Default fallback
|
|
109
140
|
|
|
110
141
|
return {
|
|
111
|
-
uri:
|
|
112
|
-
name:
|
|
113
|
-
type:
|
|
142
|
+
uri: uri,
|
|
143
|
+
name: fileName,
|
|
144
|
+
type: mimeType,
|
|
114
145
|
// Keep original picker result for potential use
|
|
115
146
|
_pickerResult: pickerResult
|
|
116
147
|
};
|
|
@@ -201,7 +232,8 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
201
232
|
case 2:
|
|
202
233
|
result = _context2.v;
|
|
203
234
|
// Handle different picker response formats
|
|
204
|
-
// react-native-image-picker: { assets: [...] }
|
|
235
|
+
// react-native-image-picker: { assets: [{ uri, fileName, mimeType, ... }] }
|
|
236
|
+
// Example: { assets: [{ uri: "file:///...", fileName: "image.jpg", mimeType: "image/jpeg" }] }
|
|
205
237
|
// expo-image-picker: { assets: [...] }
|
|
206
238
|
// Custom: could be array directly or { assets: [...] }
|
|
207
239
|
assets = Array.isArray(result) ? result : (result === null || result === void 0 ? void 0 : result.assets) || result || [];
|
|
@@ -262,19 +294,20 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
262
294
|
borderRadius: theme.radius.md
|
|
263
295
|
}, buttonStyle],
|
|
264
296
|
disabled: isLoading,
|
|
265
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
297
|
+
children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
266
298
|
style: [styles.iconContainer, {
|
|
267
299
|
backgroundColor: theme.colors.uploadIconBackground,
|
|
268
300
|
borderRadius: theme.radius.xl,
|
|
269
301
|
marginBottom: theme.spacing.sm,
|
|
270
302
|
padding: theme.spacing.md
|
|
271
303
|
}, iconContainerStyle],
|
|
272
|
-
children:
|
|
304
|
+
children: icon
|
|
273
305
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
274
306
|
style: [styles.title, {
|
|
275
307
|
color: theme.colors.uploadText,
|
|
276
|
-
|
|
277
|
-
|
|
308
|
+
fontSize: theme.typography.body.fontSize,
|
|
309
|
+
fontWeight: theme.typography.body.fontWeight,
|
|
310
|
+
marginTop: icon ? theme.spacing.sm : 0
|
|
278
311
|
}, titleStyle],
|
|
279
312
|
children: title
|
|
280
313
|
})]
|
|
@@ -10,6 +10,7 @@ var _reactNative = require("react-native");
|
|
|
10
10
|
var _FileUpload = _interopRequireDefault(require("./FileUpload.native"));
|
|
11
11
|
var _ImagesSkeleton = _interopRequireDefault(require("./ImagesSkeleton.native"));
|
|
12
12
|
var _Pagination = _interopRequireDefault(require("./Pagination.native"));
|
|
13
|
+
var _Icons = require("./Icons.native");
|
|
13
14
|
var _theme = require("./theme");
|
|
14
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -143,7 +144,8 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
143
144
|
onUploadError: onError,
|
|
144
145
|
picker: picker,
|
|
145
146
|
pickerOptions: pickerOptions,
|
|
146
|
-
theme: theme
|
|
147
|
+
theme: theme,
|
|
148
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.CameraIcon, {})
|
|
147
149
|
})
|
|
148
150
|
});
|
|
149
151
|
}
|
|
@@ -17,7 +17,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
17
17
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
18
18
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
19
19
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
20
|
-
var _Dimensions$get = _reactNative.Dimensions.get(
|
|
20
|
+
var _Dimensions$get = _reactNative.Dimensions.get("window"),
|
|
21
21
|
SCREEN_HEIGHT = _Dimensions$get.height;
|
|
22
22
|
var MediaPopup = function MediaPopup(_ref) {
|
|
23
23
|
var isOpen = _ref.isOpen,
|
|
@@ -25,11 +25,11 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
25
25
|
onSelect = _ref.onSelect,
|
|
26
26
|
currentData = _ref.currentData,
|
|
27
27
|
_ref$options = _ref.options,
|
|
28
|
-
options = _ref$options === void 0 ? [
|
|
28
|
+
options = _ref$options === void 0 ? ["image"] : _ref$options,
|
|
29
29
|
apiService = _ref.apiService,
|
|
30
30
|
onError = _ref.onError,
|
|
31
31
|
_ref$title = _ref.title,
|
|
32
|
-
title = _ref$title === void 0 ?
|
|
32
|
+
title = _ref$title === void 0 ? "Media Gallery" : _ref$title,
|
|
33
33
|
picker = _ref.picker,
|
|
34
34
|
pickerOptions = _ref.pickerOptions,
|
|
35
35
|
theme = _ref.theme,
|
|
@@ -91,6 +91,7 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
91
91
|
backgroundColor: currentTheme.colors.background,
|
|
92
92
|
borderTopLeftRadius: currentTheme.radius.xxl,
|
|
93
93
|
borderTopRightRadius: currentTheme.radius.xxl,
|
|
94
|
+
height: SCREEN_HEIGHT * sheetHeight,
|
|
94
95
|
maxHeight: SCREEN_HEIGHT * sheetHeight,
|
|
95
96
|
padding: currentTheme.spacing.xl
|
|
96
97
|
}, containerStyle, {
|
|
@@ -100,9 +101,7 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
100
101
|
}],
|
|
101
102
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
102
103
|
style: [styles.header, {
|
|
103
|
-
|
|
104
|
-
marginBottom: currentTheme.spacing.lg,
|
|
105
|
-
paddingBottom: currentTheme.spacing.md
|
|
104
|
+
marginBottom: currentTheme.spacing.md
|
|
106
105
|
}, headerStyle],
|
|
107
106
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
108
107
|
style: [styles.title, {
|
|
@@ -146,24 +145,24 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
146
145
|
var styles = _reactNative.StyleSheet.create({
|
|
147
146
|
overlay: {
|
|
148
147
|
flex: 1,
|
|
149
|
-
justifyContent:
|
|
148
|
+
justifyContent: "flex-end"
|
|
150
149
|
},
|
|
151
150
|
container: {
|
|
152
|
-
|
|
153
|
-
shadowColor:
|
|
151
|
+
width: "100%",
|
|
152
|
+
shadowColor: "#000",
|
|
154
153
|
shadowOffset: {
|
|
155
154
|
width: 0,
|
|
156
155
|
height: -2
|
|
157
156
|
},
|
|
158
157
|
shadowOpacity: 0.25,
|
|
159
158
|
shadowRadius: 3.84,
|
|
160
|
-
elevation: 5
|
|
159
|
+
elevation: 5,
|
|
160
|
+
overflow: "hidden" // Ensure content doesn't overflow
|
|
161
161
|
},
|
|
162
162
|
header: {
|
|
163
|
-
flexDirection:
|
|
164
|
-
alignItems:
|
|
165
|
-
justifyContent:
|
|
166
|
-
borderBottomWidth: 1
|
|
163
|
+
flexDirection: "row",
|
|
164
|
+
alignItems: "center",
|
|
165
|
+
justifyContent: "space-between"
|
|
167
166
|
},
|
|
168
167
|
title: {
|
|
169
168
|
flex: 1
|
|
@@ -44,9 +44,9 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
44
44
|
// Build a stable list of enabled tabs in order
|
|
45
45
|
var availableTabs = (0, _react.useMemo)(function () {
|
|
46
46
|
var tabs = [];
|
|
47
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
48
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
49
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
47
|
+
if (options !== null && options !== void 0 && options.includes("image")) tabs.push("image");
|
|
48
|
+
if (options !== null && options !== void 0 && options.includes("video")) tabs.push("video");
|
|
49
|
+
if (options !== null && options !== void 0 && options.includes("file")) tabs.push("file");
|
|
50
50
|
return tabs;
|
|
51
51
|
}, [options]);
|
|
52
52
|
var _useState = (0, _react.useState)(0),
|
|
@@ -59,13 +59,13 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
61
|
var renderTabLabel = function renderTabLabel(type) {
|
|
62
|
-
if (type ===
|
|
63
|
-
if (type ===
|
|
64
|
-
if (type ===
|
|
62
|
+
if (type === "image") return "Images";
|
|
63
|
+
if (type === "video") return "Videos";
|
|
64
|
+
if (type === "file") return "Files";
|
|
65
65
|
return type;
|
|
66
66
|
};
|
|
67
67
|
var renderPanel = function renderPanel(type) {
|
|
68
|
-
if (type ===
|
|
68
|
+
if (type === "image") {
|
|
69
69
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MediaGallery.default, {
|
|
70
70
|
imagePopup: imagePopup,
|
|
71
71
|
update_data: update_data,
|
|
@@ -74,10 +74,11 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
74
74
|
apiService: apiService,
|
|
75
75
|
onError: onError,
|
|
76
76
|
picker: picker,
|
|
77
|
-
pickerOptions: pickerOptions
|
|
77
|
+
pickerOptions: pickerOptions,
|
|
78
|
+
theme: theme
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
|
-
if (type ===
|
|
81
|
+
if (type === "video") {
|
|
81
82
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_VideosGallery.default, {
|
|
82
83
|
imagePopup: imagePopup,
|
|
83
84
|
update_data: update_data,
|
|
@@ -90,7 +91,7 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
90
91
|
theme: theme
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
|
-
if (type ===
|
|
94
|
+
if (type === "file") {
|
|
94
95
|
// Reuse ImagesGallery for files as in original implementation
|
|
95
96
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MediaGallery.default, {
|
|
96
97
|
imagePopup: imagePopup,
|
|
@@ -100,7 +101,8 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
100
101
|
apiService: apiService,
|
|
101
102
|
onError: onError,
|
|
102
103
|
picker: picker,
|
|
103
|
-
pickerOptions: pickerOptions
|
|
104
|
+
pickerOptions: pickerOptions,
|
|
105
|
+
theme: theme
|
|
104
106
|
});
|
|
105
107
|
}
|
|
106
108
|
return null;
|
|
@@ -111,7 +113,9 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
111
113
|
style: [styles.tabList, {
|
|
112
114
|
backgroundColor: theme.colors.tabBackground,
|
|
113
115
|
borderBottomColor: theme.colors.border,
|
|
114
|
-
paddingHorizontal: theme.spacing.xs
|
|
116
|
+
paddingHorizontal: theme.spacing.xs,
|
|
117
|
+
// Always left align
|
|
118
|
+
justifyContent: "flex-start"
|
|
115
119
|
}, tabListStyle],
|
|
116
120
|
children: availableTabs.map(function (type, index) {
|
|
117
121
|
var isSelected = index === selectedIndex;
|
|
@@ -121,7 +125,8 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
121
125
|
},
|
|
122
126
|
style: [styles.tabButton, {
|
|
123
127
|
paddingVertical: theme.spacing.md,
|
|
124
|
-
paddingHorizontal: theme.spacing.lg
|
|
128
|
+
paddingHorizontal: theme.spacing.lg,
|
|
129
|
+
flex: 1
|
|
125
130
|
}, tabButtonStyle, isSelected ? [styles.tabButtonActive, tabButtonActiveStyle] : [styles.tabButtonInactive, tabButtonInactiveStyle]],
|
|
126
131
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
127
132
|
style: [styles.tabButtonText, {
|
|
@@ -157,14 +162,13 @@ var styles = _reactNative.StyleSheet.create({
|
|
|
157
162
|
flex: 1
|
|
158
163
|
},
|
|
159
164
|
tabList: {
|
|
160
|
-
flexDirection:
|
|
165
|
+
flexDirection: "row",
|
|
161
166
|
borderBottomWidth: 2
|
|
162
167
|
},
|
|
163
168
|
tabButton: {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
position: 'relative'
|
|
169
|
+
alignItems: "center",
|
|
170
|
+
justifyContent: "center",
|
|
171
|
+
position: "relative"
|
|
168
172
|
},
|
|
169
173
|
tabButtonActive: {
|
|
170
174
|
// Active state styling applied via theme
|
|
@@ -182,7 +186,7 @@ var styles = _reactNative.StyleSheet.create({
|
|
|
182
186
|
// Inactive text color applied via theme
|
|
183
187
|
},
|
|
184
188
|
tabIndicator: {
|
|
185
|
-
position:
|
|
189
|
+
position: "absolute",
|
|
186
190
|
bottom: -2,
|
|
187
191
|
left: 0,
|
|
188
192
|
right: 0,
|
|
@@ -195,7 +199,7 @@ var styles = _reactNative.StyleSheet.create({
|
|
|
195
199
|
flex: 1
|
|
196
200
|
},
|
|
197
201
|
panelHidden: {
|
|
198
|
-
display:
|
|
202
|
+
display: "none"
|
|
199
203
|
}
|
|
200
204
|
});
|
|
201
205
|
var _default = exports.default = MediaTab;
|
|
@@ -10,6 +10,7 @@ var _reactNative = require("react-native");
|
|
|
10
10
|
var _FileUpload = _interopRequireDefault(require("./FileUpload.native"));
|
|
11
11
|
var _ImagesSkeleton = _interopRequireDefault(require("./ImagesSkeleton.native"));
|
|
12
12
|
var _Pagination = _interopRequireDefault(require("./Pagination.native"));
|
|
13
|
+
var _Icons = require("./Icons.native");
|
|
13
14
|
var _theme = require("./theme");
|
|
14
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -143,7 +144,8 @@ var VideosGallery = function VideosGallery(_ref) {
|
|
|
143
144
|
onUploadError: onError,
|
|
144
145
|
picker: picker,
|
|
145
146
|
pickerOptions: pickerOptions,
|
|
146
|
-
theme: theme
|
|
147
|
+
theme: theme,
|
|
148
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.CameraIcon, {})
|
|
147
149
|
})
|
|
148
150
|
});
|
|
149
151
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradly/asset",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "A reusable media gallery component for uploading and selecting images, videos, and files with Tradly authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|