esoftplay 0.0.110 → 0.0.111

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.
@@ -1,8 +1,10 @@
1
1
  // noPage
2
- import { esp, LibCrypt, LibNet_status, LibProgress, LibUtils } from 'esoftplay';
2
+ import { esp, LibCrypt, LibNet_status, LibObject, LibProgress, LibUtils, LogStateProperty } from 'esoftplay';
3
3
  import { reportApiError } from "esoftplay/error";
4
4
  import moment from "esoftplay/moment";
5
+ import Constants from 'expo-constants';
5
6
  const axios = require('axios');
7
+ const { manifest } = Constants;
6
8
 
7
9
  export default class ecurl {
8
10
  timeout = 55000;
@@ -28,22 +30,23 @@ export default class ecurl {
28
30
  this.header = {}
29
31
  this.setUri = this.setUri.bind(this);
30
32
  this.setUrl = this.setUrl.bind(this);
31
- this.onFetched = this.onFetched.bind(this)
33
+ this.buildUri = this.buildUri.bind(this);
34
+ this.onFetched = this.onFetched.bind(this);
32
35
  this.setHeader = this.setHeader.bind(this);
33
- this.signatureBuild = this.signatureBuild.bind(this)
34
- this.encodeGetValue = this.encodeGetValue.bind(this)
35
- this.urlEncode = this.urlEncode.bind(this)
36
- this.closeConnection = this.closeConnection.bind(this)
37
- this.onStatusCode = this.onStatusCode.bind(this)
38
- this.onFetchFailed = this.onFetchFailed.bind(this)
39
- this.onError = this.onError.bind(this)
40
- this.setApiKey = this.setApiKey.bind(this)
41
- this.secure = this.secure.bind(this)
42
- this.withHeader = this.withHeader.bind(this)
43
- this.initTimeout = this.initTimeout.bind(this)
44
- this.cancelTimeout = this.cancelTimeout.bind(this)
36
+ this.signatureBuild = this.signatureBuild.bind(this);
37
+ this.encodeGetValue = this.encodeGetValue.bind(this);
38
+ this.urlEncode = this.urlEncode.bind(this);
39
+ this.closeConnection = this.closeConnection.bind(this);
40
+ this.onStatusCode = this.onStatusCode.bind(this);
41
+ this.onFetchFailed = this.onFetchFailed.bind(this);
42
+ this.onError = this.onError.bind(this);
43
+ this.setApiKey = this.setApiKey.bind(this);
44
+ this.secure = this.secure.bind(this);
45
+ this.withHeader = this.withHeader.bind(this);
46
+ this.initTimeout = this.initTimeout.bind(this);
47
+ this.cancelTimeout = this.cancelTimeout.bind(this);
45
48
  // this.createApiTesterUris = this.createApiTesterUris.bind(this)
46
- const str: any = LibNet_status.state().get()
49
+ const str: any = LibNet_status.state().get();
47
50
  if (uri && str.isOnline) {
48
51
  this.init(uri, post, onDone, onFailed, debug);
49
52
  } else if (!str.isOnline && onFailed) {
@@ -71,6 +74,11 @@ export default class ecurl {
71
74
 
72
75
  }
73
76
 
77
+ protected buildUri(uri: string): string {
78
+ this.uri = uri
79
+ return this.uri
80
+ }
81
+
74
82
  protected setUrl(url: string): void {
75
83
  this.url = url
76
84
  }
@@ -270,11 +278,12 @@ export default class ecurl {
270
278
  }).join('&');
271
279
  this.post = ps
272
280
  }
273
- this.setUri(uri)
281
+ uri = this.buildUri(uri);
274
282
  if ((/^[A-z]+:\/\//g).test(uri)) {
275
283
  this.setUrl(uri)
276
284
  this.setUri("")
277
285
  } else {
286
+ this.setUri(uri)
278
287
  this.setUrl(esp.config("url"))
279
288
  }
280
289
  await this.setHeader()
@@ -286,7 +295,7 @@ export default class ecurl {
286
295
  ...this.header,
287
296
  ["Content-Type"]: "application/x-www-form-urlencoded;charset=UTF-8"
288
297
  },
289
- data: this.post,
298
+ data: !this.post ? undefined : this.post,
290
299
  Cache: "no-store",
291
300
  Pragma: "no-cache",
292
301
  ['Cache-Control']: "no-store",
@@ -331,11 +340,12 @@ export default class ecurl {
331
340
  this.post = ps
332
341
  }
333
342
  }
334
- this.setUri(uri)
343
+ uri = this.buildUri(uri);
335
344
  if ((/^[A-z]+:\/\//g).test(uri)) {
336
345
  this.setUrl(uri)
337
346
  this.setUri("")
338
347
  } else {
348
+ this.setUri(uri)
339
349
  this.setUrl(esp.config("url"))
340
350
  }
341
351
  await this.setHeader();
@@ -345,7 +355,7 @@ export default class ecurl {
345
355
  url: this.url + this.uri,
346
356
  method: !this.post ? "GET" : "POST",
347
357
  headers: this.header,
348
- data: this.post,
358
+ data: !this.post ? undefined : this.post,
349
359
  cancelToken: this.abort.token,
350
360
  cache: "no-store",
351
361
  Pragma: "no-cache",
@@ -354,9 +364,40 @@ export default class ecurl {
354
364
  mode: "cors",
355
365
  _post: post
356
366
  }
357
- if (debug == 1) {
358
- esp.log(this.url + this.uri, { ...options, cancelToken: undefined })
367
+ // if (debug == 1) {
368
+ // console.log(this.url + this.uri, { ...options, cancelToken: undefined })
369
+ // }
370
+
371
+ if (esp.isDebug('apitest') && manifest?.packagerOpts?.dev && LogStateProperty) {
372
+ const allData = LogStateProperty.state().get() || []
373
+ const logEnable = LogStateProperty.enableLog().get()
374
+
375
+ const complete_uri = this.uri;
376
+ const _uri = complete_uri.includes('?') ? complete_uri.split('?')[0] : complete_uri
377
+ const _get = complete_uri.includes('?') ? complete_uri.split('?')[1].split('&').map((x: any) => x.split('=')).map((t: any) => {
378
+ return ({ [t[0]]: [t[1]] })
379
+ }) : []
380
+ const get = Object.assign({}, ..._get)
381
+ const _post = post && Object.keys(post).map((key) => {
382
+ return ({ [key]: [post[key]] })
383
+ }) || []
384
+ const postNew = Object.assign({}, ..._post)
385
+
386
+ if (_uri != '') {
387
+ const data = {
388
+ [_uri]: {
389
+ secure: this.isSecure,
390
+ get: get,
391
+ post: postNew
392
+ }
393
+ }
394
+ let dt = LibObject.push(allData, data)()
395
+ if (logEnable) {
396
+ LogStateProperty.state().set(dt)
397
+ }
398
+ }
359
399
  }
400
+
360
401
  this.fetchConf = { url: this.url + this.uri, options: options }
361
402
  this.initTimeout(upload ? 120000 : undefined)
362
403
  axios(options).then(async (res: any) => {
@@ -391,9 +432,17 @@ export default class ecurl {
391
432
  private refineErrorMessage(resText: string): string {
392
433
  let out = resText
393
434
  if (!esp.isDebug('')) {
394
- if (resText.toLowerCase().includes('failed') || resText.toLowerCase().includes('code')) {
395
- reportApiError(this.fetchConf.options, resText)
396
- out = 'Terjadi kesalahan, biar ' + esp.appjson()?.expo?.name + ' bereskan, silahkan coba beberapa saat lagi.'
435
+ const ltext = resText.toLowerCase()
436
+ if (
437
+ ltext.includes('failed') ||
438
+ ltext.includes('code') ||
439
+ ltext.includes('error')
440
+ ) {
441
+ // reportApiError(this.fetchConf.options, resText)
442
+ out = 'Terjadi kesalahan, biar ' + esp.appjson()?.expo?.name + ' bereskan, silahkan coba beberapa saat lagi atau kembali ke halaman utama'
443
+ }
444
+ if (ltext.includes('timeout exceeded')) {
445
+ out = 'Koneksi internet anda tidak stabil, silahkan coba beberapa saat lagi'
397
446
  }
398
447
  }
399
448
  return out
@@ -130,7 +130,7 @@ export default function m(props: LibDatepickerProps): any {
130
130
  function itemRenderer(data: any, index: number, isSelected: boolean) {
131
131
  return (
132
132
  <View>
133
- <Text style={{ fontWeight: isSelected ? 'bold' : 'normal' }} >{data}</Text>
133
+ <Text style={{ fontSize: 20, fontWeight: isSelected ? 'bold' : 'normal' }} >{data}</Text>
134
134
  </View>
135
135
  )
136
136
  }
@@ -7,7 +7,7 @@ import { SaveFormat } from 'expo-image-manipulator';
7
7
  import * as ImagePicker from 'expo-image-picker';
8
8
  import React from 'react';
9
9
  import {
10
- ActivityIndicator, Alert, Image, TouchableOpacity, View
10
+ ActivityIndicator, Alert, Image, TouchableOpacity, View
11
11
  } from 'react-native';
12
12
  const { height, width } = LibStyle;
13
13
 
@@ -51,12 +51,17 @@ const fetchPicture = LibWorker.registerJobAsync('lib_picture_fetch', (url: strin
51
51
  let wantedheight = 0
52
52
  let wantedwidth = 0
53
53
  let ratio = rawwidth / rawheight
54
- if (rawheight > rawwidth) {
55
- wantedwidth = wantedMaxSize * ratio;
56
- wantedheight = wantedMaxSize;
54
+ if (Math.max(rawheight, rawwidth) > wantedMaxSize) {
55
+ if (rawheight > rawwidth) {
56
+ wantedwidth = wantedMaxSize * ratio;
57
+ wantedheight = wantedMaxSize;
58
+ } else {
59
+ wantedwidth = wantedMaxSize;
60
+ wantedheight = wantedMaxSize / ratio;
61
+ }
57
62
  } else {
58
- wantedwidth = wantedMaxSize;
59
- wantedheight = wantedMaxSize / ratio;
63
+ wantedwidth = rawwidth
64
+ wantedheight = rawheight
60
65
  }
61
66
  let canvas = document.createElement('canvas');
62
67
  let ctx = canvas.getContext('2d');
@@ -0,0 +1,131 @@
1
+ // withHooks
2
+ // noPage
3
+
4
+ import { LibStyle, useSafeState } from 'esoftplay';
5
+ import { LinearGradient } from 'expo-linear-gradient';
6
+ import React, { useEffect, useRef } from 'react';
7
+ import { Text, TouchableOpacity, View } from 'react-native';
8
+ import ScrollPicker from 'react-native-picker-scrollview';
9
+
10
+ export interface LibTimepickerProps {
11
+ /* hh:mm:ss */
12
+ selectedTime: string,
13
+ onTimeChange: (second: string) => void,
14
+ /* hh:mm:ss */
15
+ minTime?: string,
16
+ /* hh:mm:ss */
17
+ maxTime?: string,
18
+ mode?: 24 | 12,
19
+ /* hh:mm:ss */
20
+ type?: "hour" | "hourMinute" | "hourMinuteSecond"
21
+ }
22
+
23
+ export default function m(props: LibTimepickerProps): any {
24
+
25
+ const _mode = props.mode || 24
26
+ const refHour = useRef<any>(null)
27
+ const refMinute = useRef<any>(null)
28
+ const refSecond = useRef<any>(null)
29
+ const t24 = _mode == 12 ? ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11"] : ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"]
30
+ const t60 = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"]
31
+ const time = { hours: t24, minutes: t60, seconds: t60 }
32
+ const minTime = props.minTime
33
+ const maxTime = props.maxTime
34
+ const type = props.type || "hourMinuteSecond"
35
+ const [selectedTime, setSelectedTime] = useSafeState(props.selectedTime || minTime)
36
+ let sHour = selectedTime.split(':')[0]
37
+ let sMinute = selectedTime.split(':')[1]
38
+ let sSecond = selectedTime.split(':')[2]
39
+ let showHour = (type == 'hour') || (type == 'hourMinute') || (type == 'hourMinuteSecond');
40
+ let showHourMinute = (type == 'hourMinuteSecond') || (type == 'hourMinute');
41
+ let showHourMinuteSecond = type == 'hourMinuteSecond';
42
+
43
+ function scrollTo(time: string) {
44
+ refHour?.current?.scrollToIndex(t24.indexOf(time.split(':')[0]))
45
+ refMinute?.current?.scrollToIndex(t60.indexOf(time.split(':')[1]))
46
+ refSecond?.current?.scrollToIndex(t60.indexOf(time.split(':')[2]))
47
+ }
48
+
49
+ useEffect(() => {
50
+ if (selectedTime) {
51
+ let toTime = null
52
+ if (maxTime && selectedTime > maxTime) {
53
+ toTime = maxTime;
54
+ } else if (minTime && selectedTime < minTime) {
55
+ toTime = minTime;
56
+ }
57
+ if (toTime != null){
58
+ scrollTo(toTime);
59
+ setSelectedTime(toTime);
60
+ }
61
+ }
62
+ }, [selectedTime])
63
+
64
+ function itemRenderer(data: any, index: number, isSelected: boolean) {
65
+ return (
66
+ <View>
67
+ <Text style={{ fontSize: 20, fontWeight: isSelected ? 'bold' : 'normal' }} >{data}</Text>
68
+ </View>
69
+ )
70
+ }
71
+
72
+ return (
73
+ <View style={{ flex: 1, backgroundColor: 'white' }} >
74
+ <View style={{ height: 44, alignItems: 'flex-end', backgroundColor: '#fafafa' }} >
75
+ <TouchableOpacity onPress={() => { props.onTimeChange(selectedTime) }} >
76
+ <Text style={{ fontSize: 15, fontWeight: "500", paddingHorizontal: 9, paddingVertical: 13, fontStyle: "normal", letterSpacing: 0, color: LibStyle.colorPrimary }} >Done</Text>
77
+ </TouchableOpacity>
78
+ </View>
79
+ <View style={{ width: 180, flex: 1, height: 175, alignSelf: 'center' }} >
80
+ <View style={{ height: 175, flexDirection: 'row', alignItems: 'center' }} >
81
+ <View style={{ width: showHour ? undefined : 0, flex: showHour ? 1 : 0, }} >
82
+ <ScrollPicker
83
+ ref={refHour}
84
+ dataSource={time.hours}
85
+ selectedIndex={time.hours.indexOf(sHour)}
86
+ itemHeight={35}
87
+ wrapperHeight={175}
88
+ wrapperColor={'#ffffff'}
89
+ highlightColor={'#c8c7cc'}
90
+ renderItem={itemRenderer}
91
+ onValueChange={(value: any) => setSelectedTime(value + ':' + sMinute + ":" + sSecond)}
92
+ />
93
+ </View>
94
+ <Text style={{ width: showHourMinute ? undefined : 0, fontSize: 30, marginBottom: 5 }} >:</Text>
95
+ <View style={{ width: showHourMinute ? undefined : 0, flex: showHourMinute ? 1 : 0 }} >
96
+ <ScrollPicker
97
+ ref={refMinute}
98
+ dataSource={time.minutes}
99
+ selectedIndex={time.minutes.indexOf(sMinute)}
100
+ itemHeight={35}
101
+ wrapperHeight={175}
102
+ wrapperColor={'#ffffff'}
103
+ highlightColor={'#c8c7cc'}
104
+ renderItem={itemRenderer}
105
+ onValueChange={(value: any) => setSelectedTime(sHour + ':' + value + ":" + sSecond)}
106
+ />
107
+ </View>
108
+ <Text style={{ width: showHourMinuteSecond ? undefined : 0, fontSize: 30, marginBottom: 5 }} >:</Text>
109
+ <View style={{ width: showHourMinuteSecond ? undefined : 0, flex: showHourMinuteSecond ? 1 : 0, }} >
110
+ <ScrollPicker
111
+ ref={refSecond}
112
+ dataSource={time.seconds}
113
+ selectedIndex={time.seconds.indexOf(sSecond)}
114
+ itemHeight={35}
115
+ wrapperHeight={175}
116
+ wrapperColor={'#ffffff'}
117
+ highlightColor={'#c8c7cc'}
118
+ renderItem={itemRenderer}
119
+ onValueChange={(value: any) => setSelectedTime(sHour + ':' + sMinute + ":" + value)}
120
+ />
121
+ </View>
122
+ </View>
123
+ </View>
124
+ <LinearGradient
125
+ start={{ x: 1, y: 0 }}
126
+ end={{ x: 1, y: 1 }}
127
+ colors={['rgba(255,255,255,1)', 'rgba(255,255,255,0.8)', 'rgba(255,255,255,0)', 'rgba(255,255,255,0.8)', 'rgba(255,255,255,1)']}
128
+ pointerEvents='none' style={{ height: 175, position: 'absolute', top: 44, bottom: 0, left: 0, right: 0 }} />
129
+ </View>
130
+ )
131
+ }
@@ -3,12 +3,11 @@
3
3
 
4
4
  import { esp, LibDialog, LibImage, LibNet_status, LibProgress, LibStyle, LibToast, LibUpdaterProperty, LibVersion, LibWorker, LibWorkloop, LibWorkview, UseDeeplink, UserClass, UserLoading, UserMain, UserRoutes, useSafeState, _global } from 'esoftplay';
5
5
  import * as Font from "expo-font";
6
- import firebase from 'firebase';
7
6
  import React, { useEffect, useMemo } from "react";
8
7
  import { Alert, View } from "react-native";
9
- //@ts-ignore
10
8
  import Navs from "../../cache/navs";
11
9
 
10
+
12
11
  export interface UserIndexProps {
13
12
 
14
13
  }
@@ -56,9 +55,12 @@ export default function m(props: UserIndexProps): any {
56
55
  ], { cancelable: false })
57
56
  }, 30 * 1000);
58
57
  if (esp.config('firebase').hasOwnProperty('apiKey')) {
59
- if (!firebase.apps.length) {
60
- firebase.initializeApp(esp.config('firebase'));
61
- firebase.auth().signInAnonymously()
58
+ try {
59
+ const chatFirebase = require('../chatting/firebase')?.default
60
+ if (chatFirebase)
61
+ chatFirebase?.signInAnonymously?.();
62
+ } catch (error) {
63
+
62
64
  }
63
65
  }
64
66
  UserClass.isLogin(async () => {
@@ -31,7 +31,7 @@ export interface UserLoginState {
31
31
  isLoading: boolean
32
32
  }
33
33
 
34
- export default class euserLogin extends LibComponent<UserLoginProps, UserLoginState> {
34
+ export default class m extends LibComponent<UserLoginProps, UserLoginState> {
35
35
 
36
36
  inputUsername: any;
37
37
  inputPassword: any;
@@ -1,9 +1,9 @@
1
1
  //
2
2
 
3
3
  import {
4
- esp, LibComponent, LibCrypt,
5
- LibCurl, LibIcon, LibList, LibNotification, LibObject, LibStatusbar, LibStyle, LibUtils, useGlobalReturn, useGlobalState,
6
- UserClass, UserNotification_item
4
+ esp, LibComponent, LibCrypt,
5
+ LibCurl, LibIcon, LibList, LibNotification, LibObject, LibStatusbar, LibStyle, LibUtils, useGlobalReturn, useGlobalState,
6
+ UserClass, UserNotification_item
7
7
  } from "esoftplay";
8
8
  import * as Notifications from 'expo-notifications';
9
9
  import React from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.110",
3
+ "version": "0.0.111",
4
4
  "description": "embedding data from esoftplay framework (web based) into mobile app",
5
5
  "main": "cache/index.js",
6
6
  "types": "../../index.d.ts",