Skip to content

Commit

Permalink
Merge pull request #18 from Mindera/ALFMOB-52-remove-back-button-on-w…
Browse files Browse the repository at this point in the history
…ishlist-screen-when-there-is-nothing-to-go-back-for

[ALFMOB-52]: Remove back button on wishlist screen when there is nothing to go back for
  • Loading branch information
JoaoPinhoMinder authored Jan 8, 2025
2 parents d68505a + 4fb1b82 commit f0e652e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Alfie/Alfie/Helpers/ToolbarItemProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ enum ToolbarItemProvider {
.productDetails,
.productListing,
.categoryList:
backButton(with: coordinator)
if coordinator.canPop() {
backButton(with: coordinator)
} else {
EmptyView()
}

default:
EmptyView()
Expand Down
4 changes: 4 additions & 0 deletions Alfie/Alfie/Navigation/Coordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ final class Coordinator: ObservableObject, CoordinatorProtocol {
navigationAdapter.popToRoot()
}

public func canPop() -> Bool {
navigationAdapter.canPop()
}

// MARK: Search

public func openSearch() {
Expand Down
10 changes: 10 additions & 0 deletions Alfie/Packages/Navigation/Sources/NavigationAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,13 @@ extension NavigationAdapter {
}
}
}

// MARK: - Auxiliar methods

extension NavigationAdapter {
public func canPop() -> Bool {
modalPath.count >= 1 ||
path.count >= 1 ||
isPresentingFullScreenOverlay
}
}

0 comments on commit f0e652e

Please sign in to comment.