Skip to content

Commit

Permalink
Refactoring navigationItem.title
Browse files Browse the repository at this point in the history
  • Loading branch information
Camilla Copetti committed Dec 6, 2024
1 parent bf312fa commit 7382bcb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,6 @@ private extension AppCoordinator {
func showNewsDetails(newsId: String, sender: Any?) {
guard let topViewController
else { return }

// TODO: remove after title refactor
func configureBindings(
viewModel: NewsDetailsViewModel,
pageViewController: NewsPageViewController
) {
viewModel.$result
.compactMap { $0 }
.receive(on: DispatchQueue.main)
.sink { [weak pageViewController] news in
pageViewController?.navigationItem.title = localizedValue(
from: news.languageToDetails
)?
.title
}
.store(in: &subscriptions)
}

let viewModel = dependencyContainer.makeNewsDetailsViewModel(
newsId: newsId
Expand Down Expand Up @@ -255,12 +238,6 @@ private extension AppCoordinator {
return pageVC
}()

// TODO: remove after title refactor
configureBindings(
viewModel: viewModel,
pageViewController: pageVC
)

topViewController.present(
NavigationController(rootViewController: pageVC),
animated: true
Expand Down Expand Up @@ -315,21 +292,7 @@ private extension AppCoordinator {
func showEventDetails(eventId: String, sender: Any?) {
guard let topViewController
else { return }

// TODO: move set navigationItem title here
func configureBindings(
viewModel: EventDetailsViewModel,
pageViewController: EventPageViewController
) {
viewModel.$result
.compactMap { $0 }
.receive(on: DispatchQueue.main)
.sink { [weak pageViewController] event in
pageViewController?.navigationItem.title = event.title
}
.store(in: &subscriptions)
}


let viewModel = dependencyContainer.makeEventDetailsViewModel(
eventId: eventId
)
Expand Down Expand Up @@ -357,10 +320,7 @@ private extension AppCoordinator {

self?.signupEvent($0, from: pageVC)
}

// TODO: move set navigationItem title here
pageVC.navigationItem.title = nil

pageVC.navigationItem.title = nil
pageVC.navigationItem.largeTitleDisplayMode = .never
pageVC.navigationItem.leftBarButtonItem = UIBarButtonItem(
image: UIImage(systemName: "xmark.circle.fill"),
Expand All @@ -372,8 +332,6 @@ private extension AppCoordinator {
return pageVC
}()

configureBindings(viewModel: viewModel, pageViewController: pageVC)

topViewController.present(
NavigationController(rootViewController: pageVC),
animated: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ private extension EventsCoordinator {
pageVC.signupActionHandler = { [weak self] in
self?.signupEvent($0)
}

// TODO: remove after title refactor
pageVC.navigationItem.title = event.title

pageVC.navigationItem.largeTitleDisplayMode = .never

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class EventPageViewController: BasePageViewController<EventDetailsViewMode
else { return }

// TODO: move set navigationItem title here
self.navigationItem.title = event.title
self.show(content: self.makeResultContent(for: event))
}
.store(in: &subscriptions)
Expand Down
7 changes: 1 addition & 6 deletions NOICommunity/NewsFeature/Coordinators/NewsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ private extension NewsCoordinator {
pageVC.askQuestionActionHandler = { [weak self] in
self?.showAskAQuestion(for: $0)
}

// TODO: move set navigationItem title here
pageVC.navigationItem.title = localizedValue(
from: news.languageToDetails
)?
.title

pageVC.navigationItem.largeTitleDisplayMode = .never

return pageVC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ final class NewsPageViewController: BasePageViewController<NewsDetailsViewModel>
.sink { [weak self] event in
guard let self
else { return }

// TODO: move set navigationItem title here
self.navigationItem.title = localizedValue(
from: event.languageToDetails
)?
.title

self.show(content: self.makeResultContent(for: event))
}
Expand Down

0 comments on commit 7382bcb

Please sign in to comment.