muba-posting 4.0.4 → 4.0.7
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/Posting.js +17 -19
- package/Publish1.js +22 -18
- package/Publish2.js +0 -4
- package/Publish4.js +3 -2
- package/package.json +1 -2
package/Posting.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BackHandler, Text, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import { manipulateAsync } from 'expo-image-manipulator';
|
|
4
3
|
import CustomScrollView from 'muba-custom-scroll-view';
|
|
5
4
|
import { CommonActions } from '@react-navigation/native';
|
|
6
5
|
import { loadLocaleData, currentLocale, strings } from 'muba-i18n';
|
|
@@ -54,7 +53,7 @@ export default class Posting extends React.Component {
|
|
|
54
53
|
prevViews: [],
|
|
55
54
|
currentScreen: 1,
|
|
56
55
|
fontLoaded: false,
|
|
57
|
-
isLoading:
|
|
56
|
+
isLoading: false,
|
|
58
57
|
showImageBrowser: false,
|
|
59
58
|
headerHeight: 0,
|
|
60
59
|
progressBarHeight: 0,
|
|
@@ -159,7 +158,7 @@ export default class Posting extends React.Component {
|
|
|
159
158
|
]);
|
|
160
159
|
this.setState({ fontLoaded: true });
|
|
161
160
|
|
|
162
|
-
this.
|
|
161
|
+
this.popupPermissions.open();
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
refresh = () => {
|
|
@@ -182,8 +181,7 @@ export default class Posting extends React.Component {
|
|
|
182
181
|
});
|
|
183
182
|
}
|
|
184
183
|
|
|
185
|
-
loadData = async () => {
|
|
186
|
-
const canPublish = await this.popupPermissions.open();
|
|
184
|
+
loadData = async (canPublish) => {
|
|
187
185
|
if (canPublish) {
|
|
188
186
|
const resultJson = await this.props.request(this, GET_COUNTRY_PHONE);
|
|
189
187
|
if (resultJson.success) {
|
|
@@ -205,6 +203,7 @@ export default class Posting extends React.Component {
|
|
|
205
203
|
}
|
|
206
204
|
BackHandler.addEventListener('hardwareBackPress', this.goBack);
|
|
207
205
|
} else {
|
|
206
|
+
this.goBack();
|
|
208
207
|
await this.setState({ isLoading: false });
|
|
209
208
|
}
|
|
210
209
|
}
|
|
@@ -217,7 +216,9 @@ export default class Posting extends React.Component {
|
|
|
217
216
|
originView: this.props.adId ? Views.EDIT_SELECTOR : Views.PUBLISH_1,
|
|
218
217
|
prevViews: [],
|
|
219
218
|
currentScreen: 1
|
|
220
|
-
},
|
|
219
|
+
}, () => {
|
|
220
|
+
this.popupPermissions.open();
|
|
221
|
+
});
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
|
|
@@ -338,14 +339,6 @@ export default class Posting extends React.Component {
|
|
|
338
339
|
let i = 0;
|
|
339
340
|
for (let imageObject of this.state.postingAd.images) {
|
|
340
341
|
if (imageObject.photo.url) {
|
|
341
|
-
if (imageObject.photo.extension === 'heic' || imageObject.photo.extension === 'heif') {
|
|
342
|
-
const manipResult = await manipulateAsync(
|
|
343
|
-
imageObject.photo.url.uri, [], {}
|
|
344
|
-
);
|
|
345
|
-
|
|
346
|
-
imageObject.photo.url.uri = manipResult.uri;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
342
|
formData.append('photo' + i, {
|
|
350
343
|
uri: imageObject.photo.url.uri,
|
|
351
344
|
name: imageObject.photo.fileName ? imageObject.photo.fileName : 'photo_' + i + '.' + imageObject.photo.extension,
|
|
@@ -398,14 +391,19 @@ export default class Posting extends React.Component {
|
|
|
398
391
|
}
|
|
399
392
|
}
|
|
400
393
|
|
|
401
|
-
_showLoading() {
|
|
394
|
+
async _showLoading() {
|
|
402
395
|
this.setState({ isLoading: true });
|
|
403
396
|
}
|
|
404
397
|
|
|
405
|
-
_hideLoading() {
|
|
398
|
+
async _hideLoading() {
|
|
399
|
+
await this.sleep(500);
|
|
406
400
|
this.setState({ isLoading: false });
|
|
407
401
|
}
|
|
408
402
|
|
|
403
|
+
sleep = (ms) => {
|
|
404
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
405
|
+
}
|
|
406
|
+
|
|
409
407
|
_openPictureSelector() {
|
|
410
408
|
this.setState({ showImageBrowser: true })
|
|
411
409
|
}
|
|
@@ -414,7 +412,7 @@ export default class Posting extends React.Component {
|
|
|
414
412
|
await this.setState({ showImageBrowser: false });
|
|
415
413
|
|
|
416
414
|
for (let photo of photos) {
|
|
417
|
-
this.publish4Screen.loadImage(photo
|
|
415
|
+
this.publish4Screen.loadImage(photo);
|
|
418
416
|
}
|
|
419
417
|
}
|
|
420
418
|
|
|
@@ -429,7 +427,7 @@ export default class Posting extends React.Component {
|
|
|
429
427
|
_savePicture = async (picture) => {
|
|
430
428
|
await this.setState({ showImageBrowser: false })
|
|
431
429
|
this.setState({ view: Views.PUBLISH_4 }, () => {
|
|
432
|
-
this.publish4Screen.loadImage(picture
|
|
430
|
+
this.publish4Screen.loadImage(picture);
|
|
433
431
|
})
|
|
434
432
|
}
|
|
435
433
|
|
|
@@ -447,7 +445,7 @@ export default class Posting extends React.Component {
|
|
|
447
445
|
:
|
|
448
446
|
null}
|
|
449
447
|
|
|
450
|
-
<PopupPermissions ref={(element) => this.popupPermissions = element} camera={true} mediaLibrary={true} message={strings('setup.permissionsMessage')}
|
|
448
|
+
<PopupPermissions ref={(element) => this.popupPermissions = element} camera={true} mediaLibrary={true} message={strings('setup.permissionsMessage')} onClose={this.loadData} />
|
|
451
449
|
|
|
452
450
|
{this.state.fontLoaded ?
|
|
453
451
|
<View style={[this.props.containerStyle, this.state.showImageBrowser ? commonStyles.displayNone : '']}>
|
package/Publish1.js
CHANGED
|
@@ -23,26 +23,30 @@ export default class Publish1 extends React.Component {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
async
|
|
27
|
-
this.props.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
componentDidUpdate = async (prevProps) => {
|
|
27
|
+
if (!prevProps.showView && this.props.showView && !this.state.viewLoaded) {
|
|
28
|
+
this.props.showLoading();
|
|
29
|
+
this.setState({
|
|
30
|
+
viewLoaded: true
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const responseJson = await this.props.request(this.props.context, GET_CATEGORIES, {
|
|
34
|
+
userEmail: this.props.postingAd.userEmail
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (responseJson.success) {
|
|
38
|
+
this.jsonCategories = responseJson.categoryList;
|
|
39
|
+
this.props.postingAd.category = this.props.postingAd.category != null ? this.props.postingAd.category : this.jsonCategories[0].value;
|
|
40
|
+
this.props.postingAd.subCategory = this.props.postingAd.subCategory != null ? this.props.postingAd.subCategory : this.jsonCategories[0].subCategoryList[0].value;
|
|
41
|
+
|
|
42
|
+
await this.setState({
|
|
43
|
+
transactionOptions: { elements: this.jsonCategories.map(jsonCategory => { return { label: jsonCategory.label, value: jsonCategory.value } }), selectedItem: this.props.postingAd.category },
|
|
44
|
+
typeBienOptions: { elements: this.getSubCategories(this.props.postingAd.category), selectedItem: this.props.postingAd.subCategory }
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
this.props.hideLoading();
|
|
41
48
|
}
|
|
42
|
-
this.props.hideLoading();
|
|
43
|
-
}
|
|
44
49
|
|
|
45
|
-
componentDidUpdate = (prevProps) => {
|
|
46
50
|
const componentsHeight = this.props.headerHeight + this.props.progressBarHeight;
|
|
47
51
|
const minHeight = window.height - componentsHeight;
|
|
48
52
|
if (this.state.minHeight != minHeight) {
|
package/Publish2.js
CHANGED
|
@@ -34,7 +34,6 @@ export default class Publish2 extends React.Component {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
if (!prevProps.showView && this.props.showView && !this.state.viewLoaded) {
|
|
37
|
-
this.props.showLoading();
|
|
38
37
|
this.setState({
|
|
39
38
|
viewLoaded: true
|
|
40
39
|
});
|
|
@@ -54,7 +53,6 @@ export default class Publish2 extends React.Component {
|
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
async validateLocation() {
|
|
57
|
-
this.props.showLoading();
|
|
58
56
|
let validateLocation = false;
|
|
59
57
|
|
|
60
58
|
this._changeMapLocation(await this.map.getPosition());
|
|
@@ -98,8 +96,6 @@ export default class Publish2 extends React.Component {
|
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
|
|
101
|
-
this.props.hideLoading();
|
|
102
|
-
|
|
103
99
|
return validateLocation;
|
|
104
100
|
}
|
|
105
101
|
|
package/Publish4.js
CHANGED
|
@@ -3,7 +3,6 @@ import { Text, View, TouchableHighlight, TouchableOpacity, ImageBackground, Dime
|
|
|
3
3
|
import PopupAdvice from 'muba-popup-advice';
|
|
4
4
|
import { strings } from 'muba-i18n';
|
|
5
5
|
import commonStyles from './commonStyles';
|
|
6
|
-
import { canOpenCamera } from './utils/Common.js';
|
|
7
6
|
import { Views } from './utils/Views';
|
|
8
7
|
import { createIconSetFromFontello } from 'react-native-vector-icons';
|
|
9
8
|
import fontelloConfig from './fonts/config.json';
|
|
@@ -47,11 +46,13 @@ export default class Publish4 extends React.Component {
|
|
|
47
46
|
|
|
48
47
|
async loadImage(imgUri) {
|
|
49
48
|
if (imgUri) {
|
|
49
|
+
let extension = imgUri.substring(imgUri.lastIndexOf('.') + 1).toLowerCase();
|
|
50
|
+
|
|
50
51
|
const image = {
|
|
51
52
|
photo: {
|
|
52
53
|
id: 0,
|
|
53
54
|
url: { uri: imgUri },
|
|
54
|
-
extension:
|
|
55
|
+
extension: extension
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muba-posting",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7",
|
|
4
4
|
"description": "Posting",
|
|
5
5
|
"main": "Posting.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"homepage": "https://github.com/Mubawab/muba-posting#readme",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@react-native-async-storage/async-storage": "~1.15.0",
|
|
21
|
-
"expo-image-manipulator": "~10.2.0",
|
|
22
21
|
"muba-custom-scroll-view": "4",
|
|
23
22
|
"muba-display-price": "4",
|
|
24
23
|
"muba-font": "4",
|