Documents tab with file sharing

This commit is contained in:
Arkadiusz Fal
2022-11-13 00:01:04 +01:00
parent ccded28468
commit 4657af2f3d
15 changed files with 474 additions and 59 deletions

View File

@@ -37,54 +37,64 @@ struct VideoContextMenuView: View {
}
@ViewBuilder var contextMenu: some View {
if saveHistory {
Section {
if let watchedAtString {
Text(watchedAtString)
}
if !video.localStreamIsDirectory {
if saveHistory {
Section {
if let watchedAtString {
Text(watchedAtString)
}
if !watch.isNil, !watch!.finished, !watchingNow {
continueButton
}
if !watch.isNil, !watch!.finished, !watchingNow {
continueButton
}
if !(watch?.finished ?? false) {
markAsWatchedButton
}
if !(watch?.finished ?? false) {
markAsWatchedButton
}
if !watch.isNil, !watchingNow {
removeFromHistoryButton
if !watch.isNil, !watchingNow {
removeFromHistoryButton
}
}
}
Section {
playNowButton
#if !os(tvOS)
playNowInPictureInPictureButton
playNowInMusicMode
#endif
}
Section {
playNextButton
addToQueueButton
}
if accounts.app.supportsUserPlaylists, accounts.signedIn, !video.isLocal {
Section {
addToPlaylistButton
addToLastPlaylistButton
if let id = navigation.tabSelection?.playlistID ?? playlistID {
removeFromPlaylistButton(playlistID: id)
}
}
}
}
Section {
playNowButton
#if !os(tvOS)
playNowInPictureInPictureButton
playNowInMusicMode
Section {
ShareButton(contentItem: .init(video: video))
}
#endif
}
Section {
playNextButton
addToQueueButton
}
if accounts.app.supportsUserPlaylists, accounts.signedIn, !video.isLocal {
Section {
addToPlaylistButton
addToLastPlaylistButton
if let id = navigation.tabSelection?.playlistID ?? playlistID {
removeFromPlaylistButton(playlistID: id)
#if os(iOS)
if video.isLocal, let url = video.localStream?.localURL, DocumentsModel.shared.isDocument(url) {
Section {
removeDocumentButton
}
}
}
#if !os(tvOS)
Section {
ShareButton(contentItem: .init(video: video))
}
#endif
if !inChannelView, !inChannelPlaylistView, !video.isLocal {
@@ -215,6 +225,31 @@ struct VideoContextMenuView: View {
}
}
#if os(iOS)
private var removeDocumentButton: some View {
Button {
if let url = video.localStream?.localURL {
NavigationModel.shared.presentAlert(
Alert(
title: Text("Are you sure you want to remove this document?"),
primaryButton: .destructive(Text("Remove")) {
do {
try DocumentsModel.shared.removeDocument(url)
} catch {
NavigationModel.shared.presentAlert(title: "Could not delete document", message: error.localizedDescription)
}
},
secondaryButton: .cancel()
)
)
}
} label: {
Label("Remove...", systemImage: "trash.fill")
.foregroundColor(Color("AppRedColor"))
}
}
#endif
private var openChannelButton: some View {
Button {
NavigationModel.openChannel(