esoftplay 0.0.240 → 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 +40 -22
- package/package.json +1 -1
|
@@ -93,20 +93,24 @@ export default {
|
|
|
93
93
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#navigate) untuk melihat dokumentasi*/
|
|
94
94
|
navigate<S extends keyof EspArgsInterface>(route: S, params?: EspArgsInterface[S]): void {
|
|
95
95
|
logArgs(params)
|
|
96
|
-
|
|
96
|
+
doIt(() => {
|
|
97
|
+
this._ref?.navigate?.(replaceModuleByUrlParam(params, route), params)
|
|
98
|
+
})
|
|
97
99
|
},
|
|
98
100
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#navigateTab) untuk melihat dokumentasi*/
|
|
99
101
|
navigateTab<S extends keyof EspArgsInterface>(route: S, tabIndex: number, params?: EspArgsInterface[S]): void {
|
|
100
102
|
logArgs(params)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
+
})
|
|
110
114
|
},
|
|
111
115
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#createTabConfig) untuk melihat dokumentasi*/
|
|
112
116
|
createTabConfig<S extends keyof EspArgsInterface>(modules: S[], defaultIndex?: number): useGlobalReturn<LibNavigationTabConfigReturn<S>> {
|
|
@@ -172,34 +176,41 @@ export default {
|
|
|
172
176
|
r(value)
|
|
173
177
|
};
|
|
174
178
|
}
|
|
175
|
-
|
|
176
|
-
|
|
179
|
+
doIt(() => {
|
|
180
|
+
this.push(replaceModuleByUrlParam(params, route), params)
|
|
181
|
+
})
|
|
177
182
|
})
|
|
178
183
|
},
|
|
179
184
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#replace) untuk melihat dokumentasi*/
|
|
180
185
|
replace<S extends keyof EspArgsInterface>(route: S, params?: EspArgsInterface[S]): void {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
186
|
+
doIt(() => {
|
|
187
|
+
this._ref.dispatch(
|
|
188
|
+
StackActions.replace(replaceModuleByUrlParam(params, route), params)
|
|
189
|
+
)
|
|
190
|
+
})
|
|
185
191
|
},
|
|
186
192
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#push) untuk melihat dokumentasi*/
|
|
187
193
|
push<S extends keyof EspArgsInterface>(route: S, params?: EspArgsInterface[S]): void {
|
|
188
194
|
logArgs(params)
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
195
|
+
doIt(() => {
|
|
196
|
+
|
|
197
|
+
this._ref?.dispatch?.(
|
|
198
|
+
StackActions.push(
|
|
199
|
+
replaceModuleByUrlParam(params, route),
|
|
200
|
+
params
|
|
201
|
+
)
|
|
193
202
|
)
|
|
194
|
-
)
|
|
203
|
+
})
|
|
195
204
|
},
|
|
196
205
|
/** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/navigation.md#reset) untuk melihat dokumentasi*/
|
|
197
206
|
reset(route?: LibNavigationRoutes, ...routes: LibNavigationRoutes[]): void {
|
|
207
|
+
|
|
198
208
|
const user = UserClass.state().get()
|
|
199
209
|
let _route = [route || esp.config('home', (user && (user.id || user.user_id || user.apikey)) ? 'member' : 'public')]
|
|
200
210
|
if (routes && routes.length > 0) {
|
|
201
211
|
_route = [..._route, ...routes]
|
|
202
212
|
}
|
|
213
|
+
// this._ref?.dispatch?.(StackActions.popToTop());
|
|
203
214
|
const resetAction = CommonActions.reset({
|
|
204
215
|
index: _route.length - 1,
|
|
205
216
|
routes: _route.map((rn) => ({ name: rn }))
|
|
@@ -210,7 +221,9 @@ export default {
|
|
|
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)
|