Skip to content

Commit 0dba973

Browse files
committed
Navigation rework
1 parent 7dada7c commit 0dba973

File tree

16 files changed

+142
-253
lines changed

16 files changed

+142
-253
lines changed

ForPDA.xcodeproj/project.pbxproj

Lines changed: 48 additions & 36 deletions
Large diffs are not rendered by default.

ForPDA.xcodeproj/xcshareddata/xcschemes/ForPDA.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1420"
3+
LastUpgradeVersion = "1500"
44
version = "1.7">
55
<BuildAction
66
parallelizeBuildables = "YES"

ForPDA/Sources/Application/SceneDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
3232
// Cold start deeplink
3333
handleDeeplinkUrl(url)
3434
} else {
35-
try? DefaultRouter().navigate(to: RouteMap.tabBarScreen, with: nil)
35+
try? DefaultRouter().navigate(to: RouteMap.newsScreen, with: nil)
3636
}
3737
}
3838

ForPDA/Sources/Coordinator/RouteMap.swift

Lines changed: 14 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,20 @@ protocol RouteMapProtocol {
1515

1616
struct RouteMap: RouteMapProtocol {
1717

18-
// MARK: - [TabBar]
19-
20-
static var tabBarScreen: DestinationStep<PDATabBarController, Any?> {
21-
StepAssembly(
22-
finder: ClassFinder(), // В чем разница с <PDATabBarController, Any?>(options: .current, startingPoint: .root)?
23-
factory: CompleteFactoryAssembly(factory: PDATabBarControllerFactory<PDATabBarController, Any?>())
24-
.with(createNewsWithNavigationFactory(), using: PDATabBarController.add())
25-
.with(createForumWithNavigationFactory(), using: PDATabBarController.add())
26-
.with(createMenuWithNavigationFactory(), using: PDATabBarController.add())
27-
.assemble())
28-
.using(GeneralAction.replaceRoot())
29-
.from(GeneralStep.root())
30-
.assemble()
31-
}
32-
3318
// MARK: - [News]
3419

3520
static var newsScreen: DestinationStep<NewsVC, Any?> {
3621
StepAssembly(
37-
finder: ClassFinder<NewsVC, Any?>(),
38-
factory: NilFactory())
39-
.from(tabBarScreen)
22+
finder: ClassFinder(),
23+
factory: NewsFactory()
24+
)
25+
.using(PDANavigationController.push())
26+
.from(SingleContainerStep(
27+
finder: NilFinder(),
28+
factory: NavigationControllerFactory<PDANavigationController, Any?>())
29+
)
30+
.using(GeneralAction.replaceRoot())
31+
.from(GeneralStep.root())
4032
.assemble()
4133
}
4234

@@ -51,22 +43,14 @@ struct RouteMap: RouteMapProtocol {
5143
.assemble()
5244
}
5345

54-
// MARK: - [Forum]
55-
56-
static var forumScreen: DestinationStep<ForumVC, Any?> {
57-
StepAssembly(finder: ClassFinder<ForumVC, Any?>(),
58-
factory: NilFactory())
59-
.from(tabBarScreen)
60-
.assemble()
61-
}
62-
6346
// MARK: - [Menu]
6447

6548
static var menuScreen: DestinationStep<MenuVC, Any?> {
6649
StepAssembly(
67-
finder: ClassFinder<MenuVC, Any?>(),
68-
factory: NilFactory())
69-
.from(tabBarScreen)
50+
finder: ClassFinder(),
51+
factory: MenuFactory())
52+
.using(UINavigationController.push())
53+
.from(newsScreen.expectingContainer())
7054
.assemble()
7155
}
7256

@@ -79,7 +63,6 @@ struct RouteMap: RouteMapProtocol {
7963
.adding(LoginInterceptor())
8064
.using(UINavigationController.push())
8165
.from(menuScreen.expectingContainer())
82-
// .from(GeneralStep.custom(using: ClassFinder<UINavigationController, Any?>()))
8366
.assemble()
8467
}
8568

@@ -115,29 +98,3 @@ struct LoginConfiguration {
11598
// .assemble()
11699
// }
117100
}
118-
119-
// MARK: - NavCon Factories
120-
121-
extension RouteMap {
122-
123-
static func createNewsWithNavigationFactory() -> CompleteFactory<NavigationControllerFactory<UINavigationController, Any?>> {
124-
return CompleteFactoryAssembly(
125-
factory: NavigationControllerFactory())
126-
.with(NewsFactory(), using: UINavigationController.pushAsRoot())
127-
.assemble()
128-
}
129-
130-
static func createForumWithNavigationFactory() -> CompleteFactory<NavigationControllerFactory<UINavigationController, Any?>> {
131-
return CompleteFactoryAssembly(
132-
factory: NavigationControllerFactory())
133-
.with(ForumFactory(), using: UINavigationController.pushAsRoot())
134-
.assemble()
135-
}
136-
137-
static func createMenuWithNavigationFactory() -> CompleteFactory<NavigationControllerFactory<UINavigationController, Any?>> {
138-
return CompleteFactoryAssembly(
139-
factory: NavigationControllerFactory())
140-
.with(MenuFactory(), using: UINavigationController.pushAsRoot())
141-
.assemble()
142-
}
143-
}

ForPDA/Sources/Models/AppLanguage.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
// swiftlint:disable identifier_name
88

99
enum AppLanguage: String {
10-
case auto
11-
case ru
12-
case en
10+
case en, ru
1311
}

ForPDA/Sources/Modules/Login/LoginVC.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ final class LoginVC: PDAViewController<LoginView> {
5151

5252
override func viewWillDisappear(_ animated: Bool) {
5353
super.viewWillDisappear(animated)
54-
navigationController?.setNavigationBarHidden(true, animated: true)
5554
if isMovingFromParent {
5655
interceptorCompletionBlock?(.failure(FailingRouterIgnoreError(
5756
underlyingError: RoutingError.generic(.init("User tapped back button")))))

ForPDA/Sources/Modules/Menu/MenuFactory.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ final class MenuFactory: Factory {
1616
let presenter = MenuPresenter()
1717
let viewController = ViewController(presenter: presenter)
1818
presenter.view = viewController
19-
// presenter.context = context
2019

21-
viewController.setTabBarItemWith(
22-
title: R.string.localizable.menu(),
23-
sfSymbol: .listDash
24-
)
20+
viewController.title = R.string.localizable.menu()
2521

2622
return viewController
2723
}

ForPDA/Sources/Modules/Menu/MenuPresenter.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,11 @@ final class MenuPresenter: MenuPresenterProtocol {
2929
]),
3030

3131
MenuSection(options: [
32-
.staticCell(model: MenuOption(title: R.string.localizable.news(),
33-
icon: .newspaperFill, handler: showNewsScreen)),
34-
35-
// .staticCell(model: MenuOption(title: R.string.localizable.search(),
36-
// icon: .magnifyingglass, handler: showSearchScreen)),
37-
38-
.staticCell(model: MenuOption(title: R.string.localizable.forum(),
39-
icon: .bubbleLeftAndBubbleRightFill, handler: showForumScreen)),
40-
4132
.staticCell(model: MenuOption(title: R.string.localizable.history(),
4233
icon: .clockArrowCirclepath, handler: showDefaultError)),
4334

4435
.staticCell(model: MenuOption(title: R.string.localizable.bookmarks(),
4536
icon: .bookmarkFill, handler: showDefaultError))
46-
47-
// .staticCell(model: MenuOption(title: R.string.localizable.forumRules(),
48-
// icon: .bookFill, handler: {}))
4937
]),
5038

5139
MenuSection(options: [
@@ -132,14 +120,6 @@ final class MenuPresenter: MenuPresenterProtocol {
132120
try? DefaultRouter().navigate(to: RouteMap.profileScreen, with: nil)
133121
}
134122

135-
private func showNewsScreen() {
136-
try? DefaultRouter().navigate(to: RouteMap.newsScreen, with: nil)
137-
}
138-
139-
private func showForumScreen() {
140-
try? DefaultRouter().navigate(to: RouteMap.forumScreen, with: nil)
141-
}
142-
143123
private func showSettingsScreen() {
144124
try? DefaultRouter().navigate(to: RouteMap.settingsScreen, with: nil)
145125
}

ForPDA/Sources/Modules/Menu/MenuVC.swift

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,16 @@ final class MenuVC: PDAViewController<MenuView> {
3030
override func viewDidLoad() {
3131
super.viewDidLoad()
3232

33-
setDelegates()
34-
configureNavBar()
35-
}
36-
37-
override func viewWillAppear(_ animated: Bool) {
38-
super.viewWillAppear(animated)
39-
navigationController?.setNavigationBarHidden(true, animated: false)
40-
}
41-
42-
override func viewWillDisappear(_ animated: Bool) {
43-
super.viewWillDisappear(animated)
44-
navigationController?.setNavigationBarHidden(false, animated: true)
33+
configureController()
4534
}
4635

4736
// MARK: - Configure
4837

49-
private func setDelegates() {
38+
private func configureController() {
39+
title = R.string.localizable.menu()
5040
myView.tableView.dataSource = self
5141
myView.tableView.delegate = self
5242
}
53-
54-
private func configureNavBar() {
55-
navigationController?.setNavigationBarHidden(true, animated: false)
56-
}
5743
}
5844

5945
// MARK: - DataSource & Delegates
@@ -72,18 +58,26 @@ extension MenuVC: UITableViewDataSource, UITableViewDelegate {
7258
return indexPath.section == 0 ? 60 : 46
7359
}
7460

61+
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
62+
return section == 0 ? 16 : 0
63+
}
64+
7565
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
7666
let model = presenter.sections[indexPath.section].options[indexPath.row]
7767

7868
switch model.self {
7969
case .authCell:
8070
let cell = tableView.dequeueReusableCell(withClass: MenuAuthCell.self)
8171
if let user = presenter.user {
82-
let imageOptions = ImageLoadingOptions(placeholder: R.image.avatarPlaceholder(),
83-
failureImage: R.image.avatarPlaceholder())
84-
NukeExtensions.loadImage(with: URL(string: presenter.user?.avatarUrl),
85-
options: imageOptions,
86-
into: cell.iconImageView) { _ in }
72+
let imageOptions = ImageLoadingOptions(
73+
placeholder: R.image.avatarPlaceholder(),
74+
failureImage: R.image.avatarPlaceholder()
75+
)
76+
NukeExtensions.loadImage(
77+
with: URL(string: presenter.user?.avatarUrl),
78+
options: imageOptions,
79+
into: cell.iconImageView
80+
) { _ in }
8781
cell.titleLabel.text = user.nickname
8882
cell.subtitleLabel.text = R.string.localizable.goToProfile()
8983
}
@@ -121,9 +115,11 @@ extension MenuVC: UITableViewDataSource, UITableViewDelegate {
121115
extension MenuVC: MenuVCProtocol {
122116

123117
func showDefaultError() {
124-
let alert = UIAlertController(title: R.string.localizable.whoops(),
125-
message: R.string.localizable.notDoneYet(),
126-
preferredStyle: .alert)
118+
let alert = UIAlertController(
119+
title: R.string.localizable.whoops(),
120+
message: R.string.localizable.notDoneYet(),
121+
preferredStyle: .alert
122+
)
127123
let action = UIAlertAction(title: R.string.localizable.ok(), style: .default)
128124
alert.addAction(action)
129125
present(alert, animated: true)

ForPDA/Sources/Modules/News/NewsFactory.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@ final class NewsFactory: Factory {
1616
let presenter = NewsPresenter()
1717
let viewController = ViewController(presenter: presenter)
1818
presenter.view = viewController
19-
// presenter.context = context
2019

2120
viewController.title = R.string.localizable.news()
2221

23-
viewController.setTabBarItemWith(
24-
title: R.string.localizable.news(),
25-
sfSymbol: .newspaperFill
26-
)
27-
2822
return viewController
2923
}
3024
}

0 commit comments

Comments
 (0)