Display informational footer on empty favorites
This commit is contained in:
parent
7865f6a697
commit
d43acb8593
|
@ -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 {
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue