Unify forms, add to/remove from playlist on all platforms, UI improvements

This commit is contained in:
Arkadiusz Fal
2021-09-28 20:06:05 +02:00
parent 17291b47e0
commit 7446c945b5
29 changed files with 644 additions and 448 deletions

View File

@@ -69,6 +69,9 @@ struct ChannelVideosView: View {
}
}
#endif
#if os(tvOS)
.background(.thickMaterial)
#endif
.modifier(UnsubscribeAlertModifier())
.onAppear {
if store.item.isNil {

View File

@@ -37,7 +37,7 @@ struct SearchView: View {
}
.edgesIgnoringSafeArea(.horizontal)
#else
VideosCellsVertical(videos: state.store.collection)
VideosCellsVertical(videos: state.store.collection)
#endif
if noResults {

View File

@@ -47,6 +47,10 @@ struct SignInRequiredView<Content: View>: View {
if instances.isEmpty {
openSettingsButton
}
#if os(tvOS)
openSettingsButton
#endif
}
}

View File

@@ -4,22 +4,24 @@ import SwiftUI
struct VideoContextMenuView: View {
@EnvironmentObject<InvidiousAPI> private var api
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<PlaylistsModel> private var playlists
@EnvironmentObject<RecentsModel> private var recents
@EnvironmentObject<SubscriptionsModel> private var subscriptions
let video: Video
@Default(.showingAddToPlaylist) var showingAddToPlaylist
@Default(.videoIDToAddToPlaylist) var videoIDToAddToPlaylist
var body: some View {
Section {
openChannelButton
subscriptionButton
if case let .playlist(id) = navigation.tabSelection {
removeFromPlaylistButton(playlistID: id)
}
if navigation.tabSelection == .playlists {
removeFromPlaylistButton
removeFromPlaylistButton(playlistID: playlists.currentPlaylist!.id)
} else {
addToPlaylistButton
}
@@ -29,7 +31,7 @@ struct VideoContextMenuView: View {
var openChannelButton: some View {
Button("\(video.author) Channel") {
let recent = RecentItem(from: video.channel)
recents.open(recent)
recents.add(recent)
navigation.tabSelection = .recentlyOpened(recent.tag)
navigation.isChannelOpen = true
navigation.sidebarSectionChanged.toggle()
@@ -58,17 +60,13 @@ struct VideoContextMenuView: View {
var addToPlaylistButton: some View {
Button("Add to playlist...") {
videoIDToAddToPlaylist = video.id
showingAddToPlaylist = true
navigation.presentAddToPlaylist(video)
}
}
var removeFromPlaylistButton: some View {
func removeFromPlaylistButton(playlistID: String) -> some View {
Button("Remove from playlist", role: .destructive) {
let resource = api.playlistVideo(Defaults[.selectedPlaylistID]!, video.indexID!)
resource.request(.delete).onSuccess { _ in
api.playlists.load()
}
playlists.removeVideoFromPlaylist(videoIndexID: video.indexID!, playlistID: playlistID)
}
}
}