@tradly/asset 1.0.13 → 1.0.15

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 (76) hide show
  1. package/README.md +414 -13
  2. package/dist/components/FileUpload.js +8 -254
  3. package/dist/components/FileUpload.native.js +13 -0
  4. package/dist/components/Icons.js +10 -33
  5. package/dist/components/Icons.native.js +16 -0
  6. package/dist/components/ImagesSkeleton.js +7 -15
  7. package/dist/components/ImagesSkeleton.native.js +13 -0
  8. package/dist/components/MediaGallery.js +8 -148
  9. package/dist/components/MediaGallery.native.js +13 -0
  10. package/dist/components/MediaPopup.js +8 -99
  11. package/dist/components/MediaPopup.native.js +13 -0
  12. package/dist/components/MediaTab.js +7 -180
  13. package/dist/components/MediaTab.native.js +13 -0
  14. package/dist/components/Pagination.js +8 -136
  15. package/dist/components/Pagination.native.js +13 -0
  16. package/dist/components/VideosGallery.js +8 -148
  17. package/dist/components/VideosGallery.native.js +13 -0
  18. package/dist/core/MediaApiService.js +396 -0
  19. package/dist/esm/components/FileUpload.js +1 -253
  20. package/dist/esm/components/FileUpload.native.js +1 -0
  21. package/dist/esm/components/Icons.js +1 -32
  22. package/dist/esm/components/Icons.native.js +1 -0
  23. package/dist/esm/components/ImagesSkeleton.js +1 -14
  24. package/dist/esm/components/ImagesSkeleton.native.js +1 -0
  25. package/dist/esm/components/MediaGallery.js +1 -144
  26. package/dist/esm/components/MediaGallery.native.js +1 -0
  27. package/dist/esm/components/MediaPopup.js +1 -97
  28. package/dist/esm/components/MediaPopup.native.js +1 -0
  29. package/dist/esm/components/MediaTab.js +1 -177
  30. package/dist/esm/components/MediaTab.native.js +1 -0
  31. package/dist/esm/components/Pagination.js +1 -134
  32. package/dist/esm/components/Pagination.native.js +1 -0
  33. package/dist/esm/components/VideosGallery.js +1 -144
  34. package/dist/esm/components/VideosGallery.native.js +1 -0
  35. package/dist/esm/core/MediaApiService.js +390 -0
  36. package/dist/esm/index.js +4 -1
  37. package/dist/esm/native/FileUpload.native.js +310 -0
  38. package/dist/esm/native/Icons.native.js +51 -0
  39. package/dist/esm/native/ImagesSkeleton.native.js +45 -0
  40. package/dist/esm/native/MediaGallery.native.js +228 -0
  41. package/dist/esm/native/MediaPopup.native.js +170 -0
  42. package/dist/esm/native/MediaTab.native.js +192 -0
  43. package/dist/esm/native/Pagination.native.js +210 -0
  44. package/dist/esm/native/THEME_EXAMPLE.js +112 -0
  45. package/dist/esm/native/VideosGallery.native.js +240 -0
  46. package/dist/esm/native/theme.js +167 -0
  47. package/dist/esm/services/apiService.js +1 -372
  48. package/dist/esm/web/FileUpload.web.js +253 -0
  49. package/dist/esm/web/Icons.web.js +32 -0
  50. package/dist/esm/web/ImagesSkeleton.web.js +14 -0
  51. package/dist/esm/web/MediaGallery.web.js +144 -0
  52. package/dist/esm/web/MediaPopup.web.js +97 -0
  53. package/dist/esm/web/MediaTab.web.js +177 -0
  54. package/dist/esm/web/Pagination.web.js +134 -0
  55. package/dist/esm/web/VideosGallery.web.js +144 -0
  56. package/dist/index.js +16 -2
  57. package/dist/native/FileUpload.native.js +316 -0
  58. package/dist/native/Icons.native.js +59 -0
  59. package/dist/native/ImagesSkeleton.native.js +52 -0
  60. package/dist/native/MediaGallery.native.js +237 -0
  61. package/dist/native/MediaPopup.native.js +177 -0
  62. package/dist/native/MediaTab.native.js +201 -0
  63. package/dist/native/Pagination.native.js +217 -0
  64. package/dist/native/THEME_EXAMPLE.js +117 -0
  65. package/dist/native/VideosGallery.native.js +248 -0
  66. package/dist/native/theme.js +173 -0
  67. package/dist/services/apiService.js +2 -372
  68. package/dist/web/FileUpload.web.js +259 -0
  69. package/dist/web/Icons.web.js +39 -0
  70. package/dist/web/ImagesSkeleton.web.js +21 -0
  71. package/dist/web/MediaGallery.web.js +153 -0
  72. package/dist/web/MediaPopup.web.js +104 -0
  73. package/dist/web/MediaTab.web.js +186 -0
  74. package/dist/web/Pagination.web.js +141 -0
  75. package/dist/web/VideosGallery.web.js +153 -0
  76. package/package.json +3 -2
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _theme = require("./theme");
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ var Pagination = function Pagination(_ref) {
13
+ var nextPage = _ref.nextPage,
14
+ current_page = _ref.current_page,
15
+ pageCount = _ref.pageCount,
16
+ _ref$theme = _ref.theme,
17
+ theme = _ref$theme === void 0 ? _theme.defaultTheme : _ref$theme,
18
+ containerStyle = _ref.containerStyle,
19
+ navStyle = _ref.navStyle,
20
+ previousButtonStyle = _ref.previousButtonStyle,
21
+ nextButtonStyle = _ref.nextButtonStyle,
22
+ pageButtonStyle = _ref.pageButtonStyle,
23
+ pageButtonActiveStyle = _ref.pageButtonActiveStyle,
24
+ ellipsisStyle = _ref.ellipsisStyle,
25
+ pageButtonTextStyle = _ref.pageButtonTextStyle,
26
+ pageButtonTextActiveStyle = _ref.pageButtonTextActiveStyle;
27
+ var totalPages = Math.ceil(pageCount) || 1;
28
+ var currentPage = current_page || 1;
29
+
30
+ // Generate page numbers to display
31
+ var getPageNumbers = function getPageNumbers() {
32
+ var pages = [];
33
+ var maxVisible = 5;
34
+ var startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
35
+ var endPage = Math.min(totalPages, startPage + maxVisible - 1);
36
+ if (endPage - startPage < maxVisible - 1) {
37
+ startPage = Math.max(1, endPage - maxVisible + 1);
38
+ }
39
+
40
+ // Add first page and ellipsis
41
+ if (startPage > 1) {
42
+ pages.push(1);
43
+ if (startPage > 2) {
44
+ pages.push('...');
45
+ }
46
+ }
47
+
48
+ // Add visible pages
49
+ for (var i = startPage; i <= endPage; i++) {
50
+ pages.push(i);
51
+ }
52
+
53
+ // Add ellipsis and last page
54
+ if (endPage < totalPages) {
55
+ if (endPage < totalPages - 1) {
56
+ pages.push('...');
57
+ }
58
+ pages.push(totalPages);
59
+ }
60
+ return pages;
61
+ };
62
+ var handlePageClick = function handlePageClick(page) {
63
+ if (page !== currentPage && page >= 1 && page <= totalPages && typeof page === 'number') {
64
+ nextPage(page);
65
+ }
66
+ };
67
+ var handlePrevious = function handlePrevious() {
68
+ if (currentPage > 1) {
69
+ nextPage(currentPage - 1);
70
+ }
71
+ };
72
+ var handleNext = function handleNext() {
73
+ if (currentPage < totalPages) {
74
+ nextPage(currentPage + 1);
75
+ }
76
+ };
77
+ if (totalPages <= 1) return null;
78
+ var pageNumbers = getPageNumbers();
79
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
80
+ style: [styles.container, containerStyle],
81
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
82
+ style: [styles.nav, navStyle],
83
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
84
+ onPress: handlePrevious,
85
+ disabled: currentPage === 1,
86
+ style: [styles.button, styles.previousButton, {
87
+ backgroundColor: theme.colors.paginationButton,
88
+ borderColor: theme.colors.paginationBorder
89
+ }, previousButtonStyle, currentPage === 1 && styles.buttonDisabled],
90
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
91
+ style: [styles.buttonText, {
92
+ color: theme.colors.paginationText
93
+ }],
94
+ children: "\u2039"
95
+ })
96
+ }), pageNumbers.map(function (page, index) {
97
+ if (page === '...') {
98
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
99
+ style: [styles.ellipsis, {
100
+ backgroundColor: theme.colors.paginationButton,
101
+ borderColor: theme.colors.paginationBorder
102
+ }, ellipsisStyle],
103
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
104
+ style: [styles.ellipsisText, {
105
+ color: theme.colors.paginationText
106
+ }],
107
+ children: "..."
108
+ })
109
+ }, "ellipsis-".concat(index));
110
+ }
111
+ var isActive = page === currentPage;
112
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
113
+ onPress: function onPress() {
114
+ return handlePageClick(page);
115
+ },
116
+ style: [styles.button, styles.pageButton, {
117
+ backgroundColor: isActive ? theme.colors.paginationButtonActive : theme.colors.paginationButton,
118
+ borderColor: isActive ? theme.colors.paginationButtonActive : theme.colors.paginationBorder
119
+ }, pageButtonStyle, isActive && [styles.pageButtonActive, pageButtonActiveStyle]],
120
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
121
+ style: [styles.pageButtonText, {
122
+ color: isActive ? theme.colors.paginationTextActive : theme.colors.paginationText,
123
+ fontWeight: isActive ? '600' : '500'
124
+ }, isActive && pageButtonTextActiveStyle, pageButtonTextStyle],
125
+ children: page
126
+ })
127
+ }, page);
128
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
129
+ onPress: handleNext,
130
+ disabled: currentPage === totalPages,
131
+ style: [styles.button, styles.nextButton, {
132
+ backgroundColor: theme.colors.paginationButton,
133
+ borderColor: theme.colors.paginationBorder
134
+ }, nextButtonStyle, currentPage === totalPages && styles.buttonDisabled],
135
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
136
+ style: [styles.buttonText, {
137
+ color: theme.colors.paginationText
138
+ }],
139
+ children: "\u203A"
140
+ })
141
+ })]
142
+ })
143
+ });
144
+ };
145
+ var styles = _reactNative.StyleSheet.create({
146
+ container: {
147
+ alignItems: 'center',
148
+ justifyContent: 'center'
149
+ },
150
+ nav: {
151
+ flexDirection: 'row',
152
+ alignItems: 'center',
153
+ justifyContent: 'center',
154
+ flexWrap: 'wrap'
155
+ },
156
+ button: {
157
+ minWidth: 40,
158
+ height: 40,
159
+ paddingHorizontal: 12,
160
+ justifyContent: 'center',
161
+ alignItems: 'center',
162
+ borderWidth: 1
163
+ // Colors applied via theme
164
+ },
165
+ previousButton: {
166
+ borderTopLeftRadius: 6,
167
+ borderBottomLeftRadius: 6,
168
+ borderRightWidth: 0
169
+ },
170
+ nextButton: {
171
+ borderTopRightRadius: 6,
172
+ borderBottomRightRadius: 6,
173
+ borderLeftWidth: 0
174
+ },
175
+ pageButton: {
176
+ borderLeftWidth: 0,
177
+ borderRightWidth: 0
178
+ },
179
+ pageButtonActive: {
180
+ backgroundColor: '#3B3269',
181
+ borderColor: '#3B3269'
182
+ },
183
+ buttonDisabled: {
184
+ opacity: 0.5
185
+ },
186
+ buttonText: {
187
+ fontSize: 18,
188
+ fontWeight: '500'
189
+ // Color applied via theme
190
+ },
191
+ pageButtonText: {
192
+ fontSize: 14,
193
+ fontWeight: '500'
194
+ // Color applied via theme
195
+ },
196
+ pageButtonTextActive: {
197
+ fontWeight: '600'
198
+ // Color applied via theme
199
+ },
200
+ ellipsis: {
201
+ minWidth: 40,
202
+ height: 40,
203
+ paddingHorizontal: 12,
204
+ justifyContent: 'center',
205
+ alignItems: 'center',
206
+ borderWidth: 1,
207
+ borderLeftWidth: 0,
208
+ borderRightWidth: 0
209
+ // Colors applied via theme
210
+ },
211
+ ellipsisText: {
212
+ fontSize: 14,
213
+ fontWeight: '500'
214
+ // Color applied via theme
215
+ }
216
+ });
217
+ var _default = exports.default = Pagination;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.lightTheme = exports.fullyCustomTheme = exports.darkTheme = exports.customBrandTheme = void 0;
7
+ var _theme = require("./theme");
8
+ /**
9
+ * Theme Configuration Examples
10
+ *
11
+ * This file shows how to customize the Media Gallery theme for React Native
12
+ */
13
+
14
+ // Example 1: Light Mode (Default)
15
+ var lightTheme = exports.lightTheme = (0, _theme.createTheme)({
16
+ mode: 'light'
17
+ });
18
+
19
+ // Example 2: Dark Mode
20
+ var darkTheme = exports.darkTheme = (0, _theme.createTheme)({
21
+ mode: 'dark'
22
+ });
23
+
24
+ // Example 3: Custom Brand Colors
25
+ var customBrandTheme = exports.customBrandTheme = (0, _theme.createTheme)({
26
+ mode: 'light',
27
+ colors: {
28
+ primary: '#FF6B6B',
29
+ // Custom red primary
30
+ tabActive: '#FF6B6B',
31
+ tabIndicator: '#FF6B6B',
32
+ uploadBorder: '#FF6B6B',
33
+ uploadIconBackground: '#FF6B6B',
34
+ paginationButtonActive: '#FF6B6B'
35
+ },
36
+ bottomSheetHeight: 0.85 // 85% of screen height
37
+ });
38
+
39
+ // Example 4: Full Customization
40
+ var fullyCustomTheme = exports.fullyCustomTheme = (0, _theme.createTheme)({
41
+ mode: 'dark',
42
+ colors: {
43
+ // Primary colors
44
+ primary: '#6366F1',
45
+ primaryLight: '#818CF8',
46
+ primaryDark: '#4F46E5',
47
+ // Backgrounds
48
+ background: '#0F172A',
49
+ backgroundSecondary: '#1E293B',
50
+ backgroundTertiary: '#334155',
51
+ // Text
52
+ text: '#F1F5F9',
53
+ textSecondary: '#CBD5E1',
54
+ textTertiary: '#94A3B8',
55
+ // Tabs
56
+ tabActive: '#6366F1',
57
+ tabInactive: '#94A3B8',
58
+ tabIndicator: '#6366F1',
59
+ tabBackground: '#0F172A',
60
+ // Borders
61
+ border: '#334155',
62
+ borderLight: '#1E293B',
63
+ borderDark: '#475569',
64
+ // Overlay
65
+ overlay: 'rgba(0, 0, 0, 0.8)',
66
+ // Pagination
67
+ paginationBackground: '#1E293B',
68
+ paginationButton: '#0F172A',
69
+ paginationButtonActive: '#6366F1',
70
+ paginationText: '#CBD5E1',
71
+ paginationTextActive: '#FFFFFF',
72
+ paginationBorder: '#334155',
73
+ // Upload
74
+ uploadBorder: '#6366F1',
75
+ uploadBackground: '#0F172A',
76
+ uploadIconBackground: '#6366F1',
77
+ uploadText: '#F1F5F9',
78
+ // Items
79
+ itemBackground: '#1E293B',
80
+ itemShadow: '#000000',
81
+ // Loading
82
+ loadingBackground: '#1E293B',
83
+ loadingText: '#94A3B8'
84
+ },
85
+ spacing: {
86
+ xs: 4,
87
+ sm: 8,
88
+ md: 12,
89
+ lg: 16,
90
+ xl: 20,
91
+ xxl: 24
92
+ },
93
+ radius: {
94
+ sm: 6,
95
+ md: 8,
96
+ lg: 12,
97
+ xl: 16,
98
+ xxl: 20
99
+ },
100
+ bottomSheetHeight: 0.92 // 92% of screen height
101
+ });
102
+
103
+ // Usage in your component:
104
+ /*
105
+ import { MediaPopup, MediaApiService } from '@tradly/asset'
106
+ import { darkTheme } from './theme'
107
+
108
+ <MediaPopup
109
+ isOpen={isOpen}
110
+ onClose={() => setIsOpen(false)}
111
+ onSelect={handleSelect}
112
+ apiService={apiService}
113
+ picker={picker}
114
+ theme={darkTheme} // Pass your custom theme
115
+ bottomSheetHeight={0.9} // Or override height directly
116
+ />
117
+ */
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactNative = require("react-native");
10
+ var _FileUpload = _interopRequireDefault(require("./FileUpload.native"));
11
+ var _ImagesSkeleton = _interopRequireDefault(require("./ImagesSkeleton.native"));
12
+ var _Pagination = _interopRequireDefault(require("./Pagination.native"));
13
+ var _theme = require("./theme");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
17
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
18
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
20
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
21
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
22
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
23
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
24
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
25
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
26
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
27
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
28
+ 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; }
29
+ 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; } }
30
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } // Note: You'll need to install react-native-video for video playback
31
+ // import Video from 'react-native-video'
32
+ var _Dimensions$get = _reactNative.Dimensions.get('window'),
33
+ SCREEN_WIDTH = _Dimensions$get.width;
34
+ var NUM_COLUMNS = 3;
35
+ var ITEM_MARGIN = 8;
36
+ var ITEM_SIZE = (SCREEN_WIDTH - 40 - ITEM_MARGIN * (NUM_COLUMNS - 1) * 2) / NUM_COLUMNS;
37
+ var VIDEO_MIME_TYPES = ['video/mp4', 'video/quicktime', 'video/x-ms-wmv', 'video/h265', 'video/hevc', 'video/webm'];
38
+ var VideosGallery = function VideosGallery(_ref) {
39
+ var update_data = _ref.update_data,
40
+ closePopup = _ref.closePopup,
41
+ apiService = _ref.apiService,
42
+ onError = _ref.onError,
43
+ picker = _ref.picker,
44
+ pickerOptions = _ref.pickerOptions,
45
+ _ref$theme = _ref.theme,
46
+ theme = _ref$theme === void 0 ? _theme.defaultTheme : _ref$theme,
47
+ containerStyle = _ref.containerStyle,
48
+ gridStyle = _ref.gridStyle,
49
+ videoItemStyle = _ref.videoItemStyle,
50
+ paginationContainerStyle = _ref.paginationContainerStyle;
51
+ var _useState = (0, _react.useState)([]),
52
+ _useState2 = _slicedToArray(_useState, 2),
53
+ videos = _useState2[0],
54
+ setVideos = _useState2[1];
55
+ var _useState3 = (0, _react.useState)(0),
56
+ _useState4 = _slicedToArray(_useState3, 2),
57
+ total_count = _useState4[0],
58
+ setTotalCount = _useState4[1];
59
+ var _useState5 = (0, _react.useState)(1),
60
+ _useState6 = _slicedToArray(_useState5, 2),
61
+ currentPage = _useState6[0],
62
+ setCurrentPage = _useState6[1];
63
+ var _useState7 = (0, _react.useState)(false),
64
+ _useState8 = _slicedToArray(_useState7, 2),
65
+ isLoading = _useState8[0],
66
+ setISLoading = _useState8[1];
67
+
68
+ // Fetch videos
69
+ (0, _react.useEffect)(function () {
70
+ loadMedia();
71
+ }, []);
72
+ var loadMedia = /*#__PURE__*/function () {
73
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
74
+ var page_number,
75
+ _response$data,
76
+ _response$data2,
77
+ response,
78
+ mediaData,
79
+ count,
80
+ _args = arguments,
81
+ _t;
82
+ return _regenerator().w(function (_context) {
83
+ while (1) switch (_context.p = _context.n) {
84
+ case 0:
85
+ page_number = _args.length > 0 && _args[0] !== undefined ? _args[0] : 1;
86
+ _context.p = 1;
87
+ _context.n = 2;
88
+ return apiService.fetchMedia({
89
+ mimeTypes: VIDEO_MIME_TYPES,
90
+ page: page_number,
91
+ setISLoading: setISLoading,
92
+ isLoading: isLoading
93
+ });
94
+ case 2:
95
+ response = _context.v;
96
+ // Handle different response formats
97
+ mediaData = (response === null || response === void 0 ? void 0 : response.media) || (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.media) || (response === null || response === void 0 ? void 0 : response.data) || response || [];
98
+ count = (response === null || response === void 0 ? void 0 : response.count) || (response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.count) || (response === null || response === void 0 ? void 0 : response.total) || 0;
99
+ setVideos(Array.isArray(mediaData) ? mediaData : []);
100
+ setTotalCount(count);
101
+ setCurrentPage(page_number);
102
+ _context.n = 4;
103
+ break;
104
+ case 3:
105
+ _context.p = 3;
106
+ _t = _context.v;
107
+ console.error('Error loading videos:', _t);
108
+ if (onError) {
109
+ onError(_t);
110
+ }
111
+ case 4:
112
+ return _context.a(2);
113
+ }
114
+ }, _callee, null, [[1, 3]]);
115
+ }));
116
+ return function loadMedia() {
117
+ return _ref2.apply(this, arguments);
118
+ };
119
+ }();
120
+ var handleVideoClick = function handleVideoClick(video) {
121
+ if (update_data) {
122
+ update_data(video.url || video);
123
+ }
124
+ if (closePopup) {
125
+ closePopup();
126
+ }
127
+ };
128
+ var renderItem = function renderItem(_ref3) {
129
+ var item = _ref3.item,
130
+ index = _ref3.index;
131
+ // First item is the upload button
132
+ if (index === 0) {
133
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
134
+ style: [styles.uploadContainer, {
135
+ width: ITEM_SIZE,
136
+ height: ITEM_SIZE
137
+ }],
138
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FileUpload.default, {
139
+ loadMedia: loadMedia,
140
+ accept: "video/*",
141
+ title: "Add Video",
142
+ apiService: apiService,
143
+ onUploadError: onError,
144
+ picker: picker,
145
+ pickerOptions: pickerOptions,
146
+ theme: theme
147
+ })
148
+ });
149
+ }
150
+ var video = videos[index - 1];
151
+ var videoUrl = typeof video === 'string' ? video : video.url;
152
+ var videoKey = video.id || video.url || index;
153
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
154
+ onPress: function onPress() {
155
+ return handleVideoClick(video);
156
+ },
157
+ style: [styles.videoItem, {
158
+ width: ITEM_SIZE,
159
+ height: ITEM_SIZE
160
+ }, videoItemStyle],
161
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
162
+ style: styles.videoPlaceholder,
163
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
164
+ style: styles.playIcon,
165
+ children: "\u25B6"
166
+ })
167
+ })
168
+ });
169
+ };
170
+ var data = isLoading ? [] : [{
171
+ type: 'upload'
172
+ }].concat(_toConsumableArray(videos));
173
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
174
+ style: [styles.container, containerStyle],
175
+ children: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImagesSkeleton.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.FlatList, {
176
+ data: data,
177
+ renderItem: renderItem,
178
+ keyExtractor: function keyExtractor(item, index) {
179
+ if (index === 0) return 'upload';
180
+ var video = videos[index - 1];
181
+ return video.id || video.url || "video-".concat(index);
182
+ },
183
+ numColumns: NUM_COLUMNS,
184
+ contentContainerStyle: [styles.grid, gridStyle],
185
+ showsVerticalScrollIndicator: false,
186
+ ListFooterComponent: total_count > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
187
+ style: [styles.paginationContainer, {
188
+ backgroundColor: theme.colors.paginationBackground,
189
+ paddingVertical: theme.spacing.lg,
190
+ paddingHorizontal: theme.spacing.sm,
191
+ marginTop: theme.spacing.sm
192
+ }, paginationContainerStyle],
193
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pagination.default, {
194
+ nextPage: function nextPage(value) {
195
+ return loadMedia(value);
196
+ },
197
+ pageCount: Math.ceil(total_count / 30),
198
+ current_page: currentPage,
199
+ theme: theme
200
+ })
201
+ }) : null
202
+ })
203
+ });
204
+ };
205
+ var styles = _reactNative.StyleSheet.create({
206
+ container: {
207
+ flex: 1
208
+ },
209
+ grid: {
210
+ padding: 4
211
+ },
212
+ uploadContainer: {
213
+ margin: ITEM_MARGIN
214
+ },
215
+ videoItem: {
216
+ margin: ITEM_MARGIN,
217
+ borderRadius: 8,
218
+ overflow: 'hidden',
219
+ backgroundColor: '#000000',
220
+ shadowColor: '#000',
221
+ shadowOffset: {
222
+ width: 0,
223
+ height: 2
224
+ },
225
+ shadowOpacity: 0.1,
226
+ shadowRadius: 3.84,
227
+ elevation: 5
228
+ },
229
+ videoPlaceholder: {
230
+ width: '100%',
231
+ height: '100%',
232
+ backgroundColor: '#1a1a1a',
233
+ justifyContent: 'center',
234
+ alignItems: 'center'
235
+ },
236
+ playIcon: {
237
+ fontSize: 32,
238
+ color: '#FFFFFF'
239
+ },
240
+ video: {
241
+ width: '100%',
242
+ height: '100%'
243
+ },
244
+ paginationContainer: {
245
+ // Styles applied via theme
246
+ }
247
+ });
248
+ var _default = exports.default = VideosGallery;