esoftplay 0.0.239 → 0.0.241
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/modules/lib/navigation.ts +52 -34
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// noPage
|
|
2
2
|
// withObject
|
|
3
|
-
import { StackActions } from '@react-navigation/native';
|
|
3
|
+
import { CommonActions, StackActions } from '@react-navigation/native';
|
|
4
4
|
import { LibNavigationRoutes } from 'esoftplay';
|
|
5
5
|
import { EspArgsInterface } from 'esoftplay/cache/args';
|
|
6
6
|
import { LibUtils } from 'esoftplay/cache/lib/utils/import';
|
|
7
7
|
import { EspRouterInterface } from 'esoftplay/cache/routers';
|
|
8
|
+
import { UserClass } from 'esoftplay/cache/user/class/import';
|
|
8
9
|
import { UserRoutes } from 'esoftplay/cache/user/routes/import';
|
|
9
10
|
|
|
10
11
|
import esp from 'esoftplay/esp';
|
|
@@ -92,20 +93,24 @@ export default {
|
|
|
92
93
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#navigate) untuk melihat dokumentasi*/
|
|
93
94
|
navigate<S extends keyof EspArgsInterface>(route: S, params?: EspArgsInterface[S]): void {
|
|
94
95
|
logArgs(params)
|
|
95
|
-
|
|
96
|
+
doIt(() => {
|
|
97
|
+
this._ref?.navigate?.(replaceModuleByUrlParam(params, route), params)
|
|
98
|
+
})
|
|
96
99
|
},
|
|
97
100
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#navigateTab) untuk melihat dokumentasi*/
|
|
98
101
|
navigateTab<S extends keyof EspArgsInterface>(route: S, tabIndex: number, params?: EspArgsInterface[S]): void {
|
|
99
102
|
logArgs(params)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
doIt(() => {
|
|
104
|
+
this._ref?.navigate?.(replaceModuleByUrlParam(params, route), params)
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
const TabConfig = esp.modProp(replaceModuleByUrlParam(params, route))?.TabConfig;
|
|
107
|
+
if (TabConfig) {
|
|
108
|
+
TabConfig.set(esp.mod("lib/object").set(TabConfig.get(), tabIndex)('activeIndex'))
|
|
109
|
+
} else {
|
|
110
|
+
console.error("TabConfig not found or exported in module " + route);
|
|
111
|
+
}
|
|
112
|
+
}, 100);
|
|
113
|
+
})
|
|
109
114
|
},
|
|
110
115
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#createTabConfig) untuk melihat dokumentasi*/
|
|
111
116
|
createTabConfig<S extends keyof EspArgsInterface>(modules: S[], defaultIndex?: number): useGlobalReturn<LibNavigationTabConfigReturn<S>> {
|
|
@@ -171,46 +176,54 @@ export default {
|
|
|
171
176
|
r(value)
|
|
172
177
|
};
|
|
173
178
|
}
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
doIt(() => {
|
|
180
|
+
this.push(replaceModuleByUrlParam(params, route), params)
|
|
181
|
+
})
|
|
176
182
|
})
|
|
177
183
|
},
|
|
178
184
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#replace) untuk melihat dokumentasi*/
|
|
179
185
|
replace<S extends keyof EspArgsInterface>(route: S, params?: EspArgsInterface[S]): void {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
186
|
+
doIt(() => {
|
|
187
|
+
this._ref.dispatch(
|
|
188
|
+
StackActions.replace(replaceModuleByUrlParam(params, route), params)
|
|
189
|
+
)
|
|
190
|
+
})
|
|
184
191
|
},
|
|
185
192
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#push) untuk melihat dokumentasi*/
|
|
186
193
|
push<S extends keyof EspArgsInterface>(route: S, params?: EspArgsInterface[S]): void {
|
|
187
194
|
logArgs(params)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
doIt(() => {
|
|
196
|
+
|
|
197
|
+
this._ref?.dispatch?.(
|
|
198
|
+
StackActions.push(
|
|
199
|
+
replaceModuleByUrlParam(params, route),
|
|
200
|
+
params
|
|
201
|
+
)
|
|
192
202
|
)
|
|
193
|
-
)
|
|
203
|
+
})
|
|
194
204
|
},
|
|
195
205
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#reset) untuk melihat dokumentasi*/
|
|
196
206
|
reset(route?: LibNavigationRoutes, ...routes: LibNavigationRoutes[]): void {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
//
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
|
|
208
|
+
const user = UserClass.state().get()
|
|
209
|
+
let _route = [route || esp.config('home', (user && (user.id || user.user_id || user.apikey)) ? 'member' : 'public')]
|
|
210
|
+
if (routes && routes.length > 0) {
|
|
211
|
+
_route = [..._route, ...routes]
|
|
212
|
+
}
|
|
213
|
+
// this._ref?.dispatch?.(StackActions.popToTop());
|
|
214
|
+
const resetAction = CommonActions.reset({
|
|
215
|
+
index: _route.length - 1,
|
|
216
|
+
routes: _route.map((rn) => ({ name: rn }))
|
|
217
|
+
});
|
|
218
|
+
this._ref?.dispatch?.(resetAction);
|
|
208
219
|
},
|
|
209
220
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#back) untuk melihat dokumentasi*/
|
|
210
221
|
back(deep?: number): void {
|
|
211
222
|
let _deep = deep || 1
|
|
212
223
|
const popAction = StackActions.pop(_deep);
|
|
213
|
-
|
|
224
|
+
doIt(() => {
|
|
225
|
+
this._ref?.dispatch?.(popAction)
|
|
226
|
+
})
|
|
214
227
|
},
|
|
215
228
|
|
|
216
229
|
/* return `root` on initialRoute otherwise return the route was active */
|
|
@@ -233,6 +246,11 @@ export default {
|
|
|
233
246
|
}
|
|
234
247
|
}
|
|
235
248
|
|
|
249
|
+
function doIt(func: Function) {
|
|
250
|
+
requestAnimationFrame(() => func())
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
236
254
|
function replaceModuleByUrlParam<S extends keyof EspArgsInterface>(params: any, defaultModule: S) {
|
|
237
255
|
let module = defaultModule
|
|
238
256
|
logArgs(params)
|