mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Share button
This commit is contained in:
@@ -4,6 +4,8 @@ import SwiftUI
|
||||
struct ChannelPlaylistView: View {
|
||||
var playlist: ChannelPlaylist
|
||||
|
||||
@State private var presentingShareSheet = false
|
||||
|
||||
@StateObject private var store = Store<ChannelPlaylist>()
|
||||
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@@ -44,12 +46,26 @@ struct ChannelPlaylistView: View {
|
||||
#endif
|
||||
VerticalCells(items: items)
|
||||
}
|
||||
#if os(iOS)
|
||||
.sheet(isPresented: $presentingShareSheet) {
|
||||
ShareSheet(activityItems: [
|
||||
accounts.api.shareURL(contentItem)
|
||||
])
|
||||
}
|
||||
#endif
|
||||
.onAppear {
|
||||
resource?.addObserver(store)
|
||||
resource?.loadIfNeeded()
|
||||
}
|
||||
#if !os(tvOS)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: shareButtonPlacement) {
|
||||
ShareButton(
|
||||
contentItem: contentItem,
|
||||
presentingShareSheet: $presentingShareSheet
|
||||
)
|
||||
}
|
||||
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
if inNavigationView {
|
||||
Button("Done") {
|
||||
@@ -64,6 +80,18 @@ struct ChannelPlaylistView: View {
|
||||
.background(.thickMaterial)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var shareButtonPlacement: ToolbarItemPlacement {
|
||||
#if os(iOS)
|
||||
.navigation
|
||||
#else
|
||||
.automatic
|
||||
#endif
|
||||
}
|
||||
|
||||
private var contentItem: ContentItem {
|
||||
ContentItem(playlist: playlist)
|
||||
}
|
||||
}
|
||||
|
||||
struct ChannelPlaylistView_Previews: PreviewProvider {
|
||||
|
Reference in New Issue
Block a user