@tradly/asset 1.0.12 → 1.0.14
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 +257 -13
- package/dist/components/FileUpload.js +8 -247
- package/dist/components/FileUpload.native.js +13 -0
- package/dist/components/Icons.js +10 -33
- package/dist/components/Icons.native.js +16 -0
- package/dist/components/ImagesSkeleton.js +7 -15
- package/dist/components/ImagesSkeleton.native.js +13 -0
- package/dist/components/MediaGallery.js +8 -148
- package/dist/components/MediaGallery.native.js +13 -0
- package/dist/components/MediaPopup.js +8 -99
- package/dist/components/MediaPopup.native.js +13 -0
- package/dist/components/MediaTab.js +7 -180
- package/dist/components/MediaTab.native.js +13 -0
- package/dist/components/Pagination.js +8 -136
- package/dist/components/Pagination.native.js +13 -0
- package/dist/components/VideosGallery.js +8 -148
- package/dist/components/VideosGallery.native.js +13 -0
- package/dist/core/MediaApiService.js +396 -0
- package/dist/esm/components/FileUpload.js +1 -246
- package/dist/esm/components/FileUpload.native.js +1 -0
- package/dist/esm/components/Icons.js +1 -32
- package/dist/esm/components/Icons.native.js +1 -0
- package/dist/esm/components/ImagesSkeleton.js +1 -14
- package/dist/esm/components/ImagesSkeleton.native.js +1 -0
- package/dist/esm/components/MediaGallery.js +1 -144
- package/dist/esm/components/MediaGallery.native.js +1 -0
- package/dist/esm/components/MediaPopup.js +1 -97
- package/dist/esm/components/MediaPopup.native.js +1 -0
- package/dist/esm/components/MediaTab.js +1 -177
- package/dist/esm/components/MediaTab.native.js +1 -0
- package/dist/esm/components/Pagination.js +1 -134
- package/dist/esm/components/Pagination.native.js +1 -0
- package/dist/esm/components/VideosGallery.js +1 -144
- package/dist/esm/components/VideosGallery.native.js +1 -0
- package/dist/esm/core/MediaApiService.js +390 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/native/FileUpload.native.js +298 -0
- package/dist/esm/native/Icons.native.js +51 -0
- package/dist/esm/native/ImagesSkeleton.native.js +45 -0
- package/dist/esm/native/MediaGallery.native.js +221 -0
- package/dist/esm/native/MediaPopup.native.js +151 -0
- package/dist/esm/native/MediaTab.native.js +175 -0
- package/dist/esm/native/Pagination.native.js +186 -0
- package/dist/esm/native/VideosGallery.native.js +233 -0
- package/dist/esm/services/apiService.js +1 -372
- package/dist/esm/web/FileUpload.web.js +253 -0
- package/dist/esm/web/Icons.web.js +32 -0
- package/dist/esm/web/ImagesSkeleton.web.js +14 -0
- package/dist/esm/web/MediaGallery.web.js +144 -0
- package/dist/esm/web/MediaPopup.web.js +97 -0
- package/dist/esm/web/MediaTab.web.js +177 -0
- package/dist/esm/web/Pagination.web.js +134 -0
- package/dist/esm/web/VideosGallery.web.js +144 -0
- package/dist/index.js +2 -2
- package/dist/native/FileUpload.native.js +304 -0
- package/dist/native/Icons.native.js +59 -0
- package/dist/native/ImagesSkeleton.native.js +52 -0
- package/dist/native/MediaGallery.native.js +230 -0
- package/dist/native/MediaPopup.native.js +158 -0
- package/dist/native/MediaTab.native.js +184 -0
- package/dist/native/Pagination.native.js +193 -0
- package/dist/native/VideosGallery.native.js +241 -0
- package/dist/services/apiService.js +2 -372
- package/dist/web/FileUpload.web.js +259 -0
- package/dist/web/Icons.web.js +39 -0
- package/dist/web/ImagesSkeleton.web.js +21 -0
- package/dist/web/MediaGallery.web.js +153 -0
- package/dist/web/MediaPopup.web.js +104 -0
- package/dist/web/MediaTab.web.js +186 -0
- package/dist/web/Pagination.web.js +141 -0
- package/dist/web/VideosGallery.web.js +153 -0
- package/package.json +4 -3
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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; } }
|
|
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
|
+
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
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
var _Dimensions$get = Dimensions.get('window'),
|
|
13
|
+
SCREEN_HEIGHT = _Dimensions$get.height;
|
|
14
|
+
var MediaPopup = function MediaPopup(_ref) {
|
|
15
|
+
var isOpen = _ref.isOpen,
|
|
16
|
+
onClose = _ref.onClose,
|
|
17
|
+
onSelect = _ref.onSelect,
|
|
18
|
+
currentData = _ref.currentData,
|
|
19
|
+
_ref$options = _ref.options,
|
|
20
|
+
options = _ref$options === void 0 ? ['image'] : _ref$options,
|
|
21
|
+
apiService = _ref.apiService,
|
|
22
|
+
onError = _ref.onError,
|
|
23
|
+
_ref$title = _ref.title,
|
|
24
|
+
title = _ref$title === void 0 ? 'Media Gallery' : _ref$title,
|
|
25
|
+
picker = _ref.picker,
|
|
26
|
+
pickerOptions = _ref.pickerOptions,
|
|
27
|
+
containerStyle = _ref.containerStyle,
|
|
28
|
+
headerStyle = _ref.headerStyle,
|
|
29
|
+
titleStyle = _ref.titleStyle,
|
|
30
|
+
closeButtonStyle = _ref.closeButtonStyle;
|
|
31
|
+
var _React$useState = React.useState(new Animated.Value(SCREEN_HEIGHT)),
|
|
32
|
+
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
33
|
+
slideAnim = _React$useState2[0];
|
|
34
|
+
React.useEffect(function () {
|
|
35
|
+
if (isOpen) {
|
|
36
|
+
Animated.spring(slideAnim, {
|
|
37
|
+
toValue: 0,
|
|
38
|
+
useNativeDriver: true,
|
|
39
|
+
tension: 65,
|
|
40
|
+
friction: 11
|
|
41
|
+
}).start();
|
|
42
|
+
} else {
|
|
43
|
+
Animated.timing(slideAnim, {
|
|
44
|
+
toValue: SCREEN_HEIGHT,
|
|
45
|
+
duration: 250,
|
|
46
|
+
useNativeDriver: true
|
|
47
|
+
}).start();
|
|
48
|
+
}
|
|
49
|
+
}, [isOpen]);
|
|
50
|
+
var handleUpdate = function handleUpdate(data) {
|
|
51
|
+
if (onSelect) {
|
|
52
|
+
onSelect(data);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var handleClose = function handleClose() {
|
|
56
|
+
if (onClose) {
|
|
57
|
+
onClose();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
if (!isOpen) return null;
|
|
61
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
62
|
+
visible: isOpen,
|
|
63
|
+
transparent: true,
|
|
64
|
+
animationType: "none",
|
|
65
|
+
onRequestClose: handleClose,
|
|
66
|
+
children: /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
|
|
67
|
+
onPress: handleClose,
|
|
68
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
69
|
+
style: styles.overlay,
|
|
70
|
+
children: /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
|
|
71
|
+
children: /*#__PURE__*/_jsxs(Animated.View, {
|
|
72
|
+
style: [styles.container, containerStyle, {
|
|
73
|
+
transform: [{
|
|
74
|
+
translateY: slideAnim
|
|
75
|
+
}]
|
|
76
|
+
}],
|
|
77
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
78
|
+
style: [styles.header, headerStyle],
|
|
79
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
80
|
+
style: [styles.title, titleStyle],
|
|
81
|
+
children: title
|
|
82
|
+
}), /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
83
|
+
onPress: handleClose,
|
|
84
|
+
style: [styles.closeButton, closeButtonStyle],
|
|
85
|
+
hitSlop: {
|
|
86
|
+
top: 10,
|
|
87
|
+
bottom: 10,
|
|
88
|
+
left: 10,
|
|
89
|
+
right: 10
|
|
90
|
+
},
|
|
91
|
+
children: /*#__PURE__*/_jsx(CloseIcon, {})
|
|
92
|
+
})]
|
|
93
|
+
}), /*#__PURE__*/_jsx(MediaTab, {
|
|
94
|
+
imagePopup: isOpen,
|
|
95
|
+
update_data: handleUpdate,
|
|
96
|
+
current_data: currentData,
|
|
97
|
+
closePopup: handleClose,
|
|
98
|
+
options: options,
|
|
99
|
+
apiService: apiService,
|
|
100
|
+
onError: onError,
|
|
101
|
+
picker: picker,
|
|
102
|
+
pickerOptions: pickerOptions
|
|
103
|
+
})]
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
var styles = StyleSheet.create({
|
|
111
|
+
overlay: {
|
|
112
|
+
flex: 1,
|
|
113
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
114
|
+
justifyContent: 'flex-end'
|
|
115
|
+
},
|
|
116
|
+
container: {
|
|
117
|
+
backgroundColor: '#FFFFFF',
|
|
118
|
+
borderTopLeftRadius: 20,
|
|
119
|
+
borderTopRightRadius: 20,
|
|
120
|
+
maxHeight: SCREEN_HEIGHT * 0.85,
|
|
121
|
+
minHeight: 200,
|
|
122
|
+
padding: 20,
|
|
123
|
+
shadowColor: '#000',
|
|
124
|
+
shadowOffset: {
|
|
125
|
+
width: 0,
|
|
126
|
+
height: -2
|
|
127
|
+
},
|
|
128
|
+
shadowOpacity: 0.25,
|
|
129
|
+
shadowRadius: 3.84,
|
|
130
|
+
elevation: 5
|
|
131
|
+
},
|
|
132
|
+
header: {
|
|
133
|
+
flexDirection: 'row',
|
|
134
|
+
alignItems: 'center',
|
|
135
|
+
justifyContent: 'space-between',
|
|
136
|
+
marginBottom: 16,
|
|
137
|
+
paddingBottom: 12,
|
|
138
|
+
borderBottomWidth: 1,
|
|
139
|
+
borderBottomColor: '#E5E5E5'
|
|
140
|
+
},
|
|
141
|
+
title: {
|
|
142
|
+
fontSize: 24,
|
|
143
|
+
fontWeight: 'bold',
|
|
144
|
+
color: '#000000'
|
|
145
|
+
},
|
|
146
|
+
closeButton: {
|
|
147
|
+
padding: 8,
|
|
148
|
+
borderRadius: 20
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
export default MediaPopup;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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; } }
|
|
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
|
+
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
|
+
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';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
var MediaTab = function MediaTab(_ref) {
|
|
13
|
+
var imagePopup = _ref.imagePopup,
|
|
14
|
+
current_data = _ref.current_data,
|
|
15
|
+
update_data = _ref.update_data,
|
|
16
|
+
closePopup = _ref.closePopup,
|
|
17
|
+
options = _ref.options,
|
|
18
|
+
apiService = _ref.apiService,
|
|
19
|
+
onError = _ref.onError,
|
|
20
|
+
picker = _ref.picker,
|
|
21
|
+
pickerOptions = _ref.pickerOptions,
|
|
22
|
+
containerStyle = _ref.containerStyle,
|
|
23
|
+
tabListStyle = _ref.tabListStyle,
|
|
24
|
+
tabButtonStyle = _ref.tabButtonStyle,
|
|
25
|
+
tabButtonActiveStyle = _ref.tabButtonActiveStyle,
|
|
26
|
+
tabButtonInactiveStyle = _ref.tabButtonInactiveStyle,
|
|
27
|
+
tabPanelStyle = _ref.tabPanelStyle;
|
|
28
|
+
// Build a stable list of enabled tabs in order
|
|
29
|
+
var availableTabs = useMemo(function () {
|
|
30
|
+
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');
|
|
34
|
+
return tabs;
|
|
35
|
+
}, [options]);
|
|
36
|
+
var _useState = useState(0),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
selectedIndex = _useState2[0],
|
|
39
|
+
setSelectedIndex = _useState2[1];
|
|
40
|
+
|
|
41
|
+
// Guard: if no options passed, render nothing
|
|
42
|
+
if (!availableTabs.length) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
var renderTabLabel = function renderTabLabel(type) {
|
|
46
|
+
if (type === 'image') return 'Images';
|
|
47
|
+
if (type === 'video') return 'Videos';
|
|
48
|
+
if (type === 'file') return 'Files';
|
|
49
|
+
return type;
|
|
50
|
+
};
|
|
51
|
+
var renderPanel = function renderPanel(type) {
|
|
52
|
+
if (type === 'image') {
|
|
53
|
+
return /*#__PURE__*/_jsx(ImagesGallery, {
|
|
54
|
+
imagePopup: imagePopup,
|
|
55
|
+
update_data: update_data,
|
|
56
|
+
current_data: current_data,
|
|
57
|
+
closePopup: closePopup,
|
|
58
|
+
apiService: apiService,
|
|
59
|
+
onError: onError,
|
|
60
|
+
picker: picker,
|
|
61
|
+
pickerOptions: pickerOptions
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (type === 'video') {
|
|
65
|
+
return /*#__PURE__*/_jsx(VideosGallery, {
|
|
66
|
+
imagePopup: imagePopup,
|
|
67
|
+
update_data: update_data,
|
|
68
|
+
current_data: current_data,
|
|
69
|
+
closePopup: closePopup,
|
|
70
|
+
apiService: apiService,
|
|
71
|
+
onError: onError,
|
|
72
|
+
picker: picker,
|
|
73
|
+
pickerOptions: pickerOptions
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (type === 'file') {
|
|
77
|
+
// Reuse ImagesGallery for files as in original implementation
|
|
78
|
+
return /*#__PURE__*/_jsx(ImagesGallery, {
|
|
79
|
+
imagePopup: imagePopup,
|
|
80
|
+
update_data: update_data,
|
|
81
|
+
current_data: current_data,
|
|
82
|
+
closePopup: closePopup,
|
|
83
|
+
apiService: apiService,
|
|
84
|
+
onError: onError,
|
|
85
|
+
picker: picker,
|
|
86
|
+
pickerOptions: pickerOptions
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
92
|
+
style: [styles.container, containerStyle],
|
|
93
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
94
|
+
style: [styles.tabList, tabListStyle],
|
|
95
|
+
children: availableTabs.map(function (type, index) {
|
|
96
|
+
var isSelected = index === selectedIndex;
|
|
97
|
+
return /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
98
|
+
onPress: function onPress() {
|
|
99
|
+
return setSelectedIndex(index);
|
|
100
|
+
},
|
|
101
|
+
style: [styles.tabButton, tabButtonStyle, isSelected ? [styles.tabButtonActive, tabButtonActiveStyle] : [styles.tabButtonInactive, tabButtonInactiveStyle]],
|
|
102
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
103
|
+
style: [styles.tabButtonText, isSelected ? styles.tabButtonTextActive : styles.tabButtonTextInactive],
|
|
104
|
+
children: renderTabLabel(type)
|
|
105
|
+
}), isSelected && /*#__PURE__*/_jsx(View, {
|
|
106
|
+
style: styles.tabIndicator
|
|
107
|
+
})]
|
|
108
|
+
}, type);
|
|
109
|
+
})
|
|
110
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
111
|
+
style: [styles.tabPanel, tabPanelStyle],
|
|
112
|
+
children: availableTabs.map(function (type, index) {
|
|
113
|
+
var isSelected = index === selectedIndex;
|
|
114
|
+
return /*#__PURE__*/_jsx(View, {
|
|
115
|
+
style: isSelected ? styles.panelVisible : styles.panelHidden,
|
|
116
|
+
children: isSelected && renderPanel(type)
|
|
117
|
+
}, type);
|
|
118
|
+
})
|
|
119
|
+
})]
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
var styles = StyleSheet.create({
|
|
123
|
+
container: {
|
|
124
|
+
flex: 1
|
|
125
|
+
},
|
|
126
|
+
tabList: {
|
|
127
|
+
flexDirection: 'row',
|
|
128
|
+
borderBottomWidth: 2,
|
|
129
|
+
borderBottomColor: '#E5E5E5',
|
|
130
|
+
backgroundColor: '#FFFFFF',
|
|
131
|
+
paddingHorizontal: 4
|
|
132
|
+
},
|
|
133
|
+
tabButton: {
|
|
134
|
+
flex: 1,
|
|
135
|
+
paddingVertical: 12,
|
|
136
|
+
paddingHorizontal: 16,
|
|
137
|
+
alignItems: 'center',
|
|
138
|
+
justifyContent: 'center',
|
|
139
|
+
position: 'relative'
|
|
140
|
+
},
|
|
141
|
+
tabButtonActive: {
|
|
142
|
+
// Active state styling
|
|
143
|
+
},
|
|
144
|
+
tabButtonInactive: {
|
|
145
|
+
// Inactive state styling
|
|
146
|
+
},
|
|
147
|
+
tabButtonText: {
|
|
148
|
+
fontSize: 16,
|
|
149
|
+
fontWeight: '500'
|
|
150
|
+
},
|
|
151
|
+
tabButtonTextActive: {
|
|
152
|
+
color: '#3B3269' // primary color
|
|
153
|
+
},
|
|
154
|
+
tabButtonTextInactive: {
|
|
155
|
+
color: '#4F4F4F'
|
|
156
|
+
},
|
|
157
|
+
tabIndicator: {
|
|
158
|
+
position: 'absolute',
|
|
159
|
+
bottom: -2,
|
|
160
|
+
left: 0,
|
|
161
|
+
right: 0,
|
|
162
|
+
height: 2,
|
|
163
|
+
backgroundColor: '#3B3269' // primary color
|
|
164
|
+
},
|
|
165
|
+
tabPanel: {
|
|
166
|
+
flex: 1
|
|
167
|
+
},
|
|
168
|
+
panelVisible: {
|
|
169
|
+
flex: 1
|
|
170
|
+
},
|
|
171
|
+
panelHidden: {
|
|
172
|
+
display: 'none'
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
export default MediaTab;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
var Pagination = function Pagination(_ref) {
|
|
5
|
+
var nextPage = _ref.nextPage,
|
|
6
|
+
current_page = _ref.current_page,
|
|
7
|
+
pageCount = _ref.pageCount,
|
|
8
|
+
containerStyle = _ref.containerStyle,
|
|
9
|
+
navStyle = _ref.navStyle,
|
|
10
|
+
previousButtonStyle = _ref.previousButtonStyle,
|
|
11
|
+
nextButtonStyle = _ref.nextButtonStyle,
|
|
12
|
+
pageButtonStyle = _ref.pageButtonStyle,
|
|
13
|
+
pageButtonActiveStyle = _ref.pageButtonActiveStyle,
|
|
14
|
+
ellipsisStyle = _ref.ellipsisStyle;
|
|
15
|
+
var totalPages = Math.ceil(pageCount) || 1;
|
|
16
|
+
var currentPage = current_page || 1;
|
|
17
|
+
|
|
18
|
+
// Generate page numbers to display
|
|
19
|
+
var getPageNumbers = function getPageNumbers() {
|
|
20
|
+
var pages = [];
|
|
21
|
+
var maxVisible = 5;
|
|
22
|
+
var startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
|
|
23
|
+
var endPage = Math.min(totalPages, startPage + maxVisible - 1);
|
|
24
|
+
if (endPage - startPage < maxVisible - 1) {
|
|
25
|
+
startPage = Math.max(1, endPage - maxVisible + 1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Add first page and ellipsis
|
|
29
|
+
if (startPage > 1) {
|
|
30
|
+
pages.push(1);
|
|
31
|
+
if (startPage > 2) {
|
|
32
|
+
pages.push('...');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Add visible pages
|
|
37
|
+
for (var i = startPage; i <= endPage; i++) {
|
|
38
|
+
pages.push(i);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Add ellipsis and last page
|
|
42
|
+
if (endPage < totalPages) {
|
|
43
|
+
if (endPage < totalPages - 1) {
|
|
44
|
+
pages.push('...');
|
|
45
|
+
}
|
|
46
|
+
pages.push(totalPages);
|
|
47
|
+
}
|
|
48
|
+
return pages;
|
|
49
|
+
};
|
|
50
|
+
var handlePageClick = function handlePageClick(page) {
|
|
51
|
+
if (page !== currentPage && page >= 1 && page <= totalPages && typeof page === 'number') {
|
|
52
|
+
nextPage(page);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var handlePrevious = function handlePrevious() {
|
|
56
|
+
if (currentPage > 1) {
|
|
57
|
+
nextPage(currentPage - 1);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var handleNext = function handleNext() {
|
|
61
|
+
if (currentPage < totalPages) {
|
|
62
|
+
nextPage(currentPage + 1);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if (totalPages <= 1) return null;
|
|
66
|
+
var pageNumbers = getPageNumbers();
|
|
67
|
+
return /*#__PURE__*/_jsx(View, {
|
|
68
|
+
style: [styles.container, containerStyle],
|
|
69
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
70
|
+
style: [styles.nav, navStyle],
|
|
71
|
+
children: [/*#__PURE__*/_jsx(TouchableOpacity, {
|
|
72
|
+
onPress: handlePrevious,
|
|
73
|
+
disabled: currentPage === 1,
|
|
74
|
+
style: [styles.button, styles.previousButton, previousButtonStyle, currentPage === 1 && styles.buttonDisabled],
|
|
75
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
76
|
+
style: styles.buttonText,
|
|
77
|
+
children: "\u2039"
|
|
78
|
+
})
|
|
79
|
+
}), pageNumbers.map(function (page, index) {
|
|
80
|
+
if (page === '...') {
|
|
81
|
+
return /*#__PURE__*/_jsx(View, {
|
|
82
|
+
style: [styles.ellipsis, ellipsisStyle],
|
|
83
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
84
|
+
style: styles.ellipsisText,
|
|
85
|
+
children: "..."
|
|
86
|
+
})
|
|
87
|
+
}, "ellipsis-".concat(index));
|
|
88
|
+
}
|
|
89
|
+
var isActive = page === currentPage;
|
|
90
|
+
return /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
91
|
+
onPress: function onPress() {
|
|
92
|
+
return handlePageClick(page);
|
|
93
|
+
},
|
|
94
|
+
style: [styles.button, styles.pageButton, pageButtonStyle, isActive && [styles.pageButtonActive, pageButtonActiveStyle]],
|
|
95
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
96
|
+
style: [styles.pageButtonText, isActive && styles.pageButtonTextActive],
|
|
97
|
+
children: page
|
|
98
|
+
})
|
|
99
|
+
}, page);
|
|
100
|
+
}), /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
101
|
+
onPress: handleNext,
|
|
102
|
+
disabled: currentPage === totalPages,
|
|
103
|
+
style: [styles.button, styles.nextButton, nextButtonStyle, currentPage === totalPages && styles.buttonDisabled],
|
|
104
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
105
|
+
style: styles.buttonText,
|
|
106
|
+
children: "\u203A"
|
|
107
|
+
})
|
|
108
|
+
})]
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
var styles = StyleSheet.create({
|
|
113
|
+
container: {
|
|
114
|
+
alignItems: 'center',
|
|
115
|
+
justifyContent: 'center'
|
|
116
|
+
},
|
|
117
|
+
nav: {
|
|
118
|
+
flexDirection: 'row',
|
|
119
|
+
alignItems: 'center',
|
|
120
|
+
justifyContent: 'center',
|
|
121
|
+
flexWrap: 'wrap'
|
|
122
|
+
},
|
|
123
|
+
button: {
|
|
124
|
+
minWidth: 40,
|
|
125
|
+
height: 40,
|
|
126
|
+
paddingHorizontal: 12,
|
|
127
|
+
justifyContent: 'center',
|
|
128
|
+
alignItems: 'center',
|
|
129
|
+
borderWidth: 1,
|
|
130
|
+
borderColor: '#D1D5DB',
|
|
131
|
+
backgroundColor: '#FFFFFF'
|
|
132
|
+
},
|
|
133
|
+
previousButton: {
|
|
134
|
+
borderTopLeftRadius: 6,
|
|
135
|
+
borderBottomLeftRadius: 6,
|
|
136
|
+
borderRightWidth: 0
|
|
137
|
+
},
|
|
138
|
+
nextButton: {
|
|
139
|
+
borderTopRightRadius: 6,
|
|
140
|
+
borderBottomRightRadius: 6,
|
|
141
|
+
borderLeftWidth: 0
|
|
142
|
+
},
|
|
143
|
+
pageButton: {
|
|
144
|
+
borderLeftWidth: 0,
|
|
145
|
+
borderRightWidth: 0
|
|
146
|
+
},
|
|
147
|
+
pageButtonActive: {
|
|
148
|
+
backgroundColor: '#3B3269',
|
|
149
|
+
borderColor: '#3B3269'
|
|
150
|
+
},
|
|
151
|
+
buttonDisabled: {
|
|
152
|
+
opacity: 0.5
|
|
153
|
+
},
|
|
154
|
+
buttonText: {
|
|
155
|
+
fontSize: 18,
|
|
156
|
+
color: '#6B7280',
|
|
157
|
+
fontWeight: '500'
|
|
158
|
+
},
|
|
159
|
+
pageButtonText: {
|
|
160
|
+
fontSize: 14,
|
|
161
|
+
color: '#6B7280',
|
|
162
|
+
fontWeight: '500'
|
|
163
|
+
},
|
|
164
|
+
pageButtonTextActive: {
|
|
165
|
+
color: '#FFFFFF',
|
|
166
|
+
fontWeight: '600'
|
|
167
|
+
},
|
|
168
|
+
ellipsis: {
|
|
169
|
+
minWidth: 40,
|
|
170
|
+
height: 40,
|
|
171
|
+
paddingHorizontal: 12,
|
|
172
|
+
justifyContent: 'center',
|
|
173
|
+
alignItems: 'center',
|
|
174
|
+
borderWidth: 1,
|
|
175
|
+
borderColor: '#D1D5DB',
|
|
176
|
+
borderLeftWidth: 0,
|
|
177
|
+
borderRightWidth: 0,
|
|
178
|
+
backgroundColor: '#FFFFFF'
|
|
179
|
+
},
|
|
180
|
+
ellipsisText: {
|
|
181
|
+
fontSize: 14,
|
|
182
|
+
color: '#374151',
|
|
183
|
+
fontWeight: '500'
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
export default Pagination;
|