muba-posting 4.0.7 → 4.1.2

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/EditHead.js CHANGED
@@ -7,10 +7,10 @@ export default class EditHead extends React.Component {
7
7
  super(props);
8
8
 
9
9
  let mainPictureUrl = null;
10
- let mainPicture = this.props.postingAd?.images.filter(item => item.photo.mainPicture === true)[0];
10
+ let mainPicture = this.props.postingAd?.images.filter(item => item.mainPicture === true)[0];
11
11
 
12
12
  if (mainPicture !== undefined) {
13
- mainPictureUrl = mainPicture.photo.url;
13
+ mainPictureUrl = mainPicture.uri;
14
14
  }
15
15
 
16
16
  this.state = {
@@ -21,10 +21,10 @@ export default class EditHead extends React.Component {
21
21
  componentDidUpdate(prevProps) {
22
22
  if (!this.isSameList(prevProps.postingAd.images, this.props.postingAd.images)) {
23
23
  let mainPictureUrl = '';
24
- let mainPicture = this.props.postingAd.images.filter(item => item.photo.mainPicture === true)[0];
24
+ let mainPicture = this.props.postingAd.images.filter(item => item.mainPicture === true)[0];
25
25
 
26
26
  if (mainPicture !== undefined) {
27
- mainPictureUrl = mainPicture.photo.url;
27
+ mainPictureUrl = mainPicture.uri;
28
28
  }
29
29
  this.setState({ mainPictureUrl: mainPictureUrl })
30
30
  }
@@ -44,7 +44,7 @@ export default class EditHead extends React.Component {
44
44
 
45
45
  render() {
46
46
  return (
47
- <ImageBackground style={{ width: '100%' }} source={this.state.mainPictureUrl} resizeMode='cover'>
47
+ <ImageBackground style={{ width: '100%' }} source={{ uri: this.state.mainPictureUrl }} resizeMode='cover'>
48
48
  <View style={commonStyles.editBar}>
49
49
  {this.props.postingAd.reference && this.props.postingAd.reference != '' ?
50
50
  <View style={commonStyles.editRef}>
@@ -7,8 +7,8 @@ import Icon from '@expo/vector-icons/FontAwesome';
7
7
  import { strings } from 'muba-i18n';
8
8
  import commonStyles from './commonStyles';
9
9
 
10
- export const PROMOTE_AD = '/api/posting/PromoteAd';
11
- const GET_COUNTRY_PHONE = '/api/common/GetCountryPhone';
10
+ export const PROMOTE_AD = { method: 'PUT', url: '/controller/ad/{adId}/promote' };
11
+ const COUNTRY_PHONE = { method: 'GET', url: '/controller/countries/{countryCode}/phones' };
12
12
 
13
13
  export default class PopupSpendProduct extends React.Component {
14
14
  constructor(props) {
@@ -21,9 +21,9 @@ export default class PopupSpendProduct extends React.Component {
21
21
  }
22
22
 
23
23
  async componentDidMount() {
24
- const resultJson = await this.props.request(this, GET_COUNTRY_PHONE);
25
- if (resultJson.success) {
26
- this.setState({ countryPhone: resultJson.countryPhones[0].formattedPhone });
24
+ const resultJson = await this.props.request(this, COUNTRY_PHONE);
25
+ if (resultJson.status === 200) {
26
+ this.setState({ countryPhone: resultJson.list[0].formattedPhone });
27
27
  }
28
28
  }
29
29
 
@@ -42,7 +42,7 @@ export default class PopupSpendProduct extends React.Component {
42
42
  });
43
43
 
44
44
  this.props.hideLoading();
45
- if (responseJson.success && responseJson.remaining >= -1) {
45
+ if (responseJson.status === 200 && responseJson.remaining >= -1) {
46
46
  if (responseJson.remaining > -1) {
47
47
  result = 1;
48
48
  }
@@ -65,7 +65,7 @@ export default class PopupSpendProduct extends React.Component {
65
65
  });
66
66
 
67
67
  this.props.hideLoading();
68
- if (responseJson.success && responseJson.remaining >= -1) {
68
+ if (responseJson.status === 200 && responseJson.remaining >= -1) {
69
69
  if (responseJson.remaining > -1) {
70
70
  result = 1;
71
71
  }
package/Posting.js CHANGED
@@ -21,17 +21,18 @@ import Preview from './Preview';
21
21
  import PublishProgressBar from './PublishProgressBar.js';
22
22
  import EditHead from './EditHead.js';
23
23
  import PictureSelector from 'muba-picture';
24
- import ProgressBar from './shared/ProgressBar.js';
25
24
  import PopupPermissions from 'muba-popup-permissions';
26
25
  import { createIconSetFromFontello } from 'react-native-vector-icons';
27
26
  import fontelloConfig from './fonts/config.json';
28
27
  const FontAwesomeIcon = createIconSetFromFontello(fontelloConfig);
29
28
 
30
- const SET_AD = '/api/posting/SetAd';
31
- const GET_AD = '/api/posting/GetPostingAd';
32
- const GET_BUSINESS_PRODUCTS = '/api/posting/GetBusinessProducts';
33
- const GET_MAX_PICTURES = '/api/posting/GetMaxPictures';
34
- const GET_COUNTRY_PHONE = '/api/common/GetCountryPhone';
29
+ const CREATE_AD = { method: 'POST', url: '/controller/ads' };
30
+ const UPDATE_AD = { method: 'PUT', url: '/controller/ads/{adId}' };
31
+ const AD = { method: 'GET', url: '/controller/ads/{adId}/posting' };
32
+ const BUSINESS_ID = { method: 'GET', url: '/controller/users/{userId}/businessId' };
33
+ const BUSINESS_PRODUCTS = { method: 'GET', url: '/controller/products/{key}/remaining' };
34
+ const MAX_PICTURES = { method: 'GET', url: '/controller/max-pictures' };
35
+ const COUNTRY_PHONE = { method: 'GET', url: '/controller/countries/{countryCode}/phones' };
35
36
 
36
37
  export default class Posting extends React.Component {
37
38
  constructor(props) {
@@ -46,10 +47,10 @@ export default class Posting extends React.Component {
46
47
  });
47
48
 
48
49
  this.state = {
49
- loading: false,
50
50
  progress: 0,
51
51
  view: null,
52
52
  originView: this.props.adId ? Views.EDIT_SELECTOR : Views.PUBLISH_1,
53
+ fullPosting: this.props.adId == null,
53
54
  prevViews: [],
54
55
  currentScreen: 1,
55
56
  fontLoaded: false,
@@ -65,10 +66,11 @@ export default class Posting extends React.Component {
65
66
  category: null,
66
67
  subCategory: null,
67
68
  subCategoryDetails: [],
68
- isExactlyLocated: true,
69
+ exactlyLocated: true,
69
70
  latitude: null,
70
71
  longitude: null,
71
72
  address: null,
73
+ country: this.props.country,
72
74
  region: null,
73
75
  city: null,
74
76
  district: null,
@@ -115,7 +117,6 @@ export default class Posting extends React.Component {
115
117
  internet: false,
116
118
  phones: this.props.phones ? this.props.phones.includes('###') ? this.props.phones.split('###') : Array.isArray(this.props.phones) ? this.props.phones : [this.props.phones] : [],
117
119
  reference: null,
118
- mail: null,
119
120
  id: null,
120
121
  languageId: currentLocale().toUpperCase(),
121
122
  languages: [{ language: currentLocale().toUpperCase(), title: null, description: null, automatic: true }],
@@ -157,7 +158,6 @@ export default class Posting extends React.Component {
157
158
  }
158
159
  ]);
159
160
  this.setState({ fontLoaded: true });
160
-
161
161
  this.popupPermissions.open();
162
162
  }
163
163
 
@@ -183,12 +183,13 @@ export default class Posting extends React.Component {
183
183
 
184
184
  loadData = async (canPublish) => {
185
185
  if (canPublish) {
186
- const resultJson = await this.props.request(this, GET_COUNTRY_PHONE);
187
- if (resultJson.success) {
188
- this.setState({ countryPhone: resultJson.countryPhones[0].formattedPhone });
186
+ const resultJson = await this.props.request(this, COUNTRY_PHONE, { code: this.props.country });
187
+ if (resultJson.status === 200) {
188
+ this.setState({ countryPhone: resultJson.list[0].formattedPhone });
189
189
  }
190
190
 
191
191
  this.getMaxPictures();
192
+ this.readBusinessId();
192
193
  const hasListings = await this.checkListings();
193
194
  if (this.state.adId != null) {
194
195
  this.setState({ view: this.state.originView });
@@ -227,18 +228,23 @@ export default class Posting extends React.Component {
227
228
  }
228
229
 
229
230
  async checkListings() {
230
- const response = await this.props.request(this, GET_BUSINESS_PRODUCTS, {});
231
- this.setState({
232
- businessId: response.businessId
233
- })
231
+ const response = await this.props.request(this, BUSINESS_PRODUCTS, { key: 'LISTING' });
232
+ return response > 0;
233
+ }
234
234
 
235
- return response.success && response.listings > 0;
235
+ async readBusinessId() {
236
+ const response = await this.props.request(this, BUSINESS_ID, { userId: this.props.userId });
237
+ if (response.status !== 404) {
238
+ this.setState({
239
+ businessId: response
240
+ });
241
+ }
236
242
  }
237
243
 
238
244
  async getMaxPictures() {
239
- const response = await this.props.request(this, GET_MAX_PICTURES, {});
245
+ const response = await this.props.request(this, MAX_PICTURES, {});
240
246
  this.setState({
241
- maxPictures: response.maxPictures
247
+ maxPictures: response
242
248
  })
243
249
  }
244
250
 
@@ -255,6 +261,15 @@ export default class Posting extends React.Component {
255
261
 
256
262
  prevViews.unshift(this.state.view);
257
263
 
264
+ if (!this.state.postingAd.id && this.state.postingAd.town) {
265
+ const response = await this.props.request(this, CREATE_AD, this.state.postingAd);
266
+ if (response.status === 200) {
267
+ await this.setState({
268
+ postingAd: { ...this.state.postingAd, id: response.id }
269
+ })
270
+ }
271
+ }
272
+
258
273
  await this.setState({ prevViews: prevViews, editingStepOne: editingStepOne });
259
274
  await this._updateCurrentScreen(view, params);
260
275
  }
@@ -332,62 +347,23 @@ export default class Posting extends React.Component {
332
347
  }
333
348
 
334
349
  async _saveEditAd() {
335
- this.setState({ loading: true });
336
-
337
- const formData = new FormData();
338
-
339
- let i = 0;
340
- for (let imageObject of this.state.postingAd.images) {
341
- if (imageObject.photo.url) {
342
- formData.append('photo' + i, {
343
- uri: imageObject.photo.url.uri,
344
- name: imageObject.photo.fileName ? imageObject.photo.fileName : 'photo_' + i + '.' + imageObject.photo.extension,
345
- type: 'image/jpeg'
346
- });
347
- if (imageObject.photo.id !== 0) {
348
- formData.append('photo' + i + 'Id', imageObject.photo.id);
349
- }
350
- formData.append('photo' + i + 'ReferenceType', 'AD');
351
- formData.append('photo' + i + 'ReferenceId', this.state.adId);
352
- formData.append('photo' + i + 'ExtraInfo', i);
353
- i++;
350
+ const response = await this.props.request(this, UPDATE_AD, { ...this.state.postingAd, id: { adId: this.state.postingAd.id } });
351
+ if (this.props.adId) {
352
+ if (this.state.originView === Views.EDIT_SELECTOR) {
353
+ this.setState({ isLoading: true });
354
+ await this.loadAd();
355
+ this.editSelector.refresh();
356
+ this._goToPage(Views.EDIT_SELECTOR);
357
+ } else {
358
+ this.props.navigation.goBack();
354
359
  }
360
+ } else {
361
+ await this.setState({ postingAd: { ...this.state.postingAd, adId: response.id } });
362
+ this._goToPage(Views.PREVIEW, null, response);
355
363
  }
356
364
 
357
- this.props.request(this, SET_AD, this.state.postingAd, formData,
358
- this.updateProgress.bind(this),
359
- async (responseJson) => {
360
- await this.setState({ loading: false, progress: 0 });
361
-
362
- if (responseJson.success) {
363
- if (this.props.adId) {
364
- if (this.state.originView === Views.EDIT_SELECTOR) {
365
- this.setState({ isLoading: true });
366
- await this.loadAd();
367
- this.editSelector.refresh();
368
- this._goToPage(Views.EDIT_SELECTOR);
369
- } else {
370
- this.props.navigation.goBack();
371
- }
372
- } else {
373
- await this.setState({ postingAd: { ...this.state.postingAd, adId: responseJson.adId } });
374
- this._goToPage(Views.PREVIEW, null, responseJson);
375
- }
376
-
377
- if (this.props.showRatingPopup) {
378
- this.props.showRatingPopup();
379
- }
380
- }
381
- });
382
- }
383
-
384
- updateProgress(oEvent) {
385
- if (oEvent.lengthComputable) {
386
- var progress = oEvent.loaded / oEvent.total;
387
- var picturesUploaded = Math.round(this.state.postingAd.images.length * progress);
388
- this.setState({ progress: progress, picturesUploaded: picturesUploaded });
389
- } else {
390
- // Unable to compute progress information since the total size is unknown
365
+ if (this.props.showRatingPopup) {
366
+ this.props.showRatingPopup();
391
367
  }
392
368
  }
393
369
 
@@ -417,7 +393,7 @@ export default class Posting extends React.Component {
417
393
  }
418
394
 
419
395
  getAd = async (id) => {
420
- const responseJson = await this.props.request(this, GET_AD, {
396
+ const responseJson = await this.props.request(this, AD, {
421
397
  adId: id
422
398
  });
423
399
 
@@ -470,6 +446,7 @@ export default class Posting extends React.Component {
470
446
  showLoading={() => this._showLoading()}
471
447
  hideLoading={() => this._hideLoading()}
472
448
  scroll={(ref) => this.scroll.scrollIntoView(ref)}
449
+ fullPosting={this.state.fullPosting}
473
450
  goToPage={(view, editingStepOne) => this._goToPage(view, editingStepOne)}
474
451
  saveEditAd={() => this._saveEditAd()}
475
452
  showView={this.state.view === Views.PUBLISH_1}
@@ -488,6 +465,7 @@ export default class Posting extends React.Component {
488
465
  hideLoading={() => this._hideLoading()}
489
466
  hereAppId={this.props.hereAppId} hereAppCode={this.props.hereAppCode}
490
467
  showView={this.state.view === Views.PUBLISH_2}
468
+ fullPosting={this.state.fullPosting}
491
469
  progressBarHeight={this.state.progressBarHeight}
492
470
  headerHeight={this.state.headerHeight} />
493
471
 
@@ -502,6 +480,7 @@ export default class Posting extends React.Component {
502
480
  showLoading={() => this._showLoading()}
503
481
  hideLoading={() => this._hideLoading()}
504
482
  showView={this.state.view === Views.PUBLISH_2_B}
483
+ fullPosting={this.state.fullPosting}
505
484
  progressBarHeight={this.state.progressBarHeight}
506
485
  headerHeight={this.state.headerHeight} />
507
486
 
@@ -517,6 +496,7 @@ export default class Posting extends React.Component {
517
496
  showLoading={() => this._showLoading()}
518
497
  hideLoading={() => this._hideLoading()}
519
498
  showView={this.state.view === Views.PUBLISH_3}
499
+ fullPosting={this.state.fullPosting}
520
500
  progressBarHeight={this.state.progressBarHeight}
521
501
  headerHeight={this.state.headerHeight} />
522
502
 
@@ -529,6 +509,7 @@ export default class Posting extends React.Component {
529
509
  showLoading={() => this._showLoading()}
530
510
  hideLoading={() => this._hideLoading()}
531
511
  showView={this.state.view === Views.PUBLISH_4}
512
+ fullPosting={this.state.fullPosting}
532
513
  progressBarHeight={this.state.progressBarHeight}
533
514
  headerHeight={this.state.headerHeight}
534
515
  openPictureSelector={() => this._openPictureSelector()}
@@ -544,6 +525,7 @@ export default class Posting extends React.Component {
544
525
  showLoading={() => this._showLoading()}
545
526
  hideLoading={() => this._hideLoading()}
546
527
  showView={this.state.view === Views.PUBLISH_5}
528
+ fullPosting={this.state.fullPosting}
547
529
  progressBarHeight={this.state.progressBarHeight}
548
530
  headerHeight={this.state.headerHeight} />
549
531
 
@@ -558,6 +540,7 @@ export default class Posting extends React.Component {
558
540
  showLoading={() => this._showLoading()}
559
541
  hideLoading={() => this._hideLoading()}
560
542
  showView={this.state.view === Views.PUBLISH_6}
543
+ fullPosting={this.state.fullPosting}
561
544
  progressBarHeight={this.state.progressBarHeight}
562
545
  headerHeight={this.state.headerHeight} />
563
546
 
@@ -579,16 +562,6 @@ export default class Posting extends React.Component {
579
562
  topBar={this.props.topBar}
580
563
  goToPage={(view) => this._goToPage(view)} />
581
564
 
582
- <ProgressBar loading={this.state.loading} progress={(this.state.progress * 100).toFixed(0)}>
583
- <View style={commonStyles.loadingPicturesNote}>
584
- {this.state.picturesUploaded == this.state.postingAd.images.length ?
585
- <Text style={commonStyles.mapNoteText}>{strings('setup.savingAd')}</Text>
586
- :
587
- <Text style={commonStyles.mapNoteText}>{strings('setup.uploadingPicture')} {this.state.picturesUploaded} / {this.state.postingAd.images.length}</Text>
588
- }
589
- </View>
590
- </ProgressBar>
591
-
592
565
  </CustomScrollView>
593
566
  <PopupAdvice icon={<FontAwesomeIcon name='block' />} title={strings('setup.noPromoteTitle', { product: '' })} headerColor={commonStyles.red} ref={(popupAdvice) => { this.popupNoListings = popupAdvice; }}
594
567
  onClose={async () => this.state.view !== Views.PREVIEW ? this.goBack() : null} hideButton={true}>
package/PostingEdit.js CHANGED
@@ -10,12 +10,12 @@ export default class PostingEdit extends React.Component {
10
10
  super(props);
11
11
 
12
12
  this.state = {
13
- showFunctionalities: null
13
+ showFunctionalities: this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0
14
14
  };
15
15
  }
16
16
 
17
17
  componentDidUpdate = (prevProps) => {
18
- if (prevProps.postingAd.adId !== this.props.postingAd.adId) {
18
+ if (prevProps.postingAd.id !== this.props.postingAd.id) {
19
19
  this.refresh();
20
20
  }
21
21
  }
@@ -27,7 +27,7 @@ export default class PostingEdit extends React.Component {
27
27
  }
28
28
 
29
29
  navigateToPublish2() {
30
- if (this.props.postingAd.isExactlyLocated) {
30
+ if (this.props.postingAd.exactlyLocated) {
31
31
  this.props.goToPage(Views.PUBLISH_2);
32
32
  } else {
33
33
  this.props.goToPage(Views.PUBLISH_2_B);
package/Preview.js CHANGED
@@ -198,7 +198,7 @@ export default class Preview extends React.Component {
198
198
  </View>
199
199
  </View>
200
200
  : null}
201
- <PopupSpendProduct adId={this.props.postingAd.adId} ref={(popupShowAdvice) => { this.popupShowAdvice = popupShowAdvice }} businessId={this.props.businessId} request={this.props.request}
201
+ <PopupSpendProduct adId={this.props.postingAd.id} ref={(popupShowAdvice) => { this.popupShowAdvice = popupShowAdvice }} businessId={this.props.businessId} request={this.props.request}
202
202
  showLoading={this.props.showLoading} hideLoading={this.props.hideLoading} />
203
203
  </View>
204
204
  );
package/Publish1.js CHANGED
@@ -6,7 +6,7 @@ import RadioButtonGroup from 'muba-radio-button-group';
6
6
  import { Views } from './utils/Views';
7
7
  const window = Dimensions.get('window');
8
8
 
9
- const GET_CATEGORIES = '/api/common/GetPostingCategories';
9
+ const GET_CATEGORIES = { method: 'GET', url: '/controller/categories' };
10
10
 
11
11
  export default class Publish1 extends React.Component {
12
12
  constructor(props) {
@@ -31,11 +31,11 @@ export default class Publish1 extends React.Component {
31
31
  });
32
32
 
33
33
  const responseJson = await this.props.request(this.props.context, GET_CATEGORIES, {
34
- userEmail: this.props.postingAd.userEmail
34
+ userId: this.props.postingAd.userId
35
35
  });
36
36
 
37
- if (responseJson.success) {
38
- this.jsonCategories = responseJson.categoryList;
37
+ if (responseJson.status === 200) {
38
+ this.jsonCategories = responseJson.list;
39
39
  this.props.postingAd.category = this.props.postingAd.category != null ? this.props.postingAd.category : this.jsonCategories[0].value;
40
40
  this.props.postingAd.subCategory = this.props.postingAd.subCategory != null ? this.props.postingAd.subCategory : this.jsonCategories[0].subCategoryList[0].value;
41
41
 
@@ -113,8 +113,8 @@ export default class Publish1 extends React.Component {
113
113
  }
114
114
  }
115
115
 
116
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
117
- if (this.props.postingAd.isExactlyLocated) {
116
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
117
+ if (this.props.postingAd.exactlyLocated) {
118
118
  this.props.goToPage(Views.PUBLISH_2);
119
119
  } else {
120
120
  this.props.goToPage(Views.PUBLISH_2_B);
@@ -166,7 +166,7 @@ export default class Publish1 extends React.Component {
166
166
  <View style={commonStyles.buttomButton}>
167
167
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
168
168
  <Text style={commonStyles.actionButtonText}>
169
- {this.props.postingAd.adId == null || this.props.fullPosting || this.oldCategory != this.state.transactionOptions.selectedItem || this.oldSubCategory != this.state.typeBienOptions.selectedItem ?
169
+ {this.props.postingAd.id == null || this.props.fullPosting || this.oldCategory != this.state.transactionOptions.selectedItem || this.oldSubCategory != this.state.typeBienOptions.selectedItem ?
170
170
  strings('setup.next').toUpperCase()
171
171
  :
172
172
  strings('setup.enregistrer').toUpperCase()}
package/Publish2.js CHANGED
@@ -10,7 +10,7 @@ import fontelloConfig from './fonts/config.json';
10
10
  const FontAwesomeIcon = createIconSetFromFontello(fontelloConfig);
11
11
  const window = Dimensions.get('window');
12
12
 
13
- const GET_LOCATION_FROM_COORDINATES = '/api/common/GetLocationFromCoordinates';
13
+ const GET_LOCATION_FROM_COORDINATES = { method: 'GET', url: '/controller/location' };
14
14
 
15
15
  export default class Publish2 extends React.Component {
16
16
  constructor(props) {
@@ -42,7 +42,7 @@ export default class Publish2 extends React.Component {
42
42
 
43
43
  async nextStep() {
44
44
  if (await this.validateLocation()) {
45
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
45
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
46
46
  this.props.goToPage(Views.PUBLISH_3);
47
47
  } else {
48
48
  this.props.saveEditAd()
@@ -63,11 +63,11 @@ export default class Publish2 extends React.Component {
63
63
  });
64
64
 
65
65
  if (responseJson.success) {
66
- if (responseJson.isExactlyLocated) {
67
- this.props.postingAd.isExactlyLocated = true;
66
+ if (responseJson.exactlyLocated) {
67
+ this.props.postingAd.exactlyLocated = true;
68
68
  validateLocation = true;
69
69
  } else {
70
- this.props.postingAd.isExactlyLocated = false;
70
+ this.props.postingAd.exactlyLocated = false;
71
71
  }
72
72
 
73
73
  if (responseJson.region !== undefined) {
@@ -131,9 +131,9 @@ export default class Publish2 extends React.Component {
131
131
  : null}
132
132
  <View style={commonStyles.buttomButton} onLayout={this.onLayout}>
133
133
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
134
- <Text style={commonStyles.actionButtonText}>{this.props.postingAd.adId == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
134
+ <Text style={commonStyles.actionButtonText}>{this.props.postingAd.id == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
135
135
  </TouchableHighlight>
136
- <TouchableHighlight underlayColor="rgba(0,0,0,0)" onPress={() => { this.props.postingAd.isExactlyLocated = false; this.props.replacePage(Views.PUBLISH_2_B) }}>
136
+ <TouchableHighlight underlayColor="rgba(0,0,0,0)" onPress={() => { this.props.postingAd.exactlyLocated = false; this.props.replacePage(Views.PUBLISH_2_B) }}>
137
137
  <Text style={[commonStyles.carteNote, commonStyles.carteNoteMap]}>{strings('setup.notUseMap')}</Text>
138
138
  </TouchableHighlight>
139
139
  </View>
package/Publish2b.js CHANGED
@@ -7,7 +7,10 @@ import InputText from 'muba-input-text';
7
7
  import { Views } from './utils/Views';
8
8
  const window = Dimensions.get('window');
9
9
 
10
- const GET_LOCATIONS = '/api/common/GetLocations';
10
+ const GET_REGIONS = { method: 'GET', url: '/controller/countries/{countryCode}/regions' };
11
+ const GET_CITIES_FROM_REGION = { method: 'GET', url: '/controller/regions/{regionId}/cities' };
12
+ const GET_DISTRICTS_FROM_CITY = { method: 'GET', url: '/controller/cities/{cityId}/districts' };
13
+ const GET_TOWNS_FROM_DISTRICT = { method: 'GET', url: '/controller/districts/{districtId}/towns' };
11
14
 
12
15
  export default class Publish2b extends React.Component {
13
16
  constructor(props) {
@@ -89,17 +92,15 @@ export default class Publish2b extends React.Component {
89
92
 
90
93
  async loadRegions() {
91
94
  if (this.state.regionOptions.elements.length <= 1) {
92
- const responseJson = await this.props.request(this.props.context, GET_LOCATIONS, {
93
- locationLevel: '1'
94
- });
95
+ const responseJson = await this.props.request(this.props.context, GET_REGIONS, {});
95
96
 
96
- if (responseJson.success) {
97
+ if (responseJson.status === 200) {
97
98
  const regionOptions = {
98
99
  elements: [this.state.regionOptions.elements[0]],
99
100
  selectedItem: this.props.postingAd.region
100
101
  };
101
102
 
102
- responseJson.resultList.map((item) => {
103
+ responseJson.list.map((item) => {
103
104
  regionOptions.elements.push(item);
104
105
  });
105
106
 
@@ -115,18 +116,17 @@ export default class Publish2b extends React.Component {
115
116
 
116
117
  this.props.postingAd.region = value;
117
118
 
118
- const responseJson = await this.props.request(this.props.context, GET_LOCATIONS, {
119
- locationLevel: '3',
120
- parentId: this.props.postingAd.region
119
+ const responseJson = await this.props.request(this.props.context, GET_CITIES_FROM_REGION, {
120
+ regionId: this.props.postingAd.region
121
121
  });
122
122
 
123
- if (responseJson.success) {
123
+ if (responseJson.status === 200) {
124
124
  var cityOptions = {
125
125
  elements: [this.state.cityOptions.elements[0]],
126
126
  selectedItem: null
127
127
  };
128
128
 
129
- responseJson.resultList.map((item) => {
129
+ responseJson.list.map((item) => {
130
130
  cityOptions.elements.push(item);
131
131
  });
132
132
 
@@ -153,30 +153,29 @@ export default class Publish2b extends React.Component {
153
153
 
154
154
  this.props.postingAd.city = value;
155
155
 
156
- const responseJson = await this.props.request(this.props.context, GET_LOCATIONS, {
157
- locationLevel: '4',
158
- parentId: this.props.postingAd.city
156
+ const responseJson = await this.props.request(this.props.context, GET_DISTRICTS_FROM_CITY, {
157
+ cityId: this.props.postingAd.city
159
158
  });
160
159
 
161
- if (responseJson.success) {
160
+ if (responseJson.status === 200) {
162
161
  let districtOptions = {
163
162
  elements: [this.state.districtOptions.elements[0]],
164
163
  selectedItem: null
165
164
  };
166
165
 
167
- responseJson.resultList.map((item) => {
166
+ responseJson.list.map((item) => {
168
167
  districtOptions.elements.push(item);
169
168
  });
170
169
 
171
- if (responseJson.resultList.length == 1) {
172
- districtOptions.selectedItem = responseJson.resultList[0].value;
170
+ if (responseJson.list.length == 1) {
171
+ districtOptions.selectedItem = responseJson.list[0].value;
173
172
  }
174
173
 
175
174
  await this.setState({ districtOptions: districtOptions });
176
175
  this.props.postingAd.district = null;
177
176
  this.props.postingAd.town = null;
178
177
 
179
- if (responseJson.resultList.length == 1) {
178
+ if (responseJson.list.length == 1) {
180
179
  this.inputSelectDistrict?.onSubmitValidate();
181
180
  await this.loadTowns(districtOptions.selectedItem);
182
181
  } else {
@@ -196,29 +195,28 @@ export default class Publish2b extends React.Component {
196
195
 
197
196
  this.props.postingAd.district = value;
198
197
 
199
- const responseJson = await this.props.request(this.props.context, GET_LOCATIONS, {
200
- locationLevel: '5',
201
- parentId: this.props.postingAd.district
198
+ const responseJson = await this.props.request(this.props.context, GET_TOWNS_FROM_DISTRICT, {
199
+ districtId: this.props.postingAd.district
202
200
  });
203
201
 
204
- if (responseJson.success) {
202
+ if (responseJson.status === 200) {
205
203
  var townOptions = {
206
204
  elements: [this.state.townOptions.elements[0]],
207
205
  selectedItem: null
208
206
  };
209
207
 
210
- responseJson.resultList.map((item) => {
208
+ responseJson.list.map((item) => {
211
209
  townOptions.elements.push(item);
212
210
  });
213
211
 
214
- if (responseJson.resultList.length == 1) {
215
- townOptions.selectedItem = responseJson.resultList[0].value;
212
+ if (responseJson.list.length == 1) {
213
+ townOptions.selectedItem = responseJson.list[0].value;
216
214
  this.props.postingAd.town = townOptions.selectedItem;
217
215
  }
218
216
 
219
217
  await this.setState({ townOptions: townOptions });
220
218
 
221
- if (responseJson.resultList.length == 1) {
219
+ if (responseJson.list.length == 1) {
222
220
  this.inputSelectTown?.onSubmitValidate();
223
221
  }
224
222
  }
@@ -230,7 +228,7 @@ export default class Publish2b extends React.Component {
230
228
 
231
229
  async nextStep() {
232
230
  if (this.validateForm()) {
233
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
231
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
234
232
  this.props.goToPage(Views.PUBLISH_3);
235
233
  } else {
236
234
  this.props.saveEditAd();
@@ -318,9 +316,9 @@ export default class Publish2b extends React.Component {
318
316
  </View>
319
317
  <View style={commonStyles.buttomButton}>
320
318
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
321
- <Text style={commonStyles.actionButtonText}>{this.props.postingAd.adId == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
319
+ <Text style={commonStyles.actionButtonText}>{this.props.postingAd.id == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
322
320
  </TouchableHighlight>
323
- <TouchableHighlight underlayColor="rgba(0,0,0,0)" onPress={() => { this.props.postingAd.isExactlyLocated = true; this.props.replacePage(Views.PUBLISH_2) }}>
321
+ <TouchableHighlight underlayColor="rgba(0,0,0,0)" onPress={() => { this.props.postingAd.exactlyLocated = true; this.props.replacePage(Views.PUBLISH_2) }}>
324
322
  <Text style={[commonStyles.carteNote, commonStyles.carteNoteMap]}>{strings('setup.useMap')}</Text>
325
323
  </TouchableHighlight>
326
324
  </View>
package/Publish3.js CHANGED
@@ -9,7 +9,7 @@ import InputText from 'muba-input-text';
9
9
  import { Views } from './utils/Views';
10
10
  const window = Dimensions.get('window');
11
11
 
12
- const GET_CURRENCIES = '/api/mubawabapp/GetCurrencyList';
12
+ const GET_CURRENCIES = { method: 'GET', url: '/controller/countries/{countryCode}/currencies' };
13
13
 
14
14
  export default class Publish3 extends React.Component {
15
15
  constructor(props) {
@@ -64,8 +64,8 @@ export default class Publish3 extends React.Component {
64
64
  const responseJson = await this.props.request(this.props.context, GET_CURRENCIES, {});
65
65
  const priceOptions = this.state.priceOptions;
66
66
 
67
- if (responseJson.success) {
68
- responseJson.currencyList.map((item) => {
67
+ if (responseJson.status === 200) {
68
+ responseJson.list.map((item) => {
69
69
  priceOptions.elements.push(item);
70
70
  });
71
71
  priceOptions.selectedItem = priceOptions.elements[1]?.value;
@@ -157,7 +157,7 @@ export default class Publish3 extends React.Component {
157
157
  this.props.postingAd.pricePeriod = null;
158
158
  }
159
159
 
160
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
160
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
161
161
  this.props.goToPage(Views.PUBLISH_4);
162
162
  } else {
163
163
  if (this.props.editingStepOne && this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0) {
@@ -385,7 +385,7 @@ export default class Publish3 extends React.Component {
385
385
  <View style={commonStyles.buttomButton}>
386
386
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
387
387
  <Text style={commonStyles.actionButtonText}>
388
- {this.props.postingAd.adId == null || this.props.fullPosting || (this.props.editingStepOne && this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0) ?
388
+ {this.props.postingAd.id == null || this.props.fullPosting || (this.props.editingStepOne && this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0) ?
389
389
  strings('setup.next').toUpperCase()
390
390
  :
391
391
  strings('setup.enregistrer').toUpperCase()}
package/Publish4.js CHANGED
@@ -46,14 +46,16 @@ export default class Publish4 extends React.Component {
46
46
 
47
47
  async loadImage(imgUri) {
48
48
  if (imgUri) {
49
- let extension = imgUri.substring(imgUri.lastIndexOf('.') + 1).toLowerCase();
49
+ let fileType = imgUri.substring(imgUri.lastIndexOf('.') + 1).toLowerCase();
50
50
 
51
51
  const image = {
52
- photo: {
53
- id: 0,
54
- url: { uri: imgUri },
55
- extension: extension
56
- }
52
+ uri: imgUri,
53
+ name: 'photo_' + this.props.postingAd.images.length + '.' + fileType,
54
+ type: 'image/' + fileType,
55
+ mainPicture: this.props.postingAd.images.length === 0,
56
+ referenceType: 'AD',
57
+ referenceId: this.props.postingAd.id,
58
+ extraInfo: this.props.postingAd.images.length
57
59
  }
58
60
 
59
61
  let imagesArray = this.props.postingAd.images;
@@ -71,11 +73,11 @@ export default class Publish4 extends React.Component {
71
73
  }
72
74
 
73
75
  async deleteImage(itemDeleted) {
74
- if (itemDeleted.photo.id) {
76
+ if (itemDeleted.id) {
75
77
  if (!this.props.postingAd.deletedPictures) {
76
78
  this.props.postingAd.deletedPictures = [];
77
79
  }
78
- this.props.postingAd.deletedPictures.push(itemDeleted.photo.id);
80
+ this.props.postingAd.deletedPictures.push(itemDeleted.id);
79
81
  }
80
82
 
81
83
  let filteredArray = this.props.postingAd.images.filter(item => item !== itemDeleted);
@@ -91,15 +93,22 @@ export default class Publish4 extends React.Component {
91
93
  let imagesArray = this.props.postingAd.images.slice();
92
94
 
93
95
  for (let imageObject of imagesArray) {
94
- imageObject.photo.mainPicture = false;
96
+ imageObject.mainPicture = false;
95
97
 
96
- if (imageObject.photo.url === itemSelected.photo.url) {
97
- imageObject.photo.mainPicture = true;
98
- this.props.postingAd.images.splice(this.props.postingAd.images.indexOf(imageObject), 1);
99
- this.props.postingAd.images.splice(0, 0, imageObject);
98
+ if (imageObject.uri === itemSelected.uri) {
99
+ imageObject.mainPicture = true;
100
+ imagesArray.splice(imagesArray.indexOf(imageObject), 1);
101
+ imagesArray.splice(0, 0, imageObject);
100
102
  }
101
103
  }
104
+ let index = 0;
105
+ for (let imageObject of imagesArray) {
106
+ imageObject.name = 'photo_' + index + (imageObject.id ? '_' + imageObject.id : '') + imageObject.name.substring(imageObject.name.indexOf('.'));
107
+ imageObject.extraInfo = index;
108
+ ++index;
109
+ }
102
110
 
111
+ this.props.postingAd.images = imagesArray;
103
112
  this.setState({ updateMainPhoto: true });
104
113
  }
105
114
 
@@ -108,8 +117,7 @@ export default class Publish4 extends React.Component {
108
117
  this.setState({ showErrorNoSelectedImages: true });
109
118
  } else {
110
119
  this.setState({ showErrorNoSelectedImages: false });
111
-
112
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
120
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
113
121
  if (this.props.postingAd.subCategoryDetails.filter(function (detail) { return detail.value == "floorType" }).length > 0) {
114
122
  this.props.goToPage(Views.PUBLISH_5);
115
123
  } else {
@@ -161,14 +169,14 @@ export default class Publish4 extends React.Component {
161
169
  }
162
170
  {this.props.postingAd.images.map((item, index) => {
163
171
  return (
164
- <ImageBackground style={[commonStyles.photoBox, commonStyles.photoBoxImage]} source={item.photo.url} borderRadius={10} key={index}>
172
+ <ImageBackground style={[commonStyles.photoBox, commonStyles.photoBoxImage]} source={{ uri: item.uri }} borderRadius={10} key={index}>
165
173
  <ImageBackground style={[commonStyles.photoControls, commonStyles.row]} source={require('./assets/images/bg-shadow.png')} resizeMode='stretch' borderRadius={1.5}>
166
174
 
167
175
  <TouchableHighlight style={commonStyles.leftIcon} onPress={() => this.deleteImage(item)}>
168
176
  <FontAwesomeIcon style={commonStyles.whiteIcon} name="cancel-circled" />
169
177
  </TouchableHighlight>
170
178
  <TouchableHighlight style={commonStyles.rightIcon} onPress={() => this.selectMainPhoto(item)}>
171
- <FontAwesomeIcon style={[commonStyles.heartIcon, item.photo.mainPicture ? '' : commonStyles.whiteIcon]} name={item.photo.mainPicture ? 'heart' : 'heart-empty'} />
179
+ <FontAwesomeIcon style={[commonStyles.heartIcon, item.mainPicture ? '' : commonStyles.whiteIcon]} name={item.mainPicture ? 'heart' : 'heart-empty'} />
172
180
  </TouchableHighlight>
173
181
 
174
182
  </ImageBackground>
@@ -187,7 +195,7 @@ export default class Publish4 extends React.Component {
187
195
  </View>
188
196
  <View style={commonStyles.buttomButton}>
189
197
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
190
- <Text style={commonStyles.actionButtonText}>{this.props.postingAd.adId == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
198
+ <Text style={commonStyles.actionButtonText}>{this.props.postingAd.id == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
191
199
  </TouchableHighlight>
192
200
  </View>
193
201
 
package/Publish5.js CHANGED
@@ -124,7 +124,7 @@ export default class Publish5 extends React.Component {
124
124
 
125
125
  nextStep() {
126
126
  if (this.validateForm()) {
127
- if (this.props.postingAd.adId == null || this.props.fullPosting) {
127
+ if (this.props.postingAd.id == null || this.props.fullPosting) {
128
128
  this.props.goToPage(Views.PUBLISH_6);
129
129
  } else {
130
130
  this.props.saveEditAd();
@@ -464,7 +464,7 @@ export default class Publish5 extends React.Component {
464
464
  <View style={commonStyles.buttomButton}>
465
465
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={() => this.nextStep()}>
466
466
  <Text style={commonStyles.actionButtonText}>
467
- {this.props.postingAd.adId == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}
467
+ {this.props.postingAd.id == null || this.props.fullPosting ? strings('setup.next').toUpperCase() : strings('setup.enregistrer').toUpperCase()}
468
468
  </Text>
469
469
  </TouchableHighlight>
470
470
  </View>
package/Publish6.js CHANGED
@@ -8,10 +8,10 @@ import PopupAdvice from 'muba-popup-advice';
8
8
  import { createIconSetFromFontello } from 'react-native-vector-icons';
9
9
  import fontelloConfig from './fonts/config.json';
10
10
  const FontAwesomeIcon = createIconSetFromFontello(fontelloConfig);
11
- const GET_GENERATE_TITLE_DESCRIPTION = '/api/posting/GetGeneratedAdTitleDescription';
12
- const GET_PHONE_REGISTERED = '/api/posting/GetPhoneRegistered';
11
+
12
+ const GENERATE_TITLE_DESCRIPTION = { method: 'POST', url: '/controller/generate-title-description' };
13
+ const PHONE_REGISTERED = { method: 'GET', url: '/controller/phone-registered' };
13
14
  const window = Dimensions.get('window');
14
- const OK_MESSAGE = 'ok';
15
15
  const PHONE_SEPARATOR = '###';
16
16
 
17
17
  let submitClicked;
@@ -74,10 +74,11 @@ export default class Publish6 extends React.Component {
74
74
  this.props.postingAd.languages[0].description === undefined || this.props.postingAd.languages[0].description === null) {
75
75
 
76
76
  this.props.showLoading();
77
+ const ad = { ...this.props.postingAd };
78
+ delete ad.images;
79
+ const responseJson = await this.props.request(this.props.context, GENERATE_TITLE_DESCRIPTION, ad);
77
80
 
78
- const responseJson = await this.props.request(this.props.context, GET_GENERATE_TITLE_DESCRIPTION, this.props.postingAd);
79
-
80
- if (responseJson.success) {
81
+ if (responseJson?.status === 200) {
81
82
  if (this.props.postingAd.languages[0].title === undefined || this.props.postingAd.languages[0].title === null) {
82
83
  this.props.postingAd.languages[0].title = responseJson.title;
83
84
  }
@@ -92,6 +93,7 @@ export default class Publish6 extends React.Component {
92
93
  } else {
93
94
  this.setState({ titleDescriptionLoaded: true });
94
95
  }
96
+ this.props.hideLoading();
95
97
  }
96
98
 
97
99
  async nextStep() {
@@ -117,19 +119,17 @@ export default class Publish6 extends React.Component {
117
119
  const phones = this.props.postingAd.phones.join(PHONE_SEPARATOR);
118
120
 
119
121
  const body = {
120
- adId: this.props.postingAd.adId,
122
+ adId: this.props.postingAd.id,
121
123
  userId: this.props.postingAd.userId,
122
- phone: phones
124
+ phones: phones
123
125
  };
124
126
 
127
+
125
128
  this.setState({ loading: true });
126
129
 
127
- const responseJson = await this.props.request(this.props.context, GET_PHONE_REGISTERED, body);
128
- if (responseJson.success) {
129
- const phoneFree = (responseJson.responseStatus === OK_MESSAGE);
130
- validate = phoneFree && validate;
131
- this.setState({ existingPhoneError: !phoneFree });
132
- }
130
+ const phoneFree = await this.props.request(this.props.context, PHONE_REGISTERED, body);
131
+ validate = phoneFree && validate;
132
+ this.setState({ existingPhoneError: !phoneFree });
133
133
 
134
134
  this.languageItem.forEach(element => validate = element.validateLanguageItem() && validate);
135
135
  }
@@ -228,7 +228,7 @@ export default class Publish6 extends React.Component {
228
228
  <Text style={commonStyles.legalNoteText}>{strings('setup.legalNote')}</Text>
229
229
  </View>
230
230
  <TouchableHighlight style={commonStyles.actionButton} underlayColor="#ff5d00" onPress={async () => this.nextStep()}>
231
- <Text style={commonStyles.actionButtonText}>{this.props.postingAd.adId == null || this.props.fullPosting ? strings('setup.publish').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
231
+ <Text style={commonStyles.actionButtonText}>{this.props.postingAd.id == null || this.props.fullPosting ? strings('setup.publish').toUpperCase() : strings('setup.enregistrer').toUpperCase()}</Text>
232
232
  </TouchableHighlight>
233
233
  </View>
234
234
  <PopupAdvice width={0.9} dialogStyle={commonStyles.popupBox} ref={(popupShowAdvice) => { this.popupShowAdvice = popupShowAdvice; }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muba-posting",
3
- "version": "4.0.7",
3
+ "version": "4.1.2",
4
4
  "description": "Posting",
5
5
  "main": "Posting.js",
6
6
  "scripts": {
@@ -1,177 +0,0 @@
1
- /** React Native Percentage Circle
2
- ** @github https://github.com/JackPu/react-native-percentage-circle
3
- ** React Native Version >=0.25
4
- ** to fixed react native version
5
- **/
6
-
7
- import React, { Component } from 'react';
8
- import {
9
- StyleSheet,
10
- View,
11
- Text,
12
- } from 'react-native';
13
-
14
- const styles = StyleSheet.create({
15
- circle: {
16
- overflow: 'hidden',
17
- position: 'relative',
18
- justifyContent: 'center',
19
- alignItems: 'center',
20
- backgroundColor: '#e3e3e3',
21
- },
22
- leftWrap: {
23
- overflow: 'hidden',
24
- position: 'absolute',
25
- top: 0,
26
- },
27
- rightWrap: {
28
- position: 'absolute',
29
-
30
- },
31
-
32
- loader: {
33
- position: 'absolute',
34
- left: 0,
35
- top: 0,
36
- borderRadius: 1000,
37
-
38
- },
39
-
40
- innerCircle: {
41
- overflow: 'hidden',
42
- position: 'relative',
43
- justifyContent: 'center',
44
- alignItems: 'center',
45
- },
46
- text: {
47
- fontSize: 11,
48
- color: '#888',
49
- },
50
- });
51
-
52
- class PercentageCircle extends Component {
53
- constructor(props) {
54
- super(props);
55
- let percent = this.props.percent;
56
- let leftTransformerDegree = '0deg';
57
- let rightTransformerDegree = '0deg';
58
- if (percent >= 50) {
59
- rightTransformerDegree = '180deg';
60
- leftTransformerDegree = (percent - 50) * 3.6 + 'deg';
61
- } else {
62
- rightTransformerDegree = percent * 3.6 + 'deg';
63
- leftTransformerDegree = '180deg';
64
- }
65
-
66
- this.state = {
67
- percent: this.props.percent,
68
- borderWidth: this.props.borderWidth < 2 || !this.props.borderWidth ? 2 : this.props.borderWidth,
69
- leftTransformerDegree: leftTransformerDegree,
70
- rightTransformerDegree: rightTransformerDegree,
71
- textStyle: this.props.textStyle ? this.props.textStyle : null
72
- };
73
- }
74
-
75
- componentDidUpdate = (prevProps) => {
76
- if (prevProps.percent !== this.props.percent) {
77
- const percent = this.props.percent;
78
- let leftTransformerDegree = '0deg';
79
- let rightTransformerDegree = '0deg';
80
- if (percent >= 50) {
81
- rightTransformerDegree = '180deg';
82
- leftTransformerDegree = (percent - 50) * 3.6 + 'deg';
83
- } else {
84
- rightTransformerDegree = percent * 3.6 + 'deg';
85
- leftTransformerDegree = "180deg";
86
- }
87
- this.setState({
88
- percent: percent,
89
- borderWidth: this.props.borderWidth < 2 || !this.props.borderWidth ? 2 : this.props.borderWidth,
90
- leftTransformerDegree: leftTransformerDegree,
91
- rightTransformerDegree: rightTransformerDegree
92
- });
93
- }
94
- }
95
-
96
- render() {
97
- if (this.props.disabled) {
98
- return (
99
- <View style={[styles.circle, {
100
- width: this.props.radius * 2,
101
- height: this.props.radius * 2,
102
- borderRadius: this.props.radius
103
- }]}>
104
- <Text style={styles.text}>{this.props.disabledText}</Text>
105
- </View>
106
- );
107
- }
108
- return (
109
- <View style={[styles.circle, {
110
- width: this.props.radius * 2,
111
- height: this.props.radius * 2,
112
- borderRadius: this.props.radius,
113
- backgroundColor: this.props.bgcolor
114
- }]}>
115
- <View style={[styles.leftWrap, {
116
- left: this.props.radius,
117
- width: this.props.radius,
118
- height: this.props.radius * 2,
119
- }]}>
120
- <View style={[styles.loader, {
121
- left: -this.props.radius,
122
- width: this.props.radius,
123
- height: this.props.radius * 2,
124
- borderTopRightRadius: 0,
125
- borderBottomRightRadius: 0,
126
- backgroundColor: this.props.color,
127
- transform: [{ translateX: this.props.radius / 2 }, { rotate: this.state.rightTransformerDegree }, { translateX: -this.props.radius / 2 }],
128
- }]}></View>
129
- </View>
130
-
131
-
132
- <View style={[styles.leftWrap, {
133
- width: this.props.radius,
134
- height: this.props.radius * 2,
135
- left: 0,
136
- }]}>
137
- <View style={[styles.loader, {
138
- left: this.props.radius,
139
- width: this.props.radius,
140
- height: this.props.radius * 2,
141
- borderTopLeftRadius: 0,
142
- borderBottomLeftRadius: 0,
143
- backgroundColor: this.props.percent >= 50 ? this.props.color : this.props.bgcolor, // changed this line
144
- transform: [{ translateX: -this.props.radius / 2 }, { rotate: this.state.leftTransformerDegree }, { translateX: this.props.radius / 2 }],
145
- }]}></View>
146
- </View>
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
- <View style={[styles.innerCircle, {
157
- width: (this.props.radius - this.state.borderWidth) * 2,
158
- height: (this.props.radius - this.state.borderWidth) * 2,
159
- borderRadius: this.props.radius - this.state.borderWidth,
160
- backgroundColor: this.props.innerColor,
161
- }]}>
162
- {this.props.children ? this.props.children :
163
- <Text style={[styles.text, this.state.textStyle]}>{this.props.percent}%</Text>}
164
- </View>
165
-
166
- </View>
167
- );
168
- }
169
- }
170
-
171
- // set some attributes default value
172
- PercentageCircle.defaultProps = {
173
- bgcolor: '#e3e3e3',
174
- innerColor: '#fff'
175
- };
176
-
177
- module.exports = PercentageCircle;
@@ -1,43 +0,0 @@
1
- import React from 'react';
2
- import { StyleSheet, View, Modal, Text, ActivityIndicator } from 'react-native';
3
- import PercentageCircle from './PercentageCircle.js';
4
- import { isRTL } from 'muba-i18n';
5
- import commonStyles from '../commonStyles';
6
-
7
- const ProgressBar = props => {
8
- const {
9
- loading,
10
- progress,
11
- ...attributes
12
- } = props;
13
-
14
- return (
15
- <Modal transparent={true} animationType={'none'} visible={loading}>
16
- <View style={styles.modalBackground}>
17
- {isRTL() ?
18
- <View>
19
- <ActivityIndicator size="large" color="#ffffff" />
20
- <Text style={[commonStyles.percentage]}>{progress} %</Text>
21
- </View>
22
- :
23
- <PercentageCircle radius={50} percent={progress} color={"#00afca"} borderWidth={5} textStyle={{ fontSize: 22, fontFamily: 'PostingSemiBold', color: '#00afca', alignSelf: 'center' }}></PercentageCircle>
24
- }
25
- <View>
26
- {props.children}
27
- </View>
28
- </View>
29
- </Modal>
30
- )
31
- }
32
-
33
- const styles = StyleSheet.create({
34
- modalBackground: {
35
- flex: 1,
36
- alignItems: 'center',
37
- flexDirection: 'column',
38
- justifyContent: 'center',
39
- backgroundColor: '#00000080'
40
- }
41
- });
42
-
43
- export default ProgressBar;