esoftplay 0.0.128 → 0.0.129
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/assets/locale/id.json +0 -7
- package/bin/cli.js +11 -10
- package/bin/locale.js +29 -5
- package/bin/router.js +41 -26
- package/error.ts +4 -1
- package/esp.ts +1 -1
- package/global.ts +4 -3
- package/lazy.ts +13 -6
- package/modules/lib/effect.tsx +2 -1
- package/modules/lib/focus.tsx +3 -4
- package/modules/lib/net_status.tsx +9 -6
- package/modules/lib/notification.ts +1 -1
- package/modules/lib/style.ts +77 -59
- package/modules/lib/toast.tsx +8 -3
- package/modules/lib/utils.ts +1 -0
- package/modules/user/index.tsx +4 -0
- package/moment.ts +3 -2
- package/package.json +1 -1
- package/state.ts +7 -3
- package/subscribe.ts +3 -3
package/assets/locale/id.json
CHANGED
|
@@ -62,9 +62,6 @@
|
|
|
62
62
|
"lib/notification": {
|
|
63
63
|
"permission": "Please enable notifications permissions"
|
|
64
64
|
},
|
|
65
|
-
"lib/roll": {
|
|
66
|
-
"failed": "Failed to access"
|
|
67
|
-
},
|
|
68
65
|
"lib/updater": {
|
|
69
66
|
"alert_info": "Informasi",
|
|
70
67
|
"alert_msg": "Pembaharuan berhasil diinstall",
|
|
@@ -96,9 +93,5 @@
|
|
|
96
93
|
},
|
|
97
94
|
"use/deeplink": {
|
|
98
95
|
"msg_err": "Oops...!"
|
|
99
|
-
},
|
|
100
|
-
"user/login": {
|
|
101
|
-
"username": "username",
|
|
102
|
-
"pass": "password"
|
|
103
96
|
}
|
|
104
97
|
}
|
package/bin/cli.js
CHANGED
|
@@ -172,16 +172,17 @@ function switchStatusAssets(status) {
|
|
|
172
172
|
|
|
173
173
|
fs.readdirSync(DIR + '/modules/').forEach((mod) => {
|
|
174
174
|
const path = DIR + '/modules/' + mod
|
|
175
|
-
fs.
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
175
|
+
if (fs.statSync(path).isDirectory())
|
|
176
|
+
fs.readdirSync(path).forEach((file) => {
|
|
177
|
+
if (status.includes('d'))
|
|
178
|
+
if (file.match(/^.*.debug.*/g)) {
|
|
179
|
+
copyFileFromTo(path + '/' + file, path + '/' + file.replace('.debug.', '.'))
|
|
180
|
+
}
|
|
181
|
+
if (status.includes('l'))
|
|
182
|
+
if (file.match(/^.*.live.*/g)) {
|
|
183
|
+
copyFileFromTo(path + '/' + file, path + '/' + file.replace('.live.', '.'))
|
|
184
|
+
}
|
|
185
|
+
})
|
|
185
186
|
})
|
|
186
187
|
|
|
187
188
|
}
|
package/bin/locale.js
CHANGED
|
@@ -1,18 +1,42 @@
|
|
|
1
|
+
//@ts-check
|
|
1
2
|
const fs = require('fs')
|
|
2
3
|
const merge = require('lodash/merge')
|
|
4
|
+
const idJsonPath ="./assets/locale/id.json"
|
|
3
5
|
|
|
4
6
|
function readAsJson(path) {
|
|
5
7
|
let out = ""
|
|
6
8
|
try { out = JSON.parse(fs.readFileSync(path, { encoding: 'utf8' })) } catch (e) { }
|
|
7
9
|
return out;
|
|
8
10
|
}
|
|
9
|
-
if (!fs.existsSync("./assets/locale
|
|
10
|
-
fs.
|
|
11
|
+
if (!fs.existsSync("./assets/locale")) {
|
|
12
|
+
fs.mkdirSync("./assets/locale")
|
|
11
13
|
}
|
|
12
|
-
if (fs.existsSync(
|
|
14
|
+
if (!fs.existsSync(idJsonPath)) {
|
|
15
|
+
fs.writeFileSync(idJsonPath, JSON.stringify({}, undefined, 2))
|
|
16
|
+
}
|
|
17
|
+
if (fs.existsSync(idJsonPath)) {
|
|
13
18
|
let masterLocale = readAsJson('./node_modules/esoftplay/assets/locale/id.json')
|
|
14
|
-
let projectLang = readAsJson(
|
|
19
|
+
let projectLang = readAsJson(idJsonPath)
|
|
15
20
|
let _lg = merge(masterLocale, projectLang)
|
|
16
21
|
masterLocale = { ..._lg }
|
|
17
|
-
fs.writeFileSync(
|
|
22
|
+
fs.writeFileSync(idJsonPath, JSON.stringify(sortObject(masterLocale), undefined, 2), { encoding: 'utf8' })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function sortObject(obj) {
|
|
26
|
+
if (typeof obj !== "object" || obj === null) {
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (Array.isArray(obj)) {
|
|
31
|
+
return obj.map(sortObject);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let sortedKeys = Object.keys(obj).sort();
|
|
35
|
+
let sortedObj = {};
|
|
36
|
+
|
|
37
|
+
for (let key of sortedKeys) {
|
|
38
|
+
sortedObj[key] = sortObject(obj[key]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return sortedObj;
|
|
18
42
|
}
|
package/bin/router.js
CHANGED
|
@@ -389,9 +389,11 @@ import { AntDesignTypes, EntypoTypes, EvilIconsTypes, FeatherTypes, FontAwesomeT
|
|
|
389
389
|
|
|
390
390
|
declare module "esoftplay" {
|
|
391
391
|
var _global: any;
|
|
392
|
+
function useGlobalSubscriber<S>(initialState?: S): useGlobalSubscribeReturn<S>;
|
|
393
|
+
function useLazyState<S>(initialState?: S): [S, (newValue: S) => () => void, () => S];
|
|
392
394
|
function useGlobalState<S>(initialState?: S, option?: useGlobalOption): useGlobalReturn<S>;
|
|
393
395
|
function usePersistState<S>(key: string, initialState?: S | (() => S)): [S, (a: S | ((b: S )=> S)) => S | undefined, (a?: (x: S) => void) => void, () => void];
|
|
394
|
-
function useSafeState<S>(initialState?: S | (() => S)): [S, (a: S | ((b: S )=> S)) => S | undefined];
|
|
396
|
+
function useSafeState<S>(initialState?: S | (() => S)): [S, (a: S | ((b: S )=> S)) => S | undefined, ()=>S];
|
|
395
397
|
function applyStyle<T>(style: T): T;
|
|
396
398
|
function usePersistState<S>(key: string, initialState?: S | (() => S)): [S, (a: S) => void, (a?: (x: S)=> void) => void, () => void];
|
|
397
399
|
namespace esp {
|
|
@@ -433,7 +435,7 @@ declare module "esoftplay" {
|
|
|
433
435
|
}
|
|
434
436
|
|
|
435
437
|
interface useGlobalReturn<T> {
|
|
436
|
-
useState: () => [T, (newState: T) => void, () => void],
|
|
438
|
+
useState: () => [T, (newState: T) => void, () => void, () => T],
|
|
437
439
|
get: (param?: string, ...params: string[]) => T,
|
|
438
440
|
set: (x: T) => void,
|
|
439
441
|
reset: () => void,
|
|
@@ -447,11 +449,19 @@ declare module "esoftplay" {
|
|
|
447
449
|
listener?: (data: any) => void,
|
|
448
450
|
isUserData?: boolean
|
|
449
451
|
}
|
|
452
|
+
|
|
453
|
+
interface useGlobalSubscribeReturn {
|
|
454
|
+
getValue: () => any,
|
|
455
|
+
reset: () => void,
|
|
456
|
+
useSubscribe: Function,
|
|
457
|
+
trigger: (newValue?: any) => void
|
|
458
|
+
}
|
|
459
|
+
|
|
450
460
|
interface useGlobalConnect<T> {
|
|
451
461
|
render: (props: T) => any,
|
|
452
462
|
}`;
|
|
453
463
|
for (clsName in tmpTask) {
|
|
454
|
-
let ItemText = ""
|
|
464
|
+
let ItemText = "\nimport { useGlobalSubscribeReturn } from 'esoftplay';\nimport { useGlobalReturn } from 'esoftplay';\n"
|
|
455
465
|
if (clsName == "LibIcon") {
|
|
456
466
|
ItemText += "import { EvilIconsTypes, AntDesignTypes, EvilIconsTypes, FeatherTypes, FontAwesomeTypes, FontistoTypes, FoundationTypes, MaterialIconsTypes, EntypoTypes, OcticonsTypes, ZocialTypes, SimpleLineIconsTypes, IoniconsTypes, MaterialCommunityIconsTypes } from '@expo/vector-icons/build/esoftplay_icons';\n"
|
|
457
467
|
}
|
|
@@ -535,19 +545,22 @@ declare module "esoftplay" {
|
|
|
535
545
|
const [module, task] = clsName.split(/(?=[A-Z])/)
|
|
536
546
|
const nav = module?.toLowerCase() + '/' + task?.toLowerCase()
|
|
537
547
|
|
|
538
|
-
if (
|
|
539
|
-
fs.mkdirSync(tmpDir + module.toLowerCase());
|
|
548
|
+
if (!nav.includes('.')) {
|
|
540
549
|
|
|
541
|
-
|
|
542
|
-
|
|
550
|
+
if (module && !fs.existsSync(tmpDir + module?.toLowerCase()))
|
|
551
|
+
fs.mkdirSync(tmpDir + module.toLowerCase());
|
|
543
552
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
|
|
553
|
+
if (!fs.existsSync(tmpDir + nav))
|
|
554
|
+
fs.mkdirSync(tmpDir + nav)
|
|
555
|
+
|
|
556
|
+
PreText += "import '" + tmpDir + nav + "/import.d';\n"
|
|
557
|
+
if (isChange(tmpDir + nav + '/import.d.ts', ItemText)) {
|
|
558
|
+
fs.writeFile(tmpDir + nav + '/import.d.ts', ItemText, { flag: 'w' }, function (err) {
|
|
559
|
+
if (err) {
|
|
560
|
+
return console.log(err);
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
}
|
|
551
564
|
}
|
|
552
565
|
}
|
|
553
566
|
Text += "\n\ttype LibNavigationRoutes = \"" + Navigations.join("\" |\n\t\t\t \"") + "\"\n"
|
|
@@ -638,7 +651,7 @@ function createRouter() {
|
|
|
638
651
|
"import React from 'react'\n" +
|
|
639
652
|
"const _" + ucword(module) + ucword(task) + " = React.lazy(() => import('../../../../." + Modules[module][task] + "')); \n" +
|
|
640
653
|
"import * as " + ucword(module) + ucword(task) + SuffixHooksProperty + " from '../../../../." + Modules[module][task] + "';\n" +
|
|
641
|
-
"const UpdatedComponent = (OriginalComponent) => { function "+ucword(module) + ucword(task)+"Component(props) { return ( <React.Suspense><OriginalComponent {...props} /></React.Suspense> ) } return "+ucword(module) + ucword(task)+"Component; };\n" +
|
|
654
|
+
"const UpdatedComponent = (OriginalComponent) => { function " + ucword(module) + ucword(task) + "Component(props) { return ( <React.Suspense><OriginalComponent {...props} /></React.Suspense> ) } return " + ucword(module) + ucword(task) + "Component; };\n" +
|
|
642
655
|
"const " + ucword(module) + ucword(task) + " = stable(UpdatedComponent(_" + ucword(module) + ucword(task) + ")); \n" +
|
|
643
656
|
"export { " + ucword(module) + ucword(task) + SuffixHooksProperty + ", " + ucword(module) + ucword(task) + " };\n"
|
|
644
657
|
} else if (UseLibs.includes(nav)) {
|
|
@@ -652,18 +665,20 @@ function createRouter() {
|
|
|
652
665
|
item += "export { _" + ucword(module) + ucword(task) + " as " + ucword(module) + ucword(task) + " };\n"
|
|
653
666
|
}
|
|
654
667
|
|
|
655
|
-
if (!
|
|
656
|
-
fs.
|
|
668
|
+
if (!nav.includes('.')) {
|
|
669
|
+
if (!fs.existsSync(tmpDir + module))
|
|
670
|
+
fs.mkdirSync(tmpDir + module);
|
|
657
671
|
|
|
658
|
-
|
|
659
|
-
|
|
672
|
+
if (!fs.existsSync(tmpDir + nav))
|
|
673
|
+
fs.mkdirSync(tmpDir + nav)
|
|
660
674
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
675
|
+
if (isChange(tmpDir + nav + "/import." + fileExt, item)) {
|
|
676
|
+
fs.writeFile(tmpDir + nav + '/import.' + fileExt, item, { flag: 'w' }, function (err) {
|
|
677
|
+
if (err) {
|
|
678
|
+
return console.log(err);
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
}
|
|
667
682
|
}
|
|
668
683
|
|
|
669
684
|
// if (module == 'lib' && task == 'component') {
|
|
@@ -752,4 +767,4 @@ function createRouter() {
|
|
|
752
767
|
return console.log(err);
|
|
753
768
|
}
|
|
754
769
|
});
|
|
755
|
-
}
|
|
770
|
+
}
|
package/error.ts
CHANGED
|
@@ -27,7 +27,8 @@ export function setError(error?: any) {
|
|
|
27
27
|
const _e = {
|
|
28
28
|
user,
|
|
29
29
|
error: String(error),
|
|
30
|
-
routes: routesName
|
|
30
|
+
routes: routesName,
|
|
31
|
+
time: new Date().toISOString()
|
|
31
32
|
};
|
|
32
33
|
try {
|
|
33
34
|
AsyncStorage.setItem(`${config?.domain}error`, JSON.stringify(_e));
|
|
@@ -46,6 +47,7 @@ export function reportApiError(fetch: any, error: any) {
|
|
|
46
47
|
'slug: ' + "#" + manifest?.slug,
|
|
47
48
|
'error: ' + error,
|
|
48
49
|
'\n\n\ndev: ' + Platform.OS + ' - ' + Constants.deviceName,
|
|
50
|
+
'time: ' + new Date().toISOString(),
|
|
49
51
|
'app/pub_id: ' + Constants.appOwnership + '/' + (config?.publish_id || '-'),
|
|
50
52
|
'user_id: ' + user?.id || user?.user_id || '-',
|
|
51
53
|
'username: ' + user?.username || '-',
|
|
@@ -82,6 +84,7 @@ export function getError() {
|
|
|
82
84
|
'slug: ' + "#" + manifest?.slug,
|
|
83
85
|
'error: \n' + _e.error,
|
|
84
86
|
'\n\nname: ' + manifest?.name + ' - sdk' + pack?.dependencies?.expo,
|
|
87
|
+
'time: \n' + _e?.time,
|
|
85
88
|
'domain: ' + config.domain + config.uri,
|
|
86
89
|
'package: ' + (Platform.OS == 'ios' ? manifest?.ios?.bundleIdentifier : manifest?.android?.package) + ' - v' + (Platform.OS == 'ios' ? app.expo.ios.buildNumber : app.expo.android.versionCode),
|
|
87
90
|
'device: ' + Platform.OS + ' | ' + Constants.deviceName,
|
package/esp.ts
CHANGED
|
@@ -122,7 +122,7 @@ const esp = {
|
|
|
122
122
|
function sprintf(string: string, index: number): string {
|
|
123
123
|
if (stringToBe[index] != undefined) {
|
|
124
124
|
string = string.replace("%s", stringToBe[index])
|
|
125
|
-
if (string
|
|
125
|
+
if (string?.includes?.("%s")) {
|
|
126
126
|
return sprintf(string, index + 1)
|
|
127
127
|
}
|
|
128
128
|
}
|
package/global.ts
CHANGED
|
@@ -7,7 +7,7 @@ const isEqual = require('react-fast-compare');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
export interface useGlobalReturn<T> {
|
|
10
|
-
useState: () => [T, (newState: T) => void, () => void],
|
|
10
|
+
useState: () => [T, (newState: T) => void, () => void, () => T],
|
|
11
11
|
get: (param?: string, ...params: string[]) => T,
|
|
12
12
|
set: (x: T) => void,
|
|
13
13
|
reset: () => void,
|
|
@@ -154,14 +154,15 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
|
|
157
|
-
function useState(): [T, (newState: T) => void, () =>
|
|
157
|
+
function useState(): [T, (newState: T) => void, () => T] {
|
|
158
158
|
let [l, s] = R.useState<T>(value);
|
|
159
159
|
|
|
160
160
|
let sl = R.useCallback((ns: T) => { s(ns) }, []);
|
|
161
161
|
|
|
162
|
+
|
|
162
163
|
subscribe(sl)
|
|
163
164
|
|
|
164
|
-
return [l, set,
|
|
165
|
+
return [l, set, () => value];
|
|
165
166
|
};
|
|
166
167
|
|
|
167
168
|
function _connect(props: useGlobalConnect<T>): any {
|
package/lazy.ts
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
export default function useLazyState<T>(initialState
|
|
3
|
+
export default function useLazyState<T>(initialState?: T): [T, (newValue: T) => () => void, () => T] {
|
|
4
4
|
const [, rerender] = useState({})
|
|
5
5
|
const dispatch = () => { rerender({}) }
|
|
6
6
|
const value = useRef(initialState)
|
|
7
7
|
const isMounted = useRef(true)
|
|
8
|
+
|
|
9
|
+
const getter = () => {
|
|
10
|
+
return value.current
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
const setter = (newValue: T) => {
|
|
9
|
-
if (isMounted.current)
|
|
14
|
+
if (isMounted.current) {
|
|
10
15
|
value.current = newValue;
|
|
16
|
+
}
|
|
11
17
|
return () => {
|
|
12
|
-
if (isMounted.current)
|
|
18
|
+
if (isMounted.current) {
|
|
13
19
|
dispatch()
|
|
20
|
+
}
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
useEffect(() => {
|
|
18
25
|
isMounted.current = true
|
|
19
26
|
return () => { isMounted.current = false }
|
|
20
27
|
}, [])
|
|
21
28
|
|
|
22
|
-
return [value.current, setter]
|
|
29
|
+
return [value.current, setter, getter]
|
|
23
30
|
}
|
package/modules/lib/effect.tsx
CHANGED
package/modules/lib/focus.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { useIsFocused } from '@react-navigation/native';
|
|
5
5
|
import React, { useEffect } from 'react';
|
|
6
|
-
import { View } from 'react-native';
|
|
6
|
+
import { InteractionManager, View } from 'react-native';
|
|
7
7
|
|
|
8
8
|
export interface LibFocusProps {
|
|
9
9
|
isFocused?: boolean
|
|
@@ -18,14 +18,13 @@ export interface LibFocusState {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export default function m(props: LibFocusProps): any {
|
|
21
|
-
console.warn("LibFocus now DEPRECATED, will be remove on next update")
|
|
22
21
|
const isFocused = useIsFocused()
|
|
23
22
|
|
|
24
23
|
useEffect(() => {
|
|
25
24
|
if (isFocused) {
|
|
26
|
-
props?.onFocus
|
|
25
|
+
InteractionManager.runAfterInteractions(props?.onFocus)
|
|
27
26
|
} else {
|
|
28
|
-
props?.onBlur
|
|
27
|
+
InteractionManager.runAfterInteractions(props?.onBlur)
|
|
29
28
|
}
|
|
30
29
|
}, [isFocused]);
|
|
31
30
|
|
|
@@ -13,15 +13,18 @@ export interface LibNet_statusState {
|
|
|
13
13
|
zeroHeight: any
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const state = useGlobalState({
|
|
16
|
+
const state = useGlobalState({
|
|
17
|
+
isOnline: true,
|
|
18
|
+
isInternetReachable: true
|
|
19
|
+
})
|
|
17
20
|
|
|
18
21
|
class net_status extends LibComponent<LibNet_statusProps, LibNet_statusState> {
|
|
19
22
|
static state(): useGlobalReturn<any> {
|
|
20
23
|
return state
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
static setOnline(isOnline: boolean): void {
|
|
24
|
-
state.set({ isOnline: isOnline })
|
|
26
|
+
static setOnline(isOnline: boolean, isInternetReachable: boolean): void {
|
|
27
|
+
state.set({ isOnline: isOnline, isInternetReachable: isInternetReachable })
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
timeout
|
|
@@ -36,7 +39,7 @@ class net_status extends LibComponent<LibNet_statusProps, LibNet_statusState> {
|
|
|
36
39
|
componentDidMount(): void {
|
|
37
40
|
super.componentDidMount()
|
|
38
41
|
this.unsubscribe = NetInfo.addEventListener(state => {
|
|
39
|
-
this.onChangeConnectivityStatus(state.isConnected, state.isInternetReachable)
|
|
42
|
+
this.onChangeConnectivityStatus(!!state.isConnected, state.isInternetReachable)
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
45
|
|
|
@@ -46,8 +49,8 @@ class net_status extends LibComponent<LibNet_statusProps, LibNet_statusState> {
|
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
onChangeConnectivityStatus(isConnected: boolean, isInternetReachable): void {
|
|
49
|
-
let isOnline =
|
|
50
|
-
net_status.setOnline(
|
|
52
|
+
let isOnline = isConnected && isInternetReachable
|
|
53
|
+
net_status.setOnline(isConnected, isInternetReachable)
|
|
51
54
|
if (isOnline) {
|
|
52
55
|
this.timeout = setTimeout(() => {
|
|
53
56
|
this.setState({ zeroHeight: 1 })
|
package/modules/lib/style.ts
CHANGED
|
@@ -1,20 +1,61 @@
|
|
|
1
1
|
// noPage
|
|
2
|
-
|
|
3
2
|
import { Dimensions, Platform, StatusBar } from "react-native";
|
|
3
|
+
function isIphoneX() {
|
|
4
|
+
const dimen = Dimensions.get('window');
|
|
5
|
+
const dimenHeight = [780, 812, 844, 852, 896, 926, 932, 1170]
|
|
6
|
+
return (
|
|
7
|
+
Platform.OS === 'ios' &&
|
|
8
|
+
!Platform.isPad &&
|
|
9
|
+
!Platform.isTV &&
|
|
10
|
+
(dimenHeight.includes(dimen.height) || dimenHeight.includes(dimen.width))
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
/* LIVE */
|
|
4
14
|
|
|
5
15
|
const { height, width } = Dimensions.get("window");
|
|
6
16
|
const STATUSBAR_HEIGHT = (Platform.OS === "ios" ? isIphoneX() ? 44 : 20 : StatusBar.currentHeight) || 0;
|
|
7
17
|
const STATUSBAR_HEIGHT_MASTER = (Platform.OS === "ios" ? isIphoneX() ? 44 : 20 : StatusBar.currentHeight) || 0;
|
|
8
|
-
const colorPrimary = "#
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
+
const colorPrimary = "#FFC523";
|
|
19
|
+
const colorPrimaryMarket = "#A62287";
|
|
20
|
+
const colorPrimaryMart = "#40CEFF";
|
|
21
|
+
const colorPrimaryDark = "#FFC523";
|
|
22
|
+
const colorAccent = "#FFF";
|
|
23
|
+
const colorGrey = "#F1F1F3";
|
|
24
|
+
const colorTextPrimary = "#9e9e9e";
|
|
25
|
+
const headerHeight = 56
|
|
26
|
+
const colorBgGrey = '#EEF1F8';
|
|
27
|
+
|
|
28
|
+
const colorBrown = '#704728'
|
|
29
|
+
const colorBrownLight = '#C5906C'
|
|
30
|
+
const colorRed = "#dc143c";
|
|
31
|
+
const colorBlue = "#3EA4DC";
|
|
32
|
+
const colorGreen = "#2CB159";
|
|
33
|
+
const colorLightGrey = "#EDEDED";
|
|
34
|
+
const colorTextBody = "#909090";
|
|
35
|
+
const colorTextCaption = "#BEBEBE";
|
|
36
|
+
|
|
37
|
+
function elevation(value: any): any {
|
|
38
|
+
if (Platform.OS === "ios") {
|
|
39
|
+
if (value == 0) return {}
|
|
40
|
+
return { shadowColor: "black", shadowOffset: { width: 0, height: value / 2 }, shadowRadius: value, shadowOpacity: 0.24 }
|
|
41
|
+
}
|
|
42
|
+
return { elevation: value }
|
|
43
|
+
}
|
|
44
|
+
// Add your default style here
|
|
45
|
+
/*
|
|
46
|
+
Sample :
|
|
47
|
+
|
|
48
|
+
###################
|
|
49
|
+
le
|
|
50
|
+
const styles = StyleSheet.create({
|
|
51
|
+
container: {
|
|
52
|
+
...defaultStyle.container
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
##################
|
|
57
|
+
|
|
58
|
+
*/
|
|
18
59
|
|
|
19
60
|
const defaultStyle = {
|
|
20
61
|
container: {
|
|
@@ -41,52 +82,29 @@ const defaultStyle = {
|
|
|
41
82
|
},
|
|
42
83
|
}
|
|
43
84
|
|
|
44
|
-
export default class
|
|
45
|
-
static isIphoneX = isIphoneX()
|
|
46
|
-
static STATUSBAR_HEIGHT = STATUSBAR_HEIGHT
|
|
47
|
-
static STATUSBAR_HEIGHT_MASTER = STATUSBAR_HEIGHT_MASTER
|
|
48
|
-
static colorPrimary = colorPrimary
|
|
49
|
-
static colorPrimaryDark = colorPrimaryDark
|
|
50
|
-
static
|
|
51
|
-
static
|
|
52
|
-
static
|
|
53
|
-
static
|
|
54
|
-
static
|
|
55
|
-
static
|
|
56
|
-
static
|
|
57
|
-
static
|
|
58
|
-
static
|
|
59
|
-
static
|
|
60
|
-
static
|
|
61
|
-
static
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
} else if (Platform.OS == 'web') {
|
|
70
|
-
return { boxShadow: `${0 * value}px ${0.5 * value}px ${value}px ${'rgba(0,0,0,0.24)'}` }
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return { elevation: value }
|
|
74
|
-
}
|
|
75
|
-
function isIphoneX() {
|
|
76
|
-
const dimen = Dimensions.get('window');
|
|
77
|
-
return (
|
|
78
|
-
Platform.OS === 'ios' &&
|
|
79
|
-
!Platform.isPad &&
|
|
80
|
-
!Platform.isTVOS &&
|
|
81
|
-
(dimen.height === 780 ||
|
|
82
|
-
dimen.width === 780 ||
|
|
83
|
-
dimen.height === 812 ||
|
|
84
|
-
dimen.width === 812 ||
|
|
85
|
-
dimen.height === 844 ||
|
|
86
|
-
dimen.width === 844 ||
|
|
87
|
-
dimen.height === 896 ||
|
|
88
|
-
dimen.width === 896 ||
|
|
89
|
-
dimen.height === 926 ||
|
|
90
|
-
dimen.width === 926)
|
|
91
|
-
);
|
|
85
|
+
export default class Style {
|
|
86
|
+
static isIphoneX: boolean = isIphoneX();
|
|
87
|
+
static STATUSBAR_HEIGHT: number = STATUSBAR_HEIGHT;
|
|
88
|
+
static STATUSBAR_HEIGHT_MASTER: number = STATUSBAR_HEIGHT_MASTER;
|
|
89
|
+
static colorPrimary: string = colorPrimary;
|
|
90
|
+
static colorPrimaryDark: string = colorPrimaryDark;
|
|
91
|
+
static colorPrimaryMarket: string = colorPrimaryMarket;
|
|
92
|
+
static colorPrimaryMart: string = colorPrimaryMart;
|
|
93
|
+
static colorAccent: string = colorAccent;
|
|
94
|
+
static colorGrey: string = colorGrey;
|
|
95
|
+
static colorBrownLight: string = colorBrownLight;
|
|
96
|
+
static colorBgGrey: string = colorBgGrey;
|
|
97
|
+
static colorBrown: string = colorBrown;
|
|
98
|
+
static colorGreen: string = colorGreen;
|
|
99
|
+
static colorBlue: string = colorBlue;
|
|
100
|
+
static colorRed: string = colorRed;
|
|
101
|
+
static colorTextPrimary: string = colorTextPrimary;
|
|
102
|
+
static colorTextBody: string = colorTextBody;
|
|
103
|
+
static colorTextCaption: string = colorTextCaption;
|
|
104
|
+
static colorLightGrey: string = colorLightGrey;
|
|
105
|
+
static elevation(val: number): any { return elevation(val) };
|
|
106
|
+
static width: number = width;
|
|
107
|
+
static height: number = height;
|
|
108
|
+
static defaultStyle: any = defaultStyle;
|
|
109
|
+
static headerHeight: number = headerHeight;
|
|
92
110
|
}
|
package/modules/lib/toast.tsx
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
// noPage
|
|
3
|
+
|
|
4
|
+
// nunggu update master, margin sebelah kanan kegeser
|
|
5
|
+
|
|
3
6
|
import { LibStyle } from 'esoftplay/cache/lib/style/import';
|
|
4
7
|
import useGlobalState from 'esoftplay/global';
|
|
5
8
|
import React, { useEffect } from 'react';
|
|
6
|
-
import { Text } from 'react-native';
|
|
9
|
+
import { Text, View } from 'react-native';
|
|
7
10
|
import Animated, { interpolate, useAnimatedProps, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
8
11
|
|
|
9
12
|
export interface LibToastProps {
|
|
@@ -53,8 +56,10 @@ export default function m(props: LibToastProps): any {
|
|
|
53
56
|
}, [data])
|
|
54
57
|
|
|
55
58
|
return (
|
|
56
|
-
<Animated.View style={[{
|
|
57
|
-
<
|
|
59
|
+
<Animated.View pointerEvents={'none'} style={[{ flex: 1, position: 'absolute', justifyContent: 'center', alignContent: 'center', alignItems: 'center', top: LibStyle.STATUSBAR_HEIGHT + 20, left: 0, right: 0, }, style, LibStyle.elevation(2)]} >
|
|
60
|
+
<View style={{ maxWidth: Math.min(500, LibStyle.width - 30), minWidth: Math.min(500, LibStyle.width - 30), marginHorizontal: 15, marginVertical: 4, borderRadius: 4, borderWidth: 1, borderColor: '#505050', backgroundColor: '#323232', paddingVertical: 13, paddingHorizontal: 16, }} >
|
|
61
|
+
<Text style={{ fontSize: 14, textAlign: "center", color: 'white' }} >{String(data?.message || '')}</Text>
|
|
62
|
+
</View>
|
|
58
63
|
</Animated.View>
|
|
59
64
|
)
|
|
60
65
|
}
|
package/modules/lib/utils.ts
CHANGED
|
@@ -147,6 +147,7 @@ export default class eutils {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
static number(toNumber: string | number): string {
|
|
150
|
+
if (!toNumber) toNumber = '0'
|
|
150
151
|
var toNumb = typeof toNumber === "number" ? toNumber.toFixed(0).replace(/(\d)(?=(\d{3})+$)/g, "$1,") : parseInt(toNumber).toFixed(0).replace(/(\d)(?=(\d{3})+$)/g, "$1,")
|
|
151
152
|
return String(toNumb).replace(/,/g, ".");
|
|
152
153
|
}
|
package/modules/user/index.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { esp, useSafeState } from 'esoftplay';
|
|
|
4
4
|
import { LibDialog } from 'esoftplay/cache/lib/dialog/import';
|
|
5
5
|
import { LibIcon } from 'esoftplay/cache/lib/icon/import';
|
|
6
6
|
import { LibImage } from 'esoftplay/cache/lib/image/import';
|
|
7
|
+
import { LibLocale } from 'esoftplay/cache/lib/locale/import';
|
|
7
8
|
import { LibNavigation } from 'esoftplay/cache/lib/navigation/import';
|
|
8
9
|
import { LibNet_status } from 'esoftplay/cache/lib/net_status/import';
|
|
9
10
|
import { LibProgress } from 'esoftplay/cache/lib/progress/import';
|
|
@@ -19,6 +20,7 @@ import { UserHook } from 'esoftplay/cache/user/hook/import';
|
|
|
19
20
|
import { UserLoading } from 'esoftplay/cache/user/loading/import';
|
|
20
21
|
import { UserRoutes } from 'esoftplay/cache/user/routes/import';
|
|
21
22
|
import useGlobalState from 'esoftplay/global';
|
|
23
|
+
import moment from 'esoftplay/moment';
|
|
22
24
|
import * as Font from "expo-font";
|
|
23
25
|
import React, { useEffect, useLayoutEffect } from 'react';
|
|
24
26
|
import { Platform, Pressable, View } from 'react-native';
|
|
@@ -53,6 +55,8 @@ function setFonts(): Promise<void> {
|
|
|
53
55
|
|
|
54
56
|
const route = useGlobalState<any>(undefined, { persistKey: 'user_index_routes_initial', inFile: true })
|
|
55
57
|
export default function m(props: UserIndexProps): any {
|
|
58
|
+
const [langId] = LibLocale.state().useState()
|
|
59
|
+
moment().locale(langId)
|
|
56
60
|
const [loading, setLoading] = useSafeState(true)
|
|
57
61
|
const user = UserClass.state().useSelector(s => s)
|
|
58
62
|
const ready = React.useRef(0)
|
package/moment.ts
CHANGED
|
@@ -56,10 +56,11 @@ export default function moment(date?: string | Date | any) {
|
|
|
56
56
|
const out = dayjs(_date).tz(timeZone)
|
|
57
57
|
return moment(out)
|
|
58
58
|
},
|
|
59
|
-
locale: (locale_id:
|
|
59
|
+
locale: (locale_id: string) => {
|
|
60
60
|
require('dayjs/locale/en')
|
|
61
61
|
require('dayjs/locale/id')
|
|
62
|
-
|
|
62
|
+
require('dayjs/locale/id')
|
|
63
|
+
const out = dayjs.locale(locale_id)
|
|
63
64
|
return moment(out)
|
|
64
65
|
},
|
|
65
66
|
/* last chain */
|
package/package.json
CHANGED
package/state.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
type
|
|
3
|
+
type useSafeStateReturn<T> = [T | undefined, (value: T | undefined) => void, () => T];
|
|
4
4
|
|
|
5
|
-
export default function
|
|
5
|
+
export default function useSafeState<T = any>(defaultValue?: T): useSafeStateReturn<T> {
|
|
6
6
|
const isMountedRef = useRef<boolean>(true);
|
|
7
7
|
const [state, setState] = useState<T | undefined>(defaultValue);
|
|
8
8
|
|
|
@@ -13,6 +13,10 @@ export default function useRefState<T = any>(defaultValue?: T): UseRefStateResul
|
|
|
13
13
|
}
|
|
14
14
|
}, []);
|
|
15
15
|
|
|
16
|
+
const getter = () => {
|
|
17
|
+
return state
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
useEffect(() => {
|
|
17
21
|
isMountedRef.current = true;
|
|
18
22
|
return () => {
|
|
@@ -20,5 +24,5 @@ export default function useRefState<T = any>(defaultValue?: T): UseRefStateResul
|
|
|
20
24
|
};
|
|
21
25
|
}, []);
|
|
22
26
|
|
|
23
|
-
return [state, updateState];
|
|
27
|
+
return [state, updateState, getter];
|
|
24
28
|
}
|
package/subscribe.ts
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
|
|
5
|
-
export interface
|
|
6
|
-
getValue: (
|
|
5
|
+
export interface useGlobalSubscriberReturn {
|
|
6
|
+
getValue: () => any,
|
|
7
7
|
reset: () => void,
|
|
8
8
|
useSubscribe: Function,
|
|
9
9
|
trigger: (newValue?: any) => void
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export default function useGlobalSubscriber(defaultValue?: any):
|
|
12
|
+
export default function useGlobalSubscriber(defaultValue?: any): useGlobalSubscriberReturn {
|
|
13
13
|
const subscribers = new Set<Function>();
|
|
14
14
|
let value = defaultValue;
|
|
15
15
|
|