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
switch timeline {
case .home, .local, .federated, .favorites:
case .home, .local, .federated, .favorites, .bookmarks:
listId = nil
listTitle = nil
tag = nil

View file

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

View file

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

View file

@ -24,6 +24,7 @@
"add-identity.unable-to-connect-to-instance" = "Unable to connect to instance";
"attachment.sensitive-content" = "Sensitive content";
"attachment.media-hidden" = "Media hidden";
"bookmarks" = "Bookmarks";
"cancel" = "Cancel";
"favorites" = "Favorites";
"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 accountsStatuses(id: Account.Id, excludeReplies: Bool, onlyMedia: Bool, pinned: Bool)
case favourites
case bookmarks
}
extension StatusesEndpoint: Endpoint {
@ -22,7 +23,7 @@ extension StatusesEndpoint: Endpoint {
return defaultContext + ["timelines"]
case .accountsStatuses:
return defaultContext + ["accounts"]
case .favourites:
case .favourites, .bookmarks:
return defaultContext
}
}
@ -41,6 +42,8 @@ extension StatusesEndpoint: Endpoint {
return [id, "statuses"]
case .favourites:
return ["favourites"]
case .bookmarks:
return ["bookmarks"]
}
}

View file

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

View file

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

View file

@ -58,7 +58,11 @@ struct SecondaryNavigationView: View {
}
NavigationLink(destination: TableView(viewModel: viewModel.favoritesViewModel())
.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 {

View file

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