feat(mobile): emit screen change events on route appearance and disappearance

- Added event emissions for screen changes when a route appears or disappears, including the screen ID and route details.
- Updated the ScreenChangeEventPayload type to optionally include route information.

These changes enhance navigation tracking within the mobile application.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei 2025-03-21 18:36:50 +08:00
parent 18081805c2
commit fca0a94e6e
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
1 changed files with 3 additions and 0 deletions

View File

@ -42,6 +42,7 @@ export class Navigation {
route.id = `${route.id}-${this.viewIdCounter++}`
}
jotaiStore.set(this.ctxValue.routesAtom, [...routes, route])
this.emit("screenChange", { screenId: route.id, type: "appear", route })
}
private resolveScreenOptions<T>(
@ -94,6 +95,7 @@ export class Navigation {
return
}
jotaiStore.set(this.ctxValue.routesAtom, routes.slice(0, -1))
this.emit("screenChange", { screenId: lastRoute.id, type: "disappear", route: lastRoute })
}
/**
@ -177,4 +179,5 @@ type LifecycleEventPayload = {
type ScreenChangeEventPayload = {
screenId: string
type: "appear" | "disappear"
route?: Route
}