From d43acb8593d7ed82e4fcb27623d0583169cde840 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 21 Nov 2019 15:41:27 +0100 Subject: [PATCH] Display informational footer on empty favorites --- .../Global/SwiftGen+Strings.swift | 6 ++++++ Passepartout-iOS/Global/en.lproj/App.strings | 1 + .../Scenes/ProviderPoolViewController.swift | 20 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/Passepartout-iOS/Global/SwiftGen+Strings.swift b/Passepartout-iOS/Global/SwiftGen+Strings.swift index 8e52a509..a351a67b 100644 --- a/Passepartout-iOS/Global/SwiftGen+Strings.swift +++ b/Passepartout-iOS/Global/SwiftGen+Strings.swift @@ -76,6 +76,12 @@ internal enum L10n { /// Unfavorite internal static let unfavorite = L10n.tr("App", "provider.pool.actions.unfavorite") } + internal enum Sections { + internal enum EmptyFavorites { + /// Swipe left on a location to add or remove it from Favorites. + internal static let footer = L10n.tr("App", "provider.pool.sections.empty_favorites.footer") + } + } } internal enum Preset { internal enum Cells { diff --git a/Passepartout-iOS/Global/en.lproj/App.strings b/Passepartout-iOS/Global/en.lproj/App.strings index 93755369..a32a1052 100644 --- a/Passepartout-iOS/Global/en.lproj/App.strings +++ b/Passepartout-iOS/Global/en.lproj/App.strings @@ -50,6 +50,7 @@ "provider.pool.actions.favorite" = "Favorite"; "provider.pool.actions.unfavorite" = "Unfavorite"; +"provider.pool.sections.empty_favorites.footer" = "Swipe left on a location to add or remove it from Favorites."; "provider.preset.cells.tech_details.caption" = "Technical details"; diff --git a/Passepartout-iOS/Scenes/ProviderPoolViewController.swift b/Passepartout-iOS/Scenes/ProviderPoolViewController.swift index da204dae..fdf6ab1f 100644 --- a/Passepartout-iOS/Scenes/ProviderPoolViewController.swift +++ b/Passepartout-iOS/Scenes/ProviderPoolViewController.swift @@ -153,10 +153,16 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate } func numberOfSections(in tableView: UITableView) -> Int { + if isShowingEmptyFavorites { + return 1 + } return categories.count } func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + if isShowingEmptyFavorites { + return nil + } if categories.count == 1 && categories.first?.name == "" { return nil } @@ -164,7 +170,17 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate return model.name } + func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { + if isShowingEmptyFavorites { + return L10n.App.Provider.Pool.Sections.EmptyFavorites.footer + } + return nil + } + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if isShowingEmptyFavorites { + return 0 + } let model = categories[section] return model.groups.count } @@ -267,4 +283,8 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate private var categories: [PoolCategory] { return isShowingFavorites ? favoriteCategories : allCategories } + + private var isShowingEmptyFavorites: Bool { + return isShowingFavorites && favoriteGroupIds.isEmpty + } }