mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Fix share URLs
This commit is contained in:
parent
6328bfbfab
commit
a70d4f3b38
@ -80,6 +80,6 @@ extension VideosAPI {
|
|||||||
urlComponents.queryItems = queryItems
|
urlComponents.queryItems = queryItems
|
||||||
}
|
}
|
||||||
|
|
||||||
return urlComponents.url!
|
return urlComponents.url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ struct VideoDetails: View {
|
|||||||
@State private var confirmationShown = false
|
@State private var confirmationShown = false
|
||||||
@State private var presentingAddToPlaylist = false
|
@State private var presentingAddToPlaylist = false
|
||||||
@State private var presentingShareSheet = false
|
@State private var presentingShareSheet = false
|
||||||
@State private var shareURL = ""
|
@State private var shareURL: URL?
|
||||||
|
|
||||||
@State private var currentPage = Page.details
|
@State private var currentPage = Page.details
|
||||||
|
|
||||||
@ -309,7 +309,9 @@ struct VideoDetails: View {
|
|||||||
}
|
}
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
.sheet(isPresented: $presentingShareSheet) {
|
.sheet(isPresented: $presentingShareSheet) {
|
||||||
ShareSheet(activityItems: [shareURL])
|
if let shareURL = shareURL {
|
||||||
|
ShareSheet(activityItems: [shareURL])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ struct ChannelPlaylistView: View {
|
|||||||
var playlist: ChannelPlaylist
|
var playlist: ChannelPlaylist
|
||||||
|
|
||||||
@State private var presentingShareSheet = false
|
@State private var presentingShareSheet = false
|
||||||
|
@State private var shareURL: URL?
|
||||||
|
|
||||||
@StateObject private var store = Store<ChannelPlaylist>()
|
@StateObject private var store = Store<ChannelPlaylist>()
|
||||||
|
|
||||||
@ -56,8 +57,8 @@ struct ChannelPlaylistView: View {
|
|||||||
}
|
}
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
.sheet(isPresented: $presentingShareSheet) {
|
.sheet(isPresented: $presentingShareSheet) {
|
||||||
if let url = accounts.api.shareURL(contentItem) {
|
if let shareURL = shareURL {
|
||||||
ShareSheet(activityItems: [url])
|
ShareSheet(activityItems: [shareURL])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -70,7 +71,8 @@ struct ChannelPlaylistView: View {
|
|||||||
ToolbarItem(placement: .navigation) {
|
ToolbarItem(placement: .navigation) {
|
||||||
ShareButton(
|
ShareButton(
|
||||||
contentItem: contentItem,
|
contentItem: contentItem,
|
||||||
presentingShareSheet: $presentingShareSheet
|
presentingShareSheet: $presentingShareSheet,
|
||||||
|
shareURL: $shareURL
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ struct ChannelVideosView: View {
|
|||||||
let channel: Channel
|
let channel: Channel
|
||||||
|
|
||||||
@State private var presentingShareSheet = false
|
@State private var presentingShareSheet = false
|
||||||
|
@State private var shareURL: URL?
|
||||||
|
|
||||||
@StateObject private var store = Store<Channel>()
|
@StateObject private var store = Store<Channel>()
|
||||||
|
|
||||||
@ -79,7 +80,8 @@ struct ChannelVideosView: View {
|
|||||||
ToolbarItem(placement: .navigation) {
|
ToolbarItem(placement: .navigation) {
|
||||||
ShareButton(
|
ShareButton(
|
||||||
contentItem: contentItem,
|
contentItem: contentItem,
|
||||||
presentingShareSheet: $presentingShareSheet
|
presentingShareSheet: $presentingShareSheet,
|
||||||
|
shareURL: $shareURL
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +102,8 @@ struct ChannelVideosView: View {
|
|||||||
#endif
|
#endif
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
.sheet(isPresented: $presentingShareSheet) {
|
.sheet(isPresented: $presentingShareSheet) {
|
||||||
if let url = accounts.api.shareURL(contentItem) {
|
if let shareURL = shareURL {
|
||||||
ShareSheet(activityItems: [url])
|
ShareSheet(activityItems: [shareURL])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,7 +3,7 @@ import SwiftUI
|
|||||||
struct ShareButton: View {
|
struct ShareButton: View {
|
||||||
let contentItem: ContentItem
|
let contentItem: ContentItem
|
||||||
@Binding var presentingShareSheet: Bool
|
@Binding var presentingShareSheet: Bool
|
||||||
@Binding var shareURL: String
|
@Binding var shareURL: URL?
|
||||||
|
|
||||||
@EnvironmentObject<AccountsModel> private var accounts
|
@EnvironmentObject<AccountsModel> private var accounts
|
||||||
@EnvironmentObject<PlayerModel> private var player
|
@EnvironmentObject<PlayerModel> private var player
|
||||||
@ -11,11 +11,11 @@ struct ShareButton: View {
|
|||||||
init(
|
init(
|
||||||
contentItem: ContentItem,
|
contentItem: ContentItem,
|
||||||
presentingShareSheet: Binding<Bool>,
|
presentingShareSheet: Binding<Bool>,
|
||||||
shareURL: Binding<String>? = nil
|
shareURL: Binding<URL?>? = nil
|
||||||
) {
|
) {
|
||||||
self.contentItem = contentItem
|
self.contentItem = contentItem
|
||||||
_presentingShareSheet = presentingShareSheet
|
_presentingShareSheet = presentingShareSheet
|
||||||
_shareURL = shareURL ?? .constant("")
|
_shareURL = shareURL ?? .constant(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@ -81,7 +81,7 @@ struct ShareButton: View {
|
|||||||
NSPasteboard.general.clearContents()
|
NSPasteboard.general.clearContents()
|
||||||
NSPasteboard.general.setString(url.absoluteString, forType: .string)
|
NSPasteboard.general.setString(url.absoluteString, forType: .string)
|
||||||
#else
|
#else
|
||||||
shareURL = url.absoluteString
|
shareURL = url
|
||||||
presentingShareSheet = true
|
presentingShareSheet = true
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user