@tradly/asset 1.0.14 → 1.0.16

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.
@@ -4,10 +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 'react';
8
- import { View, Text, TouchableOpacity, StyleSheet, ScrollView } from 'react-native';
9
- import ImagesGallery from './MediaGallery.native';
10
- import VideosGallery from './VideosGallery.native';
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";
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,18 +20,24 @@ 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 () {
30
37
  var tabs = [];
31
- if (options !== null && options !== void 0 && options.includes('image')) tabs.push('image');
32
- if (options !== null && options !== void 0 && options.includes('video')) tabs.push('video');
33
- if (options !== null && options !== void 0 && options.includes('file')) tabs.push('file');
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");
34
41
  return tabs;
35
42
  }, [options]);
36
43
  var _useState = useState(0),
@@ -43,13 +50,13 @@ var MediaTab = function MediaTab(_ref) {
43
50
  return null;
44
51
  }
45
52
  var renderTabLabel = function renderTabLabel(type) {
46
- if (type === 'image') return 'Images';
47
- if (type === 'video') return 'Videos';
48
- if (type === 'file') return 'Files';
53
+ if (type === "image") return "Images";
54
+ if (type === "video") return "Videos";
55
+ if (type === "file") return "Files";
49
56
  return type;
50
57
  };
51
58
  var renderPanel = function renderPanel(type) {
52
- if (type === 'image') {
59
+ if (type === "image") {
53
60
  return /*#__PURE__*/_jsx(ImagesGallery, {
54
61
  imagePopup: imagePopup,
55
62
  update_data: update_data,
@@ -58,10 +65,11 @@ var MediaTab = function MediaTab(_ref) {
58
65
  apiService: apiService,
59
66
  onError: onError,
60
67
  picker: picker,
61
- pickerOptions: pickerOptions
68
+ pickerOptions: pickerOptions,
69
+ theme: theme
62
70
  });
63
71
  }
64
- if (type === 'video') {
72
+ if (type === "video") {
65
73
  return /*#__PURE__*/_jsx(VideosGallery, {
66
74
  imagePopup: imagePopup,
67
75
  update_data: update_data,
@@ -70,10 +78,11 @@ var MediaTab = function MediaTab(_ref) {
70
78
  apiService: apiService,
71
79
  onError: onError,
72
80
  picker: picker,
73
- pickerOptions: pickerOptions
81
+ pickerOptions: pickerOptions,
82
+ theme: theme
74
83
  });
75
84
  }
76
- if (type === 'file') {
85
+ if (type === "file") {
77
86
  // Reuse ImagesGallery for files as in original implementation
78
87
  return /*#__PURE__*/_jsx(ImagesGallery, {
79
88
  imagePopup: imagePopup,
@@ -83,7 +92,8 @@ var MediaTab = function MediaTab(_ref) {
83
92
  apiService: apiService,
84
93
  onError: onError,
85
94
  picker: picker,
86
- pickerOptions: pickerOptions
95
+ pickerOptions: pickerOptions,
96
+ theme: theme
87
97
  });
88
98
  }
89
99
  return null;
@@ -91,19 +101,41 @@ var MediaTab = function MediaTab(_ref) {
91
101
  return /*#__PURE__*/_jsxs(View, {
92
102
  style: [styles.container, containerStyle],
93
103
  children: [/*#__PURE__*/_jsx(View, {
94
- style: [styles.tabList, tabListStyle],
104
+ style: [styles.tabList, {
105
+ backgroundColor: theme.colors.tabBackground,
106
+ borderBottomColor: theme.colors.border,
107
+ paddingHorizontal: theme.spacing.xs,
108
+ // Center align if only one tab
109
+ justifyContent: availableTabs.length === 1 ? "center" : "flex-start"
110
+ }, tabListStyle],
95
111
  children: availableTabs.map(function (type, index) {
96
112
  var isSelected = index === selectedIndex;
113
+ var isSingleTab = availableTabs.length === 1;
97
114
  return /*#__PURE__*/_jsxs(TouchableOpacity, {
98
115
  onPress: function onPress() {
99
116
  return setSelectedIndex(index);
100
117
  },
101
- style: [styles.tabButton, tabButtonStyle, isSelected ? [styles.tabButtonActive, tabButtonActiveStyle] : [styles.tabButtonInactive, tabButtonInactiveStyle]],
118
+ style: [styles.tabButton, {
119
+ paddingVertical: theme.spacing.md,
120
+ paddingHorizontal: theme.spacing.lg,
121
+ // If single tab, don't use flex: 1, use auto width
122
+ flex: isSingleTab ? 0 : 1,
123
+ alignSelf: isSingleTab ? "center" : "stretch"
124
+ }, tabButtonStyle, isSelected ? [styles.tabButtonActive, tabButtonActiveStyle] : [styles.tabButtonInactive, tabButtonInactiveStyle]],
102
125
  children: [/*#__PURE__*/_jsx(Text, {
103
- style: [styles.tabButtonText, isSelected ? styles.tabButtonTextActive : styles.tabButtonTextInactive],
126
+ style: [styles.tabButtonText, {
127
+ fontSize: theme.typography.body.fontSize,
128
+ fontWeight: theme.typography.body.fontWeight
129
+ }, isSelected ? [styles.tabButtonTextActive, {
130
+ color: theme.colors.tabActive
131
+ }, tabButtonTextActiveStyle] : [styles.tabButtonTextInactive, {
132
+ color: theme.colors.tabInactive
133
+ }, tabButtonTextInactiveStyle], tabButtonTextStyle],
104
134
  children: renderTabLabel(type)
105
135
  }), isSelected && /*#__PURE__*/_jsx(View, {
106
- style: styles.tabIndicator
136
+ style: [styles.tabIndicator, {
137
+ backgroundColor: theme.colors.tabIndicator
138
+ }, tabIndicatorStyle]
107
139
  })]
108
140
  }, type);
109
141
  })
@@ -124,43 +156,36 @@ var styles = StyleSheet.create({
124
156
  flex: 1
125
157
  },
126
158
  tabList: {
127
- flexDirection: 'row',
128
- borderBottomWidth: 2,
129
- borderBottomColor: '#E5E5E5',
130
- backgroundColor: '#FFFFFF',
131
- paddingHorizontal: 4
159
+ flexDirection: "row",
160
+ borderBottomWidth: 2
132
161
  },
133
162
  tabButton: {
134
- flex: 1,
135
- paddingVertical: 12,
136
- paddingHorizontal: 16,
137
- alignItems: 'center',
138
- justifyContent: 'center',
139
- position: 'relative'
163
+ alignItems: "center",
164
+ justifyContent: "center",
165
+ position: "relative",
166
+ minWidth: 80 // Minimum width for single tab
140
167
  },
141
168
  tabButtonActive: {
142
- // Active state styling
169
+ // Active state styling applied via theme
143
170
  },
144
171
  tabButtonInactive: {
145
- // Inactive state styling
172
+ // Inactive state styling applied via theme
146
173
  },
147
174
  tabButtonText: {
148
- fontSize: 16,
149
- fontWeight: '500'
175
+ // Base text styling applied via theme
150
176
  },
151
177
  tabButtonTextActive: {
152
- color: '#3B3269' // primary color
178
+ // Active text color applied via theme
153
179
  },
154
180
  tabButtonTextInactive: {
155
- color: '#4F4F4F'
181
+ // Inactive text color applied via theme
156
182
  },
157
183
  tabIndicator: {
158
- position: 'absolute',
184
+ position: "absolute",
159
185
  bottom: -2,
160
186
  left: 0,
161
187
  right: 0,
162
- height: 2,
163
- backgroundColor: '#3B3269' // primary color
188
+ height: 2
164
189
  },
165
190
  tabPanel: {
166
191
  flex: 1
@@ -169,7 +194,7 @@ var styles = StyleSheet.create({
169
194
  flex: 1
170
195
  },
171
196
  panelHidden: {
172
- display: 'none'
197
+ display: "none"
173
198
  }
174
199
  });
175
200
  export default MediaTab;
@@ -1,17 +1,22 @@
1
1
  import React from 'react';
2
2
  import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
3
+ import { defaultTheme } from './theme';
3
4
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
5
  var Pagination = function Pagination(_ref) {
5
6
  var nextPage = _ref.nextPage,
6
7
  current_page = _ref.current_page,
7
8
  pageCount = _ref.pageCount,
9
+ _ref$theme = _ref.theme,
10
+ theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
8
11
  containerStyle = _ref.containerStyle,
9
12
  navStyle = _ref.navStyle,
10
13
  previousButtonStyle = _ref.previousButtonStyle,
11
14
  nextButtonStyle = _ref.nextButtonStyle,
12
15
  pageButtonStyle = _ref.pageButtonStyle,
13
16
  pageButtonActiveStyle = _ref.pageButtonActiveStyle,
14
- ellipsisStyle = _ref.ellipsisStyle;
17
+ ellipsisStyle = _ref.ellipsisStyle,
18
+ pageButtonTextStyle = _ref.pageButtonTextStyle,
19
+ pageButtonTextActiveStyle = _ref.pageButtonTextActiveStyle;
15
20
  var totalPages = Math.ceil(pageCount) || 1;
16
21
  var currentPage = current_page || 1;
17
22
 
@@ -71,17 +76,27 @@ var Pagination = function Pagination(_ref) {
71
76
  children: [/*#__PURE__*/_jsx(TouchableOpacity, {
72
77
  onPress: handlePrevious,
73
78
  disabled: currentPage === 1,
74
- style: [styles.button, styles.previousButton, previousButtonStyle, currentPage === 1 && styles.buttonDisabled],
79
+ style: [styles.button, styles.previousButton, {
80
+ backgroundColor: theme.colors.paginationButton,
81
+ borderColor: theme.colors.paginationBorder
82
+ }, previousButtonStyle, currentPage === 1 && styles.buttonDisabled],
75
83
  children: /*#__PURE__*/_jsx(Text, {
76
- style: styles.buttonText,
84
+ style: [styles.buttonText, {
85
+ color: theme.colors.paginationText
86
+ }],
77
87
  children: "\u2039"
78
88
  })
79
89
  }), pageNumbers.map(function (page, index) {
80
90
  if (page === '...') {
81
91
  return /*#__PURE__*/_jsx(View, {
82
- style: [styles.ellipsis, ellipsisStyle],
92
+ style: [styles.ellipsis, {
93
+ backgroundColor: theme.colors.paginationButton,
94
+ borderColor: theme.colors.paginationBorder
95
+ }, ellipsisStyle],
83
96
  children: /*#__PURE__*/_jsx(Text, {
84
- style: styles.ellipsisText,
97
+ style: [styles.ellipsisText, {
98
+ color: theme.colors.paginationText
99
+ }],
85
100
  children: "..."
86
101
  })
87
102
  }, "ellipsis-".concat(index));
@@ -91,18 +106,29 @@ var Pagination = function Pagination(_ref) {
91
106
  onPress: function onPress() {
92
107
  return handlePageClick(page);
93
108
  },
94
- style: [styles.button, styles.pageButton, pageButtonStyle, isActive && [styles.pageButtonActive, pageButtonActiveStyle]],
109
+ style: [styles.button, styles.pageButton, {
110
+ backgroundColor: isActive ? theme.colors.paginationButtonActive : theme.colors.paginationButton,
111
+ borderColor: isActive ? theme.colors.paginationButtonActive : theme.colors.paginationBorder
112
+ }, pageButtonStyle, isActive && [styles.pageButtonActive, pageButtonActiveStyle]],
95
113
  children: /*#__PURE__*/_jsx(Text, {
96
- style: [styles.pageButtonText, isActive && styles.pageButtonTextActive],
114
+ style: [styles.pageButtonText, {
115
+ color: isActive ? theme.colors.paginationTextActive : theme.colors.paginationText,
116
+ fontWeight: isActive ? '600' : '500'
117
+ }, isActive && pageButtonTextActiveStyle, pageButtonTextStyle],
97
118
  children: page
98
119
  })
99
120
  }, page);
100
121
  }), /*#__PURE__*/_jsx(TouchableOpacity, {
101
122
  onPress: handleNext,
102
123
  disabled: currentPage === totalPages,
103
- style: [styles.button, styles.nextButton, nextButtonStyle, currentPage === totalPages && styles.buttonDisabled],
124
+ style: [styles.button, styles.nextButton, {
125
+ backgroundColor: theme.colors.paginationButton,
126
+ borderColor: theme.colors.paginationBorder
127
+ }, nextButtonStyle, currentPage === totalPages && styles.buttonDisabled],
104
128
  children: /*#__PURE__*/_jsx(Text, {
105
- style: styles.buttonText,
129
+ style: [styles.buttonText, {
130
+ color: theme.colors.paginationText
131
+ }],
106
132
  children: "\u203A"
107
133
  })
108
134
  })]
@@ -126,9 +152,8 @@ var styles = StyleSheet.create({
126
152
  paddingHorizontal: 12,
127
153
  justifyContent: 'center',
128
154
  alignItems: 'center',
129
- borderWidth: 1,
130
- borderColor: '#D1D5DB',
131
- backgroundColor: '#FFFFFF'
155
+ borderWidth: 1
156
+ // Colors applied via theme
132
157
  },
133
158
  previousButton: {
134
159
  borderTopLeftRadius: 6,
@@ -153,17 +178,17 @@ var styles = StyleSheet.create({
153
178
  },
154
179
  buttonText: {
155
180
  fontSize: 18,
156
- color: '#6B7280',
157
181
  fontWeight: '500'
182
+ // Color applied via theme
158
183
  },
159
184
  pageButtonText: {
160
185
  fontSize: 14,
161
- color: '#6B7280',
162
186
  fontWeight: '500'
187
+ // Color applied via theme
163
188
  },
164
189
  pageButtonTextActive: {
165
- color: '#FFFFFF',
166
190
  fontWeight: '600'
191
+ // Color applied via theme
167
192
  },
168
193
  ellipsis: {
169
194
  minWidth: 40,
@@ -172,15 +197,14 @@ var styles = StyleSheet.create({
172
197
  justifyContent: 'center',
173
198
  alignItems: 'center',
174
199
  borderWidth: 1,
175
- borderColor: '#D1D5DB',
176
200
  borderLeftWidth: 0,
177
- borderRightWidth: 0,
178
- backgroundColor: '#FFFFFF'
201
+ borderRightWidth: 0
202
+ // Colors applied via theme
179
203
  },
180
204
  ellipsisText: {
181
205
  fontSize: 14,
182
- color: '#374151',
183
206
  fontWeight: '500'
207
+ // Color applied via theme
184
208
  }
185
209
  });
186
210
  export default Pagination;
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Theme Configuration Examples
3
+ *
4
+ * This file shows how to customize the Media Gallery theme for React Native
5
+ */
6
+
7
+ import { createTheme } from './theme';
8
+
9
+ // Example 1: Light Mode (Default)
10
+ export var lightTheme = createTheme({
11
+ mode: 'light'
12
+ });
13
+
14
+ // Example 2: Dark Mode
15
+ export var darkTheme = createTheme({
16
+ mode: 'dark'
17
+ });
18
+
19
+ // Example 3: Custom Brand Colors
20
+ export var customBrandTheme = createTheme({
21
+ mode: 'light',
22
+ colors: {
23
+ primary: '#FF6B6B',
24
+ // Custom red primary
25
+ tabActive: '#FF6B6B',
26
+ tabIndicator: '#FF6B6B',
27
+ uploadBorder: '#FF6B6B',
28
+ uploadIconBackground: '#FF6B6B',
29
+ paginationButtonActive: '#FF6B6B'
30
+ },
31
+ bottomSheetHeight: 0.85 // 85% of screen height
32
+ });
33
+
34
+ // Example 4: Full Customization
35
+ export var fullyCustomTheme = createTheme({
36
+ mode: 'dark',
37
+ colors: {
38
+ // Primary colors
39
+ primary: '#6366F1',
40
+ primaryLight: '#818CF8',
41
+ primaryDark: '#4F46E5',
42
+ // Backgrounds
43
+ background: '#0F172A',
44
+ backgroundSecondary: '#1E293B',
45
+ backgroundTertiary: '#334155',
46
+ // Text
47
+ text: '#F1F5F9',
48
+ textSecondary: '#CBD5E1',
49
+ textTertiary: '#94A3B8',
50
+ // Tabs
51
+ tabActive: '#6366F1',
52
+ tabInactive: '#94A3B8',
53
+ tabIndicator: '#6366F1',
54
+ tabBackground: '#0F172A',
55
+ // Borders
56
+ border: '#334155',
57
+ borderLight: '#1E293B',
58
+ borderDark: '#475569',
59
+ // Overlay
60
+ overlay: 'rgba(0, 0, 0, 0.8)',
61
+ // Pagination
62
+ paginationBackground: '#1E293B',
63
+ paginationButton: '#0F172A',
64
+ paginationButtonActive: '#6366F1',
65
+ paginationText: '#CBD5E1',
66
+ paginationTextActive: '#FFFFFF',
67
+ paginationBorder: '#334155',
68
+ // Upload
69
+ uploadBorder: '#6366F1',
70
+ uploadBackground: '#0F172A',
71
+ uploadIconBackground: '#6366F1',
72
+ uploadText: '#F1F5F9',
73
+ // Items
74
+ itemBackground: '#1E293B',
75
+ itemShadow: '#000000',
76
+ // Loading
77
+ loadingBackground: '#1E293B',
78
+ loadingText: '#94A3B8'
79
+ },
80
+ spacing: {
81
+ xs: 4,
82
+ sm: 8,
83
+ md: 12,
84
+ lg: 16,
85
+ xl: 20,
86
+ xxl: 24
87
+ },
88
+ radius: {
89
+ sm: 6,
90
+ md: 8,
91
+ lg: 12,
92
+ xl: 16,
93
+ xxl: 20
94
+ },
95
+ bottomSheetHeight: 0.92 // 92% of screen height
96
+ });
97
+
98
+ // Usage in your component:
99
+ /*
100
+ import { MediaPopup, MediaApiService } from '@tradly/asset'
101
+ import { darkTheme } from './theme'
102
+
103
+ <MediaPopup
104
+ isOpen={isOpen}
105
+ onClose={() => setIsOpen(false)}
106
+ onSelect={handleSelect}
107
+ apiService={apiService}
108
+ picker={picker}
109
+ theme={darkTheme} // Pass your custom theme
110
+ bottomSheetHeight={0.9} // Or override height directly
111
+ />
112
+ */
@@ -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 { defaultTheme } from './theme';
20
21
  // Note: You'll need to install react-native-video for video playback
21
22
  // import Video from 'react-native-video'
22
23
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -33,6 +34,8 @@ var VideosGallery = function VideosGallery(_ref) {
33
34
  onError = _ref.onError,
34
35
  picker = _ref.picker,
35
36
  pickerOptions = _ref.pickerOptions,
37
+ _ref$theme = _ref.theme,
38
+ theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
36
39
  containerStyle = _ref.containerStyle,
37
40
  gridStyle = _ref.gridStyle,
38
41
  videoItemStyle = _ref.videoItemStyle,
@@ -131,7 +134,8 @@ var VideosGallery = function VideosGallery(_ref) {
131
134
  apiService: apiService,
132
135
  onUploadError: onError,
133
136
  picker: picker,
134
- pickerOptions: pickerOptions
137
+ pickerOptions: pickerOptions,
138
+ theme: theme
135
139
  })
136
140
  });
137
141
  }
@@ -172,13 +176,19 @@ var VideosGallery = function VideosGallery(_ref) {
172
176
  contentContainerStyle: [styles.grid, gridStyle],
173
177
  showsVerticalScrollIndicator: false,
174
178
  ListFooterComponent: total_count > 0 ? /*#__PURE__*/_jsx(View, {
175
- style: [styles.paginationContainer, paginationContainerStyle],
179
+ style: [styles.paginationContainer, {
180
+ backgroundColor: theme.colors.paginationBackground,
181
+ paddingVertical: theme.spacing.lg,
182
+ paddingHorizontal: theme.spacing.sm,
183
+ marginTop: theme.spacing.sm
184
+ }, paginationContainerStyle],
176
185
  children: /*#__PURE__*/_jsx(Pagination, {
177
186
  nextPage: function nextPage(value) {
178
187
  return loadMedia(value);
179
188
  },
180
189
  pageCount: Math.ceil(total_count / 30),
181
- current_page: currentPage
190
+ current_page: currentPage,
191
+ theme: theme
182
192
  })
183
193
  }) : null
184
194
  })
@@ -224,10 +234,7 @@ var styles = StyleSheet.create({
224
234
  height: '100%'
225
235
  },
226
236
  paginationContainer: {
227
- paddingVertical: 16,
228
- paddingHorizontal: 8,
229
- backgroundColor: '#F5F5F5',
230
- marginTop: 8
237
+ // Styles applied via theme
231
238
  }
232
239
  });
233
240
  export default VideosGallery;