Skip to content

Commit

Permalink
List view filter for video and audio
Browse files Browse the repository at this point in the history
  • Loading branch information
livid committed Oct 18, 2024
1 parent 0cef138 commit b0b3b6f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Planet/Views/Articles/ArticleListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ struct ArticleListView: View {
}
return false
}
case .videos:
return articles.filter {
if let myArticle = $0 as? MyArticleModel {
return myArticle.videoFilename != nil
}
if let followingArticle = $0 as? FollowingArticleModel {
return followingArticle.videoFilename != nil
}
return false
}
case .audios:
return articles.filter {
if let myArticle = $0 as? MyArticleModel {
return myArticle.audioFilename != nil
}
if let followingArticle = $0 as? FollowingArticleModel {
return followingArticle.audioFilename != nil
}
return false
}
case .nav:
return articles.filter {
if let myArticle = $0 as? MyArticleModel,
Expand Down
8 changes: 8 additions & 0 deletions Planet/Views/Articles/ArticleListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Foundation
enum ListViewFilter: String, CaseIterable {
case all = "All"
case pages = "Pages"
case videos = "Videos"
case audios = "Audios"
case nav = "Navigation Items"
case unread = "Unread"
case starred = "Starred"
Expand All @@ -29,6 +31,8 @@ enum ListViewFilter: String, CaseIterable {
static let buttonLabels: [String: String] = [
"All": "Show All",
"Pages": "Show Pages",
"Videos": "Show Videos",
"Audios": "Show Audios",
"Navigation Items": "Show Navigation Items",
"Unread": "Show Unread",
"Starred": "Show All Starred",
Expand All @@ -37,6 +41,8 @@ enum ListViewFilter: String, CaseIterable {
static let emptyLabels: [String: String] = [
"All": "No Articles",
"Pages": "No Pages",
"Videos": "No Videos",
"Audios": "No Audios",
"Navigation Items": "No Navigation Items",
"Unread": "No Unread Articles",
"Starred": "No Starred Articles",
Expand All @@ -53,6 +59,8 @@ enum ListViewFilter: String, CaseIterable {
static let imageNames: [String: String] = [
"All": "line.3.horizontal.circle",
"Pages": "doc.text",
"Videos": "film",
"Audios": "waveform",
"Navigation Items": "link.circle",
"Unread": "line.3.horizontal.circle.fill",
"Starred": "star.fill",
Expand Down

0 comments on commit b0b3b6f

Please sign in to comment.