@tradly/asset 1.0.14 → 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.
- package/README.md +172 -15
- package/dist/esm/index.js +3 -0
- package/dist/esm/native/FileUpload.native.js +35 -23
- package/dist/esm/native/MediaGallery.native.js +17 -10
- package/dist/esm/native/MediaPopup.native.js +40 -21
- package/dist/esm/native/MediaTab.native.js +37 -20
- package/dist/esm/native/Pagination.native.js +43 -19
- package/dist/esm/native/THEME_EXAMPLE.js +112 -0
- package/dist/esm/native/VideosGallery.native.js +14 -7
- package/dist/esm/native/theme.js +167 -0
- package/dist/index.js +14 -0
- package/dist/native/FileUpload.native.js +35 -23
- package/dist/native/MediaGallery.native.js +17 -10
- package/dist/native/MediaPopup.native.js +40 -21
- package/dist/native/MediaTab.native.js +36 -19
- package/dist/native/Pagination.native.js +43 -19
- package/dist/native/THEME_EXAMPLE.js +117 -0
- package/dist/native/VideosGallery.native.js +14 -7
- package/dist/native/theme.js +173 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -236,11 +236,130 @@ You can customize picker options based on the accept type:
|
|
|
236
236
|
### React Native UI Differences
|
|
237
237
|
|
|
238
238
|
- **Bottom Sheet**: Media gallery opens as a bottom sheet (slides up from
|
|
239
|
-
bottom)
|
|
239
|
+
bottom) - defaults to 90% of screen height, customizable
|
|
240
240
|
- **Native Styling**: Uses React Native `StyleSheet` instead of Tailwind CSS
|
|
241
241
|
- **Components**: Uses React Native primitives (`View`, `Text`,
|
|
242
242
|
`TouchableOpacity`, `FlatList`, `Image`)
|
|
243
243
|
- **File Upload**: Requires `picker` prop to be provided
|
|
244
|
+
- **Theme System**: Full theme support for easy dark/light mode customization
|
|
245
|
+
|
|
246
|
+
### React Native Theme & Customization
|
|
247
|
+
|
|
248
|
+
The package includes a comprehensive theme system that makes it easy to
|
|
249
|
+
customize colors, spacing, and styling for dark/light mode.
|
|
250
|
+
|
|
251
|
+
#### Basic Theme Usage
|
|
252
|
+
|
|
253
|
+
```jsx
|
|
254
|
+
import { MediaPopup, MediaApiService } from "@tradly/asset";
|
|
255
|
+
import { createTheme } from "@tradly/asset/native/theme";
|
|
256
|
+
|
|
257
|
+
// Use dark mode
|
|
258
|
+
const darkTheme = createTheme({ mode: "dark" });
|
|
259
|
+
|
|
260
|
+
// Use light mode (default)
|
|
261
|
+
const lightTheme = createTheme({ mode: "light" });
|
|
262
|
+
|
|
263
|
+
<MediaPopup
|
|
264
|
+
apiService={apiService}
|
|
265
|
+
picker={picker}
|
|
266
|
+
theme={darkTheme} // Pass your theme
|
|
267
|
+
bottomSheetHeight={0.9} // 90% of screen (default), customize as needed
|
|
268
|
+
/>;
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
#### Custom Theme Colors
|
|
272
|
+
|
|
273
|
+
```jsx
|
|
274
|
+
import { createTheme } from "@tradly/asset/native/theme";
|
|
275
|
+
|
|
276
|
+
const customTheme = createTheme({
|
|
277
|
+
mode: "dark", // or "light"
|
|
278
|
+
colors: {
|
|
279
|
+
// Primary colors
|
|
280
|
+
primary: "#6366F1",
|
|
281
|
+
tabActive: "#6366F1",
|
|
282
|
+
tabIndicator: "#6366F1",
|
|
283
|
+
|
|
284
|
+
// Backgrounds
|
|
285
|
+
background: "#0F172A",
|
|
286
|
+
backgroundSecondary: "#1E293B",
|
|
287
|
+
|
|
288
|
+
// Text
|
|
289
|
+
text: "#F1F5F9",
|
|
290
|
+
textSecondary: "#CBD5E1",
|
|
291
|
+
|
|
292
|
+
// Tabs
|
|
293
|
+
tabActive: "#6366F1",
|
|
294
|
+
tabInactive: "#94A3B8",
|
|
295
|
+
tabBackground: "#0F172A",
|
|
296
|
+
|
|
297
|
+
// Borders
|
|
298
|
+
border: "#334155",
|
|
299
|
+
|
|
300
|
+
// Pagination
|
|
301
|
+
paginationButtonActive: "#6366F1",
|
|
302
|
+
paginationTextActive: "#FFFFFF",
|
|
303
|
+
|
|
304
|
+
// Upload button
|
|
305
|
+
uploadBorder: "#6366F1",
|
|
306
|
+
uploadIconBackground: "#6366F1",
|
|
307
|
+
|
|
308
|
+
// And many more...
|
|
309
|
+
},
|
|
310
|
+
bottomSheetHeight: 0.92, // 92% of screen height
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
<MediaPopup theme={customTheme} ... />
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
#### Available Theme Colors
|
|
317
|
+
|
|
318
|
+
All colors are customizable via the theme object:
|
|
319
|
+
|
|
320
|
+
- **Primary**: `primary`, `primaryLight`, `primaryDark`
|
|
321
|
+
- **Backgrounds**: `background`, `backgroundSecondary`, `backgroundTertiary`
|
|
322
|
+
- **Text**: `text`, `textSecondary`, `textTertiary`, `textInverse`
|
|
323
|
+
- **Borders**: `border`, `borderLight`, `borderDark`
|
|
324
|
+
- **Tabs**: `tabActive`, `tabInactive`, `tabIndicator`, `tabBackground`
|
|
325
|
+
- **Pagination**: `paginationBackground`, `paginationButton`,
|
|
326
|
+
`paginationButtonActive`, `paginationText`, `paginationTextActive`,
|
|
327
|
+
`paginationBorder`
|
|
328
|
+
- **Upload**: `uploadBorder`, `uploadBackground`, `uploadIconBackground`,
|
|
329
|
+
`uploadText`
|
|
330
|
+
- **Items**: `itemBackground`, `itemShadow`
|
|
331
|
+
- **Loading**: `loadingBackground`, `loadingText`
|
|
332
|
+
- **Overlay**: `overlay`
|
|
333
|
+
|
|
334
|
+
#### Customizing Bottom Sheet Height
|
|
335
|
+
|
|
336
|
+
```jsx
|
|
337
|
+
<MediaPopup
|
|
338
|
+
bottomSheetHeight={0.85} // 85% of screen height
|
|
339
|
+
// or via theme:
|
|
340
|
+
theme={createTheme({ bottomSheetHeight: 0.92 })}
|
|
341
|
+
/>
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
#### Individual Component Styling
|
|
345
|
+
|
|
346
|
+
You can also override individual component styles:
|
|
347
|
+
|
|
348
|
+
```jsx
|
|
349
|
+
<MediaPopup
|
|
350
|
+
theme={darkTheme}
|
|
351
|
+
// Override specific styles
|
|
352
|
+
containerStyle={{ padding: 24 }}
|
|
353
|
+
headerStyle={{ paddingBottom: 16 }}
|
|
354
|
+
titleStyle={{ fontSize: 28 }}
|
|
355
|
+
closeButtonStyle={{ padding: 12 }}
|
|
356
|
+
tabListStyle={{ paddingHorizontal: 8 }}
|
|
357
|
+
tabButtonStyle={{ paddingVertical: 16 }}
|
|
358
|
+
tabButtonActiveStyle={{ backgroundColor: "#F0F0F0" }}
|
|
359
|
+
tabButtonTextActiveStyle={{ fontWeight: "700" }}
|
|
360
|
+
// ... and many more style props
|
|
361
|
+
/>
|
|
362
|
+
```
|
|
244
363
|
|
|
245
364
|
## Advanced Usage
|
|
246
365
|
|
|
@@ -341,18 +460,20 @@ apiService.setBearerToken("new-bearer-token");
|
|
|
341
460
|
|
|
342
461
|
### MediaPopup Props
|
|
343
462
|
|
|
344
|
-
| Prop
|
|
345
|
-
|
|
|
346
|
-
| `isOpen`
|
|
347
|
-
| `onClose`
|
|
348
|
-
| `onSelect`
|
|
349
|
-
| `currentData`
|
|
350
|
-
| `options`
|
|
351
|
-
| `apiService`
|
|
352
|
-
| `onError`
|
|
353
|
-
| `title`
|
|
354
|
-
| `picker`
|
|
355
|
-
| `pickerOptions`
|
|
463
|
+
| Prop | Type | Default | Description | Platform |
|
|
464
|
+
| ------------------- | ----------------- | ----------------- | --------------------------------------------------- | ------------ |
|
|
465
|
+
| `isOpen` | `boolean` | `false` | Controls popup visibility | Web & Native |
|
|
466
|
+
| `onClose` | `function` | - | Callback when popup closes | Web & Native |
|
|
467
|
+
| `onSelect` | `function` | - | Callback when media is selected | Web & Native |
|
|
468
|
+
| `currentData` | `any` | - | Currently selected media data | Web & Native |
|
|
469
|
+
| `options` | `array` | `['image']` | Media types to show: `'image'`, `'video'`, `'file'` | Web & Native |
|
|
470
|
+
| `apiService` | `MediaApiService` | - | **Required**: API service instance | Web & Native |
|
|
471
|
+
| `onError` | `function` | - | Error handler callback | Web & Native |
|
|
472
|
+
| `title` | `string` | `'Media Gallery'` | Popup title | Web & Native |
|
|
473
|
+
| `picker` | `function` | - | **Required for React Native**: File picker function | Native only |
|
|
474
|
+
| `pickerOptions` | `function` | - | Optional: Function to generate picker options | Native only |
|
|
475
|
+
| `theme` | `object` | - | Theme object for colors/spacing (see Theme docs) | Native only |
|
|
476
|
+
| `bottomSheetHeight` | `number` | `0.9` | Bottom sheet height (0.85 = 85%, 0.9 = 90%, etc.) | Native only |
|
|
356
477
|
|
|
357
478
|
**React Native Required Props:**
|
|
358
479
|
|
|
@@ -430,19 +551,55 @@ using style props:
|
|
|
430
551
|
|
|
431
552
|
**Available Style Props (React Native):**
|
|
432
553
|
|
|
554
|
+
**MediaPopup:**
|
|
555
|
+
|
|
556
|
+
- `overlayStyle` - Overlay/backdrop
|
|
433
557
|
- `containerStyle` - Main popup container
|
|
434
558
|
- `headerStyle` - Header container
|
|
435
559
|
- `titleStyle` - Title text
|
|
436
560
|
- `closeButtonStyle` - Close button
|
|
561
|
+
- `closeButtonTextStyle` - Close button text/icon
|
|
562
|
+
|
|
563
|
+
**MediaTab:**
|
|
564
|
+
|
|
565
|
+
- `containerStyle` - Tab container
|
|
437
566
|
- `tabListStyle` - Tab list
|
|
438
567
|
- `tabButtonStyle` - Base tab button
|
|
439
568
|
- `tabButtonActiveStyle` - Active tab button
|
|
440
569
|
- `tabButtonInactiveStyle` - Inactive tab button
|
|
570
|
+
- `tabButtonTextStyle` - Base tab text
|
|
571
|
+
- `tabButtonTextActiveStyle` - Active tab text
|
|
572
|
+
- `tabButtonTextInactiveStyle` - Inactive tab text
|
|
573
|
+
- `tabIndicatorStyle` - Tab indicator line
|
|
574
|
+
- `tabPanelStyle` - Tab panel container
|
|
575
|
+
|
|
576
|
+
**ImagesGallery/VideosGallery:**
|
|
577
|
+
|
|
578
|
+
- `containerStyle` - Gallery container
|
|
441
579
|
- `gridStyle` - Media grid layout
|
|
442
|
-
- `imageItemStyle` -
|
|
443
|
-
- `videoItemStyle` - Video item styles
|
|
580
|
+
- `imageItemStyle` / `videoItemStyle` - Media item styles
|
|
444
581
|
- `paginationContainerStyle` - Pagination container
|
|
445
582
|
|
|
583
|
+
**FileUpload:**
|
|
584
|
+
|
|
585
|
+
- `containerStyle` - Upload container
|
|
586
|
+
- `buttonStyle` - Upload button
|
|
587
|
+
- `iconContainerStyle` - Icon container
|
|
588
|
+
- `titleStyle` - Upload title text
|
|
589
|
+
- `loadingStyle` - Loading state container
|
|
590
|
+
|
|
591
|
+
**Pagination:**
|
|
592
|
+
|
|
593
|
+
- `containerStyle` - Pagination container
|
|
594
|
+
- `navStyle` - Navigation container
|
|
595
|
+
- `previousButtonStyle` - Previous button
|
|
596
|
+
- `nextButtonStyle` - Next button
|
|
597
|
+
- `pageButtonStyle` - Page number button
|
|
598
|
+
- `pageButtonActiveStyle` - Active page button
|
|
599
|
+
- `pageButtonTextStyle` - Page button text
|
|
600
|
+
- `pageButtonTextActiveStyle` - Active page text
|
|
601
|
+
- `ellipsisStyle` - Ellipsis container
|
|
602
|
+
|
|
446
603
|
### Full Styling Guide
|
|
447
604
|
|
|
448
605
|
For detailed styling documentation with examples, see
|
package/dist/esm/index.js
CHANGED
|
@@ -21,6 +21,9 @@ export { MediaTab, ImagesGallery, VideosGallery, FileUpload };
|
|
|
21
21
|
// Export API service
|
|
22
22
|
export { MediaApiService };
|
|
23
23
|
|
|
24
|
+
// Export React Native theme utilities
|
|
25
|
+
export { createTheme, defaultTheme } from "./native/theme";
|
|
26
|
+
|
|
24
27
|
// Export default as MediaPopup for convenience
|
|
25
28
|
export default MediaPopup;
|
|
26
29
|
|
|
@@ -11,6 +11,7 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
|
11
11
|
import React, { useState } from "react";
|
|
12
12
|
import { View, Text, TouchableOpacity, StyleSheet, Alert, ActivityIndicator } from "react-native";
|
|
13
13
|
import { CameraIcon } from "./Icons.native";
|
|
14
|
+
import { defaultTheme } from "./theme";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* FileUpload component for React Native
|
|
@@ -78,6 +79,8 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
78
79
|
onUploadError = _ref.onUploadError,
|
|
79
80
|
picker = _ref.picker,
|
|
80
81
|
pickerOptions = _ref.pickerOptions,
|
|
82
|
+
_ref$theme = _ref.theme,
|
|
83
|
+
theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
|
|
81
84
|
containerStyle = _ref.containerStyle,
|
|
82
85
|
buttonStyle = _ref.buttonStyle,
|
|
83
86
|
iconContainerStyle = _ref.iconContainerStyle,
|
|
@@ -227,12 +230,18 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
227
230
|
}();
|
|
228
231
|
if (isLoading) {
|
|
229
232
|
return /*#__PURE__*/_jsxs(View, {
|
|
230
|
-
style: [styles.loadingContainer,
|
|
233
|
+
style: [styles.loadingContainer, {
|
|
234
|
+
backgroundColor: theme.colors.loadingBackground,
|
|
235
|
+
borderRadius: theme.radius.md
|
|
236
|
+
}, loadingStyle],
|
|
231
237
|
children: [/*#__PURE__*/_jsx(ActivityIndicator, {
|
|
232
238
|
size: "small",
|
|
233
|
-
color:
|
|
239
|
+
color: theme.colors.primary
|
|
234
240
|
}), /*#__PURE__*/_jsx(Text, {
|
|
235
|
-
style: styles.loadingText,
|
|
241
|
+
style: [styles.loadingText, {
|
|
242
|
+
color: theme.colors.loadingText,
|
|
243
|
+
marginTop: theme.spacing.sm
|
|
244
|
+
}],
|
|
236
245
|
children: "Uploading..."
|
|
237
246
|
})]
|
|
238
247
|
});
|
|
@@ -241,13 +250,26 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
241
250
|
style: [styles.container, containerStyle],
|
|
242
251
|
children: /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
243
252
|
onPress: handlePickFile,
|
|
244
|
-
style: [styles.button,
|
|
253
|
+
style: [styles.button, {
|
|
254
|
+
borderColor: theme.colors.uploadBorder,
|
|
255
|
+
backgroundColor: theme.colors.uploadBackground,
|
|
256
|
+
borderRadius: theme.radius.md
|
|
257
|
+
}, buttonStyle],
|
|
245
258
|
disabled: isLoading,
|
|
246
259
|
children: [/*#__PURE__*/_jsx(View, {
|
|
247
|
-
style: [styles.iconContainer,
|
|
260
|
+
style: [styles.iconContainer, {
|
|
261
|
+
backgroundColor: theme.colors.uploadIconBackground,
|
|
262
|
+
borderRadius: theme.radius.xl,
|
|
263
|
+
marginBottom: theme.spacing.sm,
|
|
264
|
+
padding: theme.spacing.md
|
|
265
|
+
}, iconContainerStyle],
|
|
248
266
|
children: /*#__PURE__*/_jsx(CameraIcon, {})
|
|
249
267
|
}), /*#__PURE__*/_jsx(Text, {
|
|
250
|
-
style: [styles.title,
|
|
268
|
+
style: [styles.title, {
|
|
269
|
+
color: theme.colors.uploadText,
|
|
270
|
+
marginTop: theme.spacing.sm,
|
|
271
|
+
fontSize: theme.typography.caption.fontSize
|
|
272
|
+
}, titleStyle],
|
|
251
273
|
children: title
|
|
252
274
|
})]
|
|
253
275
|
})
|
|
@@ -265,34 +287,24 @@ var styles = StyleSheet.create({
|
|
|
265
287
|
justifyContent: "center",
|
|
266
288
|
alignItems: "center",
|
|
267
289
|
borderWidth: 1,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
borderRadius: 8,
|
|
271
|
-
backgroundColor: "#FFFFFF"
|
|
290
|
+
borderStyle: "dashed"
|
|
291
|
+
// Colors applied via theme
|
|
272
292
|
},
|
|
273
293
|
iconContainer: {
|
|
274
|
-
|
|
275
|
-
backgroundColor: "#3B3269",
|
|
276
|
-
borderRadius: 20,
|
|
277
|
-
marginBottom: 8
|
|
294
|
+
// Colors and spacing applied via theme
|
|
278
295
|
},
|
|
279
296
|
title: {
|
|
280
|
-
|
|
281
|
-
color: "#000000",
|
|
282
|
-
marginTop: 8
|
|
297
|
+
// Colors and typography applied via theme
|
|
283
298
|
},
|
|
284
299
|
loadingContainer: {
|
|
285
300
|
width: "100%",
|
|
286
301
|
height: 160,
|
|
287
302
|
justifyContent: "center",
|
|
288
|
-
alignItems: "center"
|
|
289
|
-
|
|
290
|
-
borderRadius: 8
|
|
303
|
+
alignItems: "center"
|
|
304
|
+
// Colors applied via theme
|
|
291
305
|
},
|
|
292
306
|
loadingText: {
|
|
293
|
-
|
|
294
|
-
fontSize: 14,
|
|
295
|
-
color: "#666666"
|
|
307
|
+
// Colors applied via theme
|
|
296
308
|
}
|
|
297
309
|
});
|
|
298
310
|
export default FileUpload;
|
|
@@ -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 { defaultTheme } from './theme';
|
|
20
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
22
|
var _Dimensions$get = Dimensions.get('window'),
|
|
22
23
|
SCREEN_WIDTH = _Dimensions$get.width;
|
|
@@ -32,6 +33,8 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
32
33
|
onError = _ref.onError,
|
|
33
34
|
picker = _ref.picker,
|
|
34
35
|
pickerOptions = _ref.pickerOptions,
|
|
36
|
+
_ref$theme = _ref.theme,
|
|
37
|
+
theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
|
|
35
38
|
containerStyle = _ref.containerStyle,
|
|
36
39
|
gridStyle = _ref.gridStyle,
|
|
37
40
|
imageItemStyle = _ref.imageItemStyle,
|
|
@@ -130,7 +133,8 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
130
133
|
apiService: apiService,
|
|
131
134
|
onUploadError: onError,
|
|
132
135
|
picker: picker,
|
|
133
|
-
pickerOptions: pickerOptions
|
|
136
|
+
pickerOptions: pickerOptions,
|
|
137
|
+
theme: theme
|
|
134
138
|
})
|
|
135
139
|
});
|
|
136
140
|
}
|
|
@@ -143,7 +147,9 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
143
147
|
},
|
|
144
148
|
style: [styles.imageItem, {
|
|
145
149
|
width: ITEM_SIZE,
|
|
146
|
-
height: ITEM_SIZE
|
|
150
|
+
height: ITEM_SIZE,
|
|
151
|
+
backgroundColor: theme.colors.itemBackground,
|
|
152
|
+
shadowColor: theme.colors.itemShadow
|
|
147
153
|
}, imageItemStyle],
|
|
148
154
|
children: /*#__PURE__*/_jsx(Image, {
|
|
149
155
|
source: {
|
|
@@ -171,13 +177,19 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
171
177
|
contentContainerStyle: [styles.grid, gridStyle],
|
|
172
178
|
showsVerticalScrollIndicator: false,
|
|
173
179
|
ListFooterComponent: total_count > 0 ? /*#__PURE__*/_jsx(View, {
|
|
174
|
-
style: [styles.paginationContainer,
|
|
180
|
+
style: [styles.paginationContainer, {
|
|
181
|
+
backgroundColor: theme.colors.paginationBackground,
|
|
182
|
+
paddingVertical: theme.spacing.lg,
|
|
183
|
+
paddingHorizontal: theme.spacing.sm,
|
|
184
|
+
marginTop: theme.spacing.sm
|
|
185
|
+
}, paginationContainerStyle],
|
|
175
186
|
children: /*#__PURE__*/_jsx(Pagination, {
|
|
176
187
|
nextPage: function nextPage(value) {
|
|
177
188
|
return loadMedia(value);
|
|
178
189
|
},
|
|
179
190
|
pageCount: Math.ceil(total_count / 30),
|
|
180
|
-
current_page: currentPage
|
|
191
|
+
current_page: currentPage,
|
|
192
|
+
theme: theme
|
|
181
193
|
})
|
|
182
194
|
}) : null
|
|
183
195
|
})
|
|
@@ -197,8 +209,6 @@ var styles = StyleSheet.create({
|
|
|
197
209
|
margin: ITEM_MARGIN,
|
|
198
210
|
borderRadius: 8,
|
|
199
211
|
overflow: 'hidden',
|
|
200
|
-
backgroundColor: '#FFFFFF',
|
|
201
|
-
shadowColor: '#000',
|
|
202
212
|
shadowOffset: {
|
|
203
213
|
width: 0,
|
|
204
214
|
height: 2
|
|
@@ -212,10 +222,7 @@ var styles = StyleSheet.create({
|
|
|
212
222
|
height: '100%'
|
|
213
223
|
},
|
|
214
224
|
paginationContainer: {
|
|
215
|
-
|
|
216
|
-
paddingHorizontal: 8,
|
|
217
|
-
backgroundColor: '#F5F5F5',
|
|
218
|
-
marginTop: 8
|
|
225
|
+
// Styles applied via theme
|
|
219
226
|
}
|
|
220
227
|
});
|
|
221
228
|
export default ImagesGallery;
|
|
@@ -8,6 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import { Modal, View, Text, TouchableOpacity, StyleSheet, Dimensions, Animated, TouchableWithoutFeedback } from 'react-native';
|
|
9
9
|
import MediaTab from './MediaTab.native';
|
|
10
10
|
import { CloseIcon } from './Icons.native';
|
|
11
|
+
import { createTheme } from './theme';
|
|
11
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
13
|
var _Dimensions$get = Dimensions.get('window'),
|
|
13
14
|
SCREEN_HEIGHT = _Dimensions$get.height;
|
|
@@ -24,10 +25,18 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
24
25
|
title = _ref$title === void 0 ? 'Media Gallery' : _ref$title,
|
|
25
26
|
picker = _ref.picker,
|
|
26
27
|
pickerOptions = _ref.pickerOptions,
|
|
28
|
+
theme = _ref.theme,
|
|
29
|
+
overlayStyle = _ref.overlayStyle,
|
|
27
30
|
containerStyle = _ref.containerStyle,
|
|
28
31
|
headerStyle = _ref.headerStyle,
|
|
29
32
|
titleStyle = _ref.titleStyle,
|
|
30
|
-
closeButtonStyle = _ref.closeButtonStyle
|
|
33
|
+
closeButtonStyle = _ref.closeButtonStyle,
|
|
34
|
+
closeButtonTextStyle = _ref.closeButtonTextStyle,
|
|
35
|
+
bottomSheetHeight = _ref.bottomSheetHeight;
|
|
36
|
+
var currentTheme = React.useMemo(function () {
|
|
37
|
+
return createTheme(theme);
|
|
38
|
+
}, [theme]);
|
|
39
|
+
var sheetHeight = bottomSheetHeight || currentTheme.bottomSheetHeight || 0.9;
|
|
31
40
|
var _React$useState = React.useState(new Animated.Value(SCREEN_HEIGHT)),
|
|
32
41
|
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
33
42
|
slideAnim = _React$useState2[0];
|
|
@@ -66,18 +75,34 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
66
75
|
children: /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
|
|
67
76
|
onPress: handleClose,
|
|
68
77
|
children: /*#__PURE__*/_jsx(View, {
|
|
69
|
-
style: styles.overlay,
|
|
78
|
+
style: [styles.overlay, {
|
|
79
|
+
backgroundColor: currentTheme.colors.overlay
|
|
80
|
+
}, overlayStyle],
|
|
70
81
|
children: /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
|
|
71
82
|
children: /*#__PURE__*/_jsxs(Animated.View, {
|
|
72
|
-
style: [styles.container,
|
|
83
|
+
style: [styles.container, {
|
|
84
|
+
backgroundColor: currentTheme.colors.background,
|
|
85
|
+
borderTopLeftRadius: currentTheme.radius.xxl,
|
|
86
|
+
borderTopRightRadius: currentTheme.radius.xxl,
|
|
87
|
+
maxHeight: SCREEN_HEIGHT * sheetHeight,
|
|
88
|
+
padding: currentTheme.spacing.xl
|
|
89
|
+
}, containerStyle, {
|
|
73
90
|
transform: [{
|
|
74
91
|
translateY: slideAnim
|
|
75
92
|
}]
|
|
76
93
|
}],
|
|
77
94
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
78
|
-
style: [styles.header,
|
|
95
|
+
style: [styles.header, {
|
|
96
|
+
borderBottomColor: currentTheme.colors.border,
|
|
97
|
+
marginBottom: currentTheme.spacing.lg,
|
|
98
|
+
paddingBottom: currentTheme.spacing.md
|
|
99
|
+
}, headerStyle],
|
|
79
100
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
80
|
-
style: [styles.title,
|
|
101
|
+
style: [styles.title, {
|
|
102
|
+
fontSize: currentTheme.typography.title.fontSize,
|
|
103
|
+
fontWeight: currentTheme.typography.title.fontWeight,
|
|
104
|
+
color: currentTheme.colors.text
|
|
105
|
+
}, titleStyle],
|
|
81
106
|
children: title
|
|
82
107
|
}), /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
83
108
|
onPress: handleClose,
|
|
@@ -88,7 +113,10 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
88
113
|
left: 10,
|
|
89
114
|
right: 10
|
|
90
115
|
},
|
|
91
|
-
children: /*#__PURE__*/_jsx(CloseIcon, {
|
|
116
|
+
children: /*#__PURE__*/_jsx(CloseIcon, {
|
|
117
|
+
size: 24,
|
|
118
|
+
color: currentTheme.colors.text
|
|
119
|
+
})
|
|
92
120
|
})]
|
|
93
121
|
}), /*#__PURE__*/_jsx(MediaTab, {
|
|
94
122
|
imagePopup: isOpen,
|
|
@@ -99,7 +127,8 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
99
127
|
apiService: apiService,
|
|
100
128
|
onError: onError,
|
|
101
129
|
picker: picker,
|
|
102
|
-
pickerOptions: pickerOptions
|
|
130
|
+
pickerOptions: pickerOptions,
|
|
131
|
+
theme: currentTheme
|
|
103
132
|
})]
|
|
104
133
|
})
|
|
105
134
|
})
|
|
@@ -110,16 +139,10 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
110
139
|
var styles = StyleSheet.create({
|
|
111
140
|
overlay: {
|
|
112
141
|
flex: 1,
|
|
113
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
114
142
|
justifyContent: 'flex-end'
|
|
115
143
|
},
|
|
116
144
|
container: {
|
|
117
|
-
backgroundColor: '#FFFFFF',
|
|
118
|
-
borderTopLeftRadius: 20,
|
|
119
|
-
borderTopRightRadius: 20,
|
|
120
|
-
maxHeight: SCREEN_HEIGHT * 0.85,
|
|
121
145
|
minHeight: 200,
|
|
122
|
-
padding: 20,
|
|
123
146
|
shadowColor: '#000',
|
|
124
147
|
shadowOffset: {
|
|
125
148
|
width: 0,
|
|
@@ -133,19 +156,15 @@ var styles = StyleSheet.create({
|
|
|
133
156
|
flexDirection: 'row',
|
|
134
157
|
alignItems: 'center',
|
|
135
158
|
justifyContent: 'space-between',
|
|
136
|
-
|
|
137
|
-
paddingBottom: 12,
|
|
138
|
-
borderBottomWidth: 1,
|
|
139
|
-
borderBottomColor: '#E5E5E5'
|
|
159
|
+
borderBottomWidth: 1
|
|
140
160
|
},
|
|
141
161
|
title: {
|
|
142
|
-
|
|
143
|
-
fontWeight: 'bold',
|
|
144
|
-
color: '#000000'
|
|
162
|
+
flex: 1
|
|
145
163
|
},
|
|
146
164
|
closeButton: {
|
|
147
165
|
padding: 8,
|
|
148
|
-
borderRadius: 20
|
|
166
|
+
borderRadius: 20,
|
|
167
|
+
marginLeft: 12
|
|
149
168
|
}
|
|
150
169
|
});
|
|
151
170
|
export default MediaPopup;
|
|
@@ -5,9 +5,10 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
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
7
|
import React, { useMemo, useState } from 'react';
|
|
8
|
-
import { View, Text, TouchableOpacity, StyleSheet
|
|
8
|
+
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
|
|
9
9
|
import ImagesGallery from './MediaGallery.native';
|
|
10
10
|
import VideosGallery from './VideosGallery.native';
|
|
11
|
+
import { defaultTheme } from './theme';
|
|
11
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
13
|
var MediaTab = function MediaTab(_ref) {
|
|
13
14
|
var imagePopup = _ref.imagePopup,
|
|
@@ -19,11 +20,17 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
19
20
|
onError = _ref.onError,
|
|
20
21
|
picker = _ref.picker,
|
|
21
22
|
pickerOptions = _ref.pickerOptions,
|
|
23
|
+
_ref$theme = _ref.theme,
|
|
24
|
+
theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
|
|
22
25
|
containerStyle = _ref.containerStyle,
|
|
23
26
|
tabListStyle = _ref.tabListStyle,
|
|
24
27
|
tabButtonStyle = _ref.tabButtonStyle,
|
|
25
28
|
tabButtonActiveStyle = _ref.tabButtonActiveStyle,
|
|
26
29
|
tabButtonInactiveStyle = _ref.tabButtonInactiveStyle,
|
|
30
|
+
tabButtonTextStyle = _ref.tabButtonTextStyle,
|
|
31
|
+
tabButtonTextActiveStyle = _ref.tabButtonTextActiveStyle,
|
|
32
|
+
tabButtonTextInactiveStyle = _ref.tabButtonTextInactiveStyle,
|
|
33
|
+
tabIndicatorStyle = _ref.tabIndicatorStyle,
|
|
27
34
|
tabPanelStyle = _ref.tabPanelStyle;
|
|
28
35
|
// Build a stable list of enabled tabs in order
|
|
29
36
|
var availableTabs = useMemo(function () {
|
|
@@ -70,7 +77,8 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
70
77
|
apiService: apiService,
|
|
71
78
|
onError: onError,
|
|
72
79
|
picker: picker,
|
|
73
|
-
pickerOptions: pickerOptions
|
|
80
|
+
pickerOptions: pickerOptions,
|
|
81
|
+
theme: theme
|
|
74
82
|
});
|
|
75
83
|
}
|
|
76
84
|
if (type === 'file') {
|
|
@@ -91,19 +99,35 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
91
99
|
return /*#__PURE__*/_jsxs(View, {
|
|
92
100
|
style: [styles.container, containerStyle],
|
|
93
101
|
children: [/*#__PURE__*/_jsx(View, {
|
|
94
|
-
style: [styles.tabList,
|
|
102
|
+
style: [styles.tabList, {
|
|
103
|
+
backgroundColor: theme.colors.tabBackground,
|
|
104
|
+
borderBottomColor: theme.colors.border,
|
|
105
|
+
paddingHorizontal: theme.spacing.xs
|
|
106
|
+
}, tabListStyle],
|
|
95
107
|
children: availableTabs.map(function (type, index) {
|
|
96
108
|
var isSelected = index === selectedIndex;
|
|
97
109
|
return /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
98
110
|
onPress: function onPress() {
|
|
99
111
|
return setSelectedIndex(index);
|
|
100
112
|
},
|
|
101
|
-
style: [styles.tabButton,
|
|
113
|
+
style: [styles.tabButton, {
|
|
114
|
+
paddingVertical: theme.spacing.md,
|
|
115
|
+
paddingHorizontal: theme.spacing.lg
|
|
116
|
+
}, tabButtonStyle, isSelected ? [styles.tabButtonActive, tabButtonActiveStyle] : [styles.tabButtonInactive, tabButtonInactiveStyle]],
|
|
102
117
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
103
|
-
style: [styles.tabButtonText,
|
|
118
|
+
style: [styles.tabButtonText, {
|
|
119
|
+
fontSize: theme.typography.body.fontSize,
|
|
120
|
+
fontWeight: theme.typography.body.fontWeight
|
|
121
|
+
}, isSelected ? [styles.tabButtonTextActive, {
|
|
122
|
+
color: theme.colors.tabActive
|
|
123
|
+
}, tabButtonTextActiveStyle] : [styles.tabButtonTextInactive, {
|
|
124
|
+
color: theme.colors.tabInactive
|
|
125
|
+
}, tabButtonTextInactiveStyle], tabButtonTextStyle],
|
|
104
126
|
children: renderTabLabel(type)
|
|
105
127
|
}), isSelected && /*#__PURE__*/_jsx(View, {
|
|
106
|
-
style: styles.tabIndicator
|
|
128
|
+
style: [styles.tabIndicator, {
|
|
129
|
+
backgroundColor: theme.colors.tabIndicator
|
|
130
|
+
}, tabIndicatorStyle]
|
|
107
131
|
})]
|
|
108
132
|
}, type);
|
|
109
133
|
})
|
|
@@ -125,42 +149,35 @@ var styles = StyleSheet.create({
|
|
|
125
149
|
},
|
|
126
150
|
tabList: {
|
|
127
151
|
flexDirection: 'row',
|
|
128
|
-
borderBottomWidth: 2
|
|
129
|
-
borderBottomColor: '#E5E5E5',
|
|
130
|
-
backgroundColor: '#FFFFFF',
|
|
131
|
-
paddingHorizontal: 4
|
|
152
|
+
borderBottomWidth: 2
|
|
132
153
|
},
|
|
133
154
|
tabButton: {
|
|
134
155
|
flex: 1,
|
|
135
|
-
paddingVertical: 12,
|
|
136
|
-
paddingHorizontal: 16,
|
|
137
156
|
alignItems: 'center',
|
|
138
157
|
justifyContent: 'center',
|
|
139
158
|
position: 'relative'
|
|
140
159
|
},
|
|
141
160
|
tabButtonActive: {
|
|
142
|
-
// Active state styling
|
|
161
|
+
// Active state styling applied via theme
|
|
143
162
|
},
|
|
144
163
|
tabButtonInactive: {
|
|
145
|
-
// Inactive state styling
|
|
164
|
+
// Inactive state styling applied via theme
|
|
146
165
|
},
|
|
147
166
|
tabButtonText: {
|
|
148
|
-
|
|
149
|
-
fontWeight: '500'
|
|
167
|
+
// Base text styling applied via theme
|
|
150
168
|
},
|
|
151
169
|
tabButtonTextActive: {
|
|
152
|
-
color
|
|
170
|
+
// Active text color applied via theme
|
|
153
171
|
},
|
|
154
172
|
tabButtonTextInactive: {
|
|
155
|
-
color
|
|
173
|
+
// Inactive text color applied via theme
|
|
156
174
|
},
|
|
157
175
|
tabIndicator: {
|
|
158
176
|
position: 'absolute',
|
|
159
177
|
bottom: -2,
|
|
160
178
|
left: 0,
|
|
161
179
|
right: 0,
|
|
162
|
-
height: 2
|
|
163
|
-
backgroundColor: '#3B3269' // primary color
|
|
180
|
+
height: 2
|
|
164
181
|
},
|
|
165
182
|
tabPanel: {
|
|
166
183
|
flex: 1
|