Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf4b9caa

Browse files
committed
[Navigation] Handle NavController Back Bar Button Correctly
1 parent5da00e7 commitf4b9caa

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

‎SwiftFlowGitHubBrowser/ViewControllers/BookmarkViewController.swift‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ class BookmarkViewController: UIViewController, StoreSubscriber {
4545
super.viewWillDisappear(animated)
4646

4747
store.unsubscribe(self)
48+
49+
// Required to update the route, when this VC was dismissed through back button from
50+
// NavigationController, since we can't intercept the back button
51+
if store.state.navigationState.route==[mainViewRoute, bookmarkRoute]{
52+
store.dispatch(SetRouteAction([mainViewRoute]))
53+
}
4854
}
4955

5056
func newState(state:[Bookmark]){

‎SwiftFlowGitHubBrowser/ViewControllers/MainViewController.swift‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ class MainViewController: UIViewController, StoreSubscriber {
3030
overridefunc viewWillAppear(animated:Bool){
3131
super.viewWillAppear(animated)
3232

33-
// Required to update the route, when this VC was presented through back button from
34-
// NavigationController, since we can't intercept the back button
35-
store.dispatch(SetRouteAction([mainViewRoute]))
36-
3733
store.subscribe(self){ statein
3834
state.repositories
3935
}

‎SwiftFlowGitHubBrowser/ViewControllers/RepositoryDetailViewController.swift‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class RepositoryDetailViewController: UIViewController, StoreSubscriber {
2323

2424
store.subscribe(self){ statein
2525
(
26-
state.navigationState.getRouteSpecificState(state.navigationState.route)asAny?,
26+
state.navigationState.getRouteSpecificState(state.navigationState.route),
2727
state.bookmarks
2828
)
2929
}
@@ -33,14 +33,18 @@ class RepositoryDetailViewController: UIViewController, StoreSubscriber {
3333
super.viewWillDisappear(animated)
3434

3535
store.unsubscribe(self)
36-
}
3736

38-
func newState(state:(selectedRepository:Any?, bookmarks:[Bookmark])){
39-
guardlet selectedRepository= state.selectedRepositoryas?Repository?else{return}
37+
// Required to update the route, when this VC was dismissed through back button from
38+
// NavigationController, since we can't intercept the back button
39+
if store.state.navigationState.route==[mainViewRoute, repositoryDetailRoute]{
40+
store.dispatch(SetRouteAction([mainViewRoute]))
41+
}
42+
}
4043

41-
self.repository= selectedRepository
42-
self.mainLabel.text= selectedRepository?.name??""
43-
self.title= selectedRepository?.name??""
44+
func newState(state:(selectedRepository:Repository?, bookmarks:[Bookmark])){
45+
self.repository= state.selectedRepository
46+
self.mainLabel.text= state.selectedRepository?.name??""
47+
self.title= state.selectedRepository?.name??""
4448

4549
letbookmarkActive= !state.bookmarks.contains{ route, datain
4650
guardlet repository= dataas?Repositoryelse{returnfalse}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp