@widergy/mobile-ui 0.32.1 → 0.32.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
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [0.32.4](https://github.com/widergy/mobile-ui/compare/v0.32.3...v0.32.4) (2022-03-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* round the percentage in progress bar in routes ([#216](https://github.com/widergy/mobile-ui/issues/216)) ([9a1c459](https://github.com/widergy/mobile-ui/commit/9a1c4593fbce214c700bc708aecd16c8b10716cd))
|
|
7
|
+
|
|
8
|
+
## [0.32.3](https://github.com/widergy/mobile-ui/compare/v0.32.2...v0.32.3) (2022-02-25)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* show image on updates (ImagePicker) ([#213](https://github.com/widergy/mobile-ui/issues/213)) ([1b55704](https://github.com/widergy/mobile-ui/commit/1b55704c7e8a42eb057da35872f85ac8b7d11506))
|
|
14
|
+
|
|
15
|
+
## [0.32.2](https://github.com/widergy/mobile-ui/compare/v0.32.1...v0.32.2) (2022-02-11)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* deprecated keyboard ([#214](https://github.com/widergy/mobile-ui/issues/214)) ([57b3775](https://github.com/widergy/mobile-ui/commit/57b37756155c7bf759e586ce35f090e86834fa89))
|
|
21
|
+
|
|
1
22
|
## [0.32.1](https://github.com/widergy/mobile-ui/compare/v0.32.0...v0.32.1) (2022-01-19)
|
|
2
23
|
|
|
3
24
|
|
|
@@ -21,13 +21,21 @@ const ImagePickerComponent = ({
|
|
|
21
21
|
pickerOptions,
|
|
22
22
|
style,
|
|
23
23
|
filePlaceholder,
|
|
24
|
+
unknownFilename,
|
|
24
25
|
withMarkdownTitle,
|
|
25
26
|
markdownStyles,
|
|
26
|
-
value
|
|
27
|
+
value,
|
|
28
|
+
urlKey,
|
|
29
|
+
avoidRetrieveFile,
|
|
30
|
+
defaultSource
|
|
27
31
|
}) => {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
32
|
+
const fallbackSource = urlKey ? value[urlKey] : typeof value === 'string' ? value : null;
|
|
33
|
+
const fileValues = {
|
|
34
|
+
source: value?.source ?? fallbackSource,
|
|
35
|
+
fileName: value?.fileName ?? unknownFilename ?? filePlaceholder
|
|
36
|
+
};
|
|
37
|
+
const hasValue = fileValues.source && fileValues.fileName;
|
|
38
|
+
const image = hasValue ? fileValues : null;
|
|
31
39
|
const [deleteModalOpen, setDeleteModalOpen] = useState(false);
|
|
32
40
|
const [imageModalOpen, setImageModalOpen] = useState(false);
|
|
33
41
|
const mergedOptions = { ...options, ...pickerOptions };
|
|
@@ -45,21 +53,20 @@ const ImagePickerComponent = ({
|
|
|
45
53
|
}
|
|
46
54
|
const { assets } = response;
|
|
47
55
|
const item = assets[0];
|
|
48
|
-
const file = await retrieveFile(item.uri, item.type);
|
|
49
|
-
if (!file) {
|
|
56
|
+
const file = !avoidRetrieveFile && (await retrieveFile(item.uri, item.type));
|
|
57
|
+
if (!avoidRetrieveFile && !file) {
|
|
50
58
|
onError(response.errorCode);
|
|
51
59
|
return;
|
|
52
60
|
}
|
|
53
61
|
|
|
54
|
-
if (file.size > maxFileByteSize) {
|
|
62
|
+
if (!avoidRetrieveFile && maxFileByteSize && file.size > maxFileByteSize) {
|
|
55
63
|
onMaxSizeError(file.size, maxFileByteSize);
|
|
56
64
|
return;
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
if (onChange) {
|
|
60
68
|
const fileNameAndSource = { source: item.uri, fileName: item.fileName };
|
|
61
|
-
onChange({
|
|
62
|
-
setImage(fileNameAndSource);
|
|
69
|
+
onChange({ ...fileNameAndSource, ...(!avoidRetrieveFile && { file }) });
|
|
63
70
|
}
|
|
64
71
|
});
|
|
65
72
|
};
|
|
@@ -68,7 +75,6 @@ const ImagePickerComponent = ({
|
|
|
68
75
|
if (onChange) {
|
|
69
76
|
onChange(null);
|
|
70
77
|
}
|
|
71
|
-
setImage(null);
|
|
72
78
|
setDeleteModalOpen(false);
|
|
73
79
|
};
|
|
74
80
|
|
|
@@ -102,6 +108,7 @@ const ImagePickerComponent = ({
|
|
|
102
108
|
deleteImageModalText={deleteImageModalText}
|
|
103
109
|
withMarkdownTitle={withMarkdownTitle}
|
|
104
110
|
markdownStyles={markdownStyles}
|
|
111
|
+
defaultSource={defaultSource}
|
|
105
112
|
/>
|
|
106
113
|
);
|
|
107
114
|
};
|
|
@@ -33,6 +33,7 @@ const ImagePicker = ({
|
|
|
33
33
|
onOpenImageModal,
|
|
34
34
|
withMarkdownTitle,
|
|
35
35
|
markdownStyles,
|
|
36
|
+
defaultSource,
|
|
36
37
|
optionsModal
|
|
37
38
|
}) => {
|
|
38
39
|
const [openModalSelection, setOpenModalSelection] = useState(false);
|
|
@@ -75,7 +76,12 @@ const ImagePicker = ({
|
|
|
75
76
|
{image && (
|
|
76
77
|
<View style={styles.imageContainer}>
|
|
77
78
|
<TouchableWithoutFeedback onPress={onOpenImageModal} style={styles.touchable}>
|
|
78
|
-
<Image
|
|
79
|
+
<Image
|
|
80
|
+
source={{ uri: image.source }}
|
|
81
|
+
style={styles.image}
|
|
82
|
+
resizeMode="contain"
|
|
83
|
+
defaultSource={defaultSource}
|
|
84
|
+
/>
|
|
79
85
|
</TouchableWithoutFeedback>
|
|
80
86
|
</View>
|
|
81
87
|
)}
|
|
@@ -13,12 +13,12 @@ const useKeyboardHeight = () => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
useEffect(() => {
|
|
16
|
-
Keyboard.addListener('keyboardDidShow', keyboardDidShow);
|
|
17
|
-
Keyboard.addListener('keyboardDidHide', keyboardDidHide);
|
|
16
|
+
const showSubscription = Keyboard.addListener('keyboardDidShow', keyboardDidShow);
|
|
17
|
+
const hideSubscription = Keyboard.addListener('keyboardDidHide', keyboardDidHide);
|
|
18
18
|
|
|
19
19
|
return () => {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
showSubscription.remove();
|
|
21
|
+
hideSubscription.remove();
|
|
22
22
|
};
|
|
23
23
|
}, []);
|
|
24
24
|
|
package/package.json
CHANGED