View bookmarks

This commit is contained in:
Justin Mazzocchi 2020-12-01 10:40:19 -08:00
parent 02cc1e3533
commit 2fc7b4dad8
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
9 changed files with 29 additions and 5 deletions

View file

@ -44,7 +44,7 @@ extension TimelineRecord {
id = timeline.id id = timeline.id
switch timeline { switch timeline {
case .home, .local, .federated, .favorites: case .home, .local, .federated, .favorites, .bookmarks:
listId = nil listId = nil
listTitle = nil listTitle = nil
tag = nil tag = nil

View file

@ -11,6 +11,7 @@ public enum Timeline: Hashable {
case tag(String) case tag(String)
case profile(accountId: Account.Id, profileCollection: ProfileCollection) case profile(accountId: Account.Id, profileCollection: ProfileCollection)
case favorites case favorites
case bookmarks
} }
public extension Timeline { public extension Timeline {
@ -50,6 +51,8 @@ extension Timeline: Identifiable {
return "profile-\(accountId)-\(profileCollection)" return "profile-\(accountId)-\(profileCollection)"
case .favorites: case .favorites:
return "favorites" return "favorites"
case .bookmarks:
return "bookmarks"
} }
} }
} }

View file

@ -26,6 +26,8 @@ extension Timeline {
self = .profile(accountId: accountId, profileCollection: profileCollection) self = .profile(accountId: accountId, profileCollection: profileCollection)
case (Timeline.favorites.id, _, _, _, _, _): case (Timeline.favorites.id, _, _, _, _, _):
self = .favorites self = .favorites
case (Timeline.bookmarks.id, _, _, _, _, _):
self = .bookmarks
default: default:
return nil return nil
} }

View file

@ -24,6 +24,7 @@
"add-identity.unable-to-connect-to-instance" = "Unable to connect to instance"; "add-identity.unable-to-connect-to-instance" = "Unable to connect to instance";
"attachment.sensitive-content" = "Sensitive content"; "attachment.sensitive-content" = "Sensitive content";
"attachment.media-hidden" = "Media hidden"; "attachment.media-hidden" = "Media hidden";
"bookmarks" = "Bookmarks";
"cancel" = "Cancel"; "cancel" = "Cancel";
"favorites" = "Favorites"; "favorites" = "Favorites";
"registration.review-terms-of-use-and-privacy-policy-%@" = "Please review %@'s Terms of Use and Privacy Policy to continue"; "registration.review-terms-of-use-and-privacy-policy-%@" = "Please review %@'s Terms of Use and Privacy Policy to continue";

View file

@ -11,6 +11,7 @@ public enum StatusesEndpoint {
case timelinesList(id: List.Id) case timelinesList(id: List.Id)
case accountsStatuses(id: Account.Id, excludeReplies: Bool, onlyMedia: Bool, pinned: Bool) case accountsStatuses(id: Account.Id, excludeReplies: Bool, onlyMedia: Bool, pinned: Bool)
case favourites case favourites
case bookmarks
} }
extension StatusesEndpoint: Endpoint { extension StatusesEndpoint: Endpoint {
@ -22,7 +23,7 @@ extension StatusesEndpoint: Endpoint {
return defaultContext + ["timelines"] return defaultContext + ["timelines"]
case .accountsStatuses: case .accountsStatuses:
return defaultContext + ["accounts"] return defaultContext + ["accounts"]
case .favourites: case .favourites, .bookmarks:
return defaultContext return defaultContext
} }
} }
@ -41,6 +42,8 @@ extension StatusesEndpoint: Endpoint {
return [id, "statuses"] return [id, "statuses"]
case .favourites: case .favourites:
return ["favourites"] return ["favourites"]
case .bookmarks:
return ["bookmarks"]
} }
} }

View file

@ -41,6 +41,8 @@ extension Timeline {
pinned: false) pinned: false)
case .favorites: case .favorites:
return .favourites return .favourites
case .bookmarks:
return .bookmarks
} }
} }
} }

View file

@ -95,7 +95,7 @@ public extension NavigationViewModel {
switch timeline { switch timeline {
case .home, .list: case .home, .list:
return identification.identity.handle return identification.identity.handle
case .local, .federated, .tag, .profile, .favorites: case .local, .federated, .tag, .profile, .favorites, .bookmarks:
return identification.identity.instance?.uri ?? "" return identification.identity.instance?.uri ?? ""
} }
} }
@ -146,6 +146,12 @@ public extension NavigationViewModel {
collectionService: identification.service.service(timeline: .favorites), collectionService: identification.service.service(timeline: .favorites),
identification: identification) identification: identification)
} }
func bookmarksViewModel() -> CollectionViewModel {
CollectionItemsViewModel(
collectionService: identification.service.service(timeline: .bookmarks),
identification: identification)
}
} }
extension NavigationViewModel.Tab: Identifiable { extension NavigationViewModel.Tab: Identifiable {

View file

@ -58,7 +58,11 @@ struct SecondaryNavigationView: View {
} }
NavigationLink(destination: TableView(viewModel: viewModel.favoritesViewModel()) NavigationLink(destination: TableView(viewModel: viewModel.favoritesViewModel())
.navigationTitle(Text("favorites"))) { .navigationTitle(Text("favorites"))) {
Label("favorites", systemImage: "star.fill") Label("favorites", systemImage: "star")
}
NavigationLink(destination: TableView(viewModel: viewModel.bookmarksViewModel())
.navigationTitle(Text("bookmarks"))) {
Label("bookmarks", systemImage: "bookmark")
} }
} }
Section { Section {

View file

@ -161,6 +161,8 @@ private extension Timeline {
return "" return ""
case .favorites: case .favorites:
return NSLocalizedString("favorites", comment: "") return NSLocalizedString("favorites", comment: "")
case .bookmarks:
return NSLocalizedString("bookmarks", comment: "")
} }
} }
@ -172,7 +174,8 @@ private extension Timeline {
case .list: return "scroll" case .list: return "scroll"
case .tag: return "number" case .tag: return "number"
case .profile: return "person" case .profile: return "person"
case .favorites: return "star.fill" case .favorites: return "star"
case .bookmarks: return "bookmark"
} }
} }
} }