@widergy/mobile-ui 2.3.2 → 2.3.4
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/CHANGELOG.md +14 -0
- package/lib/components/UTModal/index.js +3 -2
- package/lib/utils/fileUtils.js/index.js +39 -25
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [2.3.4](https://github.com/widergy/mobile-ui/compare/v2.3.3...v2.3.4) (2025-12-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* [UGGC-39] utmodal closebuttonvariant ([#469](https://github.com/widergy/mobile-ui/issues/469)) ([7221af5](https://github.com/widergy/mobile-ui/commit/7221af562cd739d9a649cefbe37d85eb713acccf))
|
|
7
|
+
|
|
8
|
+
## [2.3.3](https://github.com/widergy/mobile-ui/compare/v2.3.2...v2.3.3) (2025-12-10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* file type + resize ([#470](https://github.com/widergy/mobile-ui/issues/470)) ([a71989f](https://github.com/widergy/mobile-ui/commit/a71989f9d5144afe44209a1d135f873c11e084db))
|
|
14
|
+
|
|
1
15
|
## [2.3.2](https://github.com/widergy/mobile-ui/compare/v2.3.1...v2.3.2) (2025-12-10)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -37,6 +37,7 @@ const UTModal = ({
|
|
|
37
37
|
cancelButton,
|
|
38
38
|
children,
|
|
39
39
|
closeButtonColorTheme,
|
|
40
|
+
closeButtonVariant = 'text',
|
|
40
41
|
dataTestId = modal,
|
|
41
42
|
disableTouchable,
|
|
42
43
|
hideCloseButton,
|
|
@@ -106,7 +107,7 @@ const UTModal = ({
|
|
|
106
107
|
Icon="IconX"
|
|
107
108
|
onPress={onRequestClose}
|
|
108
109
|
style={{ root: styles.closeButton }}
|
|
109
|
-
variant=
|
|
110
|
+
variant={closeButtonVariant}
|
|
110
111
|
dataTestId={`${dataTestId}.${closeButton}`}
|
|
111
112
|
/>
|
|
112
113
|
)}
|
|
@@ -131,7 +132,7 @@ const UTModal = ({
|
|
|
131
132
|
Icon="IconX"
|
|
132
133
|
onPress={onRequestClose}
|
|
133
134
|
style={{ root: styles.closeButton }}
|
|
134
|
-
variant=
|
|
135
|
+
variant={closeButtonVariant}
|
|
135
136
|
dataTestId={`${dataTestId}.${closeButton}`}
|
|
136
137
|
/>
|
|
137
138
|
)}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { manipulateAsync, SaveFormat } from 'expo-image-manipulator';
|
|
2
2
|
|
|
3
3
|
import { IS_IOS } from '../platformUtils/constants';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const COMPRESSION_FACTOR = 0.8;
|
|
6
|
+
|
|
7
|
+
const IMAGE_MANIPULATOR_OPTIONS = {
|
|
8
|
+
base64: false,
|
|
9
|
+
compress: COMPRESSION_FACTOR,
|
|
10
|
+
format: SaveFormat.JPEG
|
|
11
|
+
};
|
|
7
12
|
|
|
8
13
|
export const isImageByUri = uri => {
|
|
9
14
|
const uCaseUri = uri.toUpperCase();
|
|
@@ -11,8 +16,10 @@ export const isImageByUri = uri => {
|
|
|
11
16
|
return uCaseUri.includes('.JPG') || uCaseUri.includes('.JPEG') || uCaseUri.includes('PNG');
|
|
12
17
|
};
|
|
13
18
|
|
|
14
|
-
export const blobToFile = (blob,
|
|
15
|
-
new File([blob], customName || blob.data?.name || blob.name || 'archivo', {
|
|
19
|
+
export const blobToFile = (blob, mimeType, customName) =>
|
|
20
|
+
new File([blob], customName || blob.data?.name || blob.name || 'archivo', {
|
|
21
|
+
type: blob.data?.type || mimeType
|
|
22
|
+
});
|
|
16
23
|
|
|
17
24
|
// We use the XMLHttpRequest API since the fetch API does not behave correctly under new sdks on Android
|
|
18
25
|
export const uriToBlob = uri => {
|
|
@@ -31,29 +38,36 @@ export const uriToBlob = uri => {
|
|
|
31
38
|
});
|
|
32
39
|
};
|
|
33
40
|
|
|
41
|
+
// This function is used to normalize all image files to JPEG
|
|
42
|
+
const handleImageFileToBlob = async uri => {
|
|
43
|
+
let blob = null;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
blob = await uriToBlob(uri);
|
|
47
|
+
|
|
48
|
+
const isDataTypeJpeg = blob.data?.type.includes('jpeg');
|
|
49
|
+
|
|
50
|
+
// If the file is already a JPEG, we return it as is
|
|
51
|
+
if (isDataTypeJpeg) return blob;
|
|
52
|
+
|
|
53
|
+
const imageBase = await manipulateAsync(uri, [], IMAGE_MANIPULATOR_OPTIONS);
|
|
54
|
+
|
|
55
|
+
blob = await uriToBlob(imageBase.uri);
|
|
56
|
+
} catch (err) {
|
|
57
|
+
blob = await uriToBlob(uri);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return blob;
|
|
61
|
+
};
|
|
62
|
+
|
|
34
63
|
export const retrieveFile = async (uri, type) => {
|
|
35
64
|
const uriToUse = IS_IOS ? uri.replace('file://', '') : uri;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (type ? type.includes('image') : isImageByUri(uri)) {
|
|
39
|
-
if (ExpoImageManipulator?.manipulateAsync) {
|
|
40
|
-
try {
|
|
41
|
-
const actions = [{ resize: { width: IMG_SIZE, height: IMG_SIZE } }];
|
|
42
|
-
const options = {
|
|
43
|
-
compress: IMG_QUALITY / 100,
|
|
44
|
-
format: ExpoImageManipulator?.SaveFormat?.JPEG ?? 'jpeg',
|
|
45
|
-
base64: false
|
|
46
|
-
};
|
|
47
|
-
const result = await ExpoImageManipulator.manipulateAsync(uri, actions, options);
|
|
48
|
-
blob = await uriToBlob(result.uri);
|
|
49
|
-
} catch (err) {
|
|
50
|
-
blob = await uriToBlob(uriToUse);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
blob = await uriToBlob(uriToUse);
|
|
55
|
-
}
|
|
65
|
+
const isImageFile = type ? type.includes('image') : isImageByUri(uri);
|
|
56
66
|
|
|
67
|
+
if (isImageFile) {
|
|
68
|
+
return handleImageFileToBlob(uri);
|
|
69
|
+
}
|
|
70
|
+
const blob = await uriToBlob(uriToUse);
|
|
57
71
|
return blob;
|
|
58
72
|
};
|
|
59
73
|
|
package/package.json
CHANGED