Change tab on visit, based on path configuration #258
-
|
We have a dashboard, which has link to announcement. Opening the announcement from dashboard pushes new screen, as expected, on dashboard tab. I tried this, using path configuration properties: func handle(proposal: VisitProposal, from navigator: Navigator) -> ProposalResult {
let tab = proposal.properties["tab", default: ""]
print(tab as! String)
switch tab as! String {
case "announcements":
tabBarController.selectedIndex = 3
return .accept
default:
return .accept
}But that only changes tab, and doesnt add new screen with announcement. Is it possible to change the tab and navigator and finish the visit there? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I found out the answer while I was writing the question (it was sort of rubber duck i guess), but I did publish it, so it may help someone, or there might be some problems in my solution someone will point out. I ended with this: // SceneDelegate.swift
func handle(proposal: VisitProposal, from navigator: Navigator) -> ProposalResult {
let tab = proposal.properties["tab", default: ""]
switch tab as! String {
case "announcements":
if (tabBarController.selectedIndex == 3) {
return .accept
}
tabBarController.selectedIndex = 3
tabBarController.navigator(for: HotwireTab.announcements)?.route(proposal)
return .reject
default:
break
}// path-configuration.json
...
{
"patterns": [
"/announcements/[0-9]+$"
],
"properties": {
"tab": "announcements"
}
}
...// Tabs.swift
...
extension HotwireTab {
static let all = [
dashboardTab,
reporterTab,
eventsTab,
announcementsTab,
otherTab
]
static let announcements = announcementsTab
}I will probably do some renaming, as well as setting index number dynamically, or at least from Tabs file. But the core idea is here, and seems to beworking |
Beta Was this translation helpful? Give feedback.
I found out the answer while I was writing the question (it was sort of rubber duck i guess), but I did publish it, so it may help someone, or there might be some problems in my solution someone will point out.
I ended with this: