mirror of
https://github.com/yattee/yattee.git
synced 2025-04-28 16:00:33 +05:30
Fix share actions
This commit is contained in:
parent
6be5342183
commit
50479d6b2f
@ -128,6 +128,8 @@ struct OpenVideosView: View {
|
|||||||
.fontWeight(.bold)
|
.fontWeight(.bold)
|
||||||
.padding(.vertical, 10)
|
.padding(.vertical, 10)
|
||||||
}
|
}
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.contentShape(Rectangle())
|
||||||
.padding(.horizontal, 20)
|
.padding(.horizontal, 20)
|
||||||
}
|
}
|
||||||
.foregroundColor(.accentColor)
|
.foregroundColor(.accentColor)
|
||||||
@ -152,6 +154,8 @@ struct OpenVideosView: View {
|
|||||||
.fontWeight(.bold)
|
.fontWeight(.bold)
|
||||||
.padding(.vertical, 10)
|
.padding(.vertical, 10)
|
||||||
}
|
}
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.contentShape(Rectangle())
|
||||||
.padding(.horizontal, 20)
|
.padding(.horizontal, 20)
|
||||||
}
|
}
|
||||||
.foregroundColor(.accentColor)
|
.foregroundColor(.accentColor)
|
||||||
@ -174,6 +178,7 @@ struct OpenVideosView: View {
|
|||||||
.padding(.vertical, 10)
|
.padding(.vertical, 10)
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
|
.contentShape(Rectangle())
|
||||||
.padding(.horizontal, 20)
|
.padding(.horizontal, 20)
|
||||||
}
|
}
|
||||||
.foregroundColor(.accentColor)
|
.foregroundColor(.accentColor)
|
||||||
|
@ -11,13 +11,18 @@ struct ShareButton: View {
|
|||||||
self.contentItem = contentItem
|
self.contentItem = contentItem
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
@ViewBuilder var body: some View {
|
||||||
|
if let video = contentItem.video, !video.localStreamIsFile {
|
||||||
Menu {
|
Menu {
|
||||||
|
if video.localStreamIsRemoteURL {
|
||||||
|
remoteURLAction
|
||||||
|
} else {
|
||||||
instanceActions
|
instanceActions
|
||||||
Divider()
|
Divider()
|
||||||
if !accounts.isDemo {
|
if !accounts.isDemo {
|
||||||
youtubeActions
|
youtubeActions
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} label: {
|
} label: {
|
||||||
Label("Share...", systemImage: "square.and.arrow.up")
|
Label("Share...", systemImage: "square.and.arrow.up")
|
||||||
}
|
}
|
||||||
@ -26,6 +31,7 @@ struct ShareButton: View {
|
|||||||
.frame(maxWidth: 35)
|
.frame(maxWidth: 35)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var instanceActions: some View {
|
private var instanceActions: some View {
|
||||||
Group {
|
Group {
|
||||||
@ -79,6 +85,14 @@ struct ShareButton: View {
|
|||||||
contentItem.contentType == .video && contentItem.video?.videoID == player.currentVideo?.videoID
|
contentItem.contentType == .video && contentItem.video?.videoID == player.currentVideo?.videoID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewBuilder private var remoteURLAction: some View {
|
||||||
|
if let url = contentItem.video.localStream?.localURL {
|
||||||
|
Button(labelForShareURL()) {
|
||||||
|
shareAction(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func shareAction(_ url: URL) {
|
private func shareAction(_ url: URL) {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
NSPasteboard.general.clearContents()
|
NSPasteboard.general.clearContents()
|
||||||
@ -90,18 +104,18 @@ struct ShareButton: View {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private func labelForShareURL(_ app: String, withTime: Bool = false) -> String {
|
private func labelForShareURL(_ app: String? = nil, withTime: Bool = false) -> String {
|
||||||
if withTime {
|
if withTime {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
return String(format: "Copy %@ link with time".localized(), app)
|
return String(format: "Copy %@ link with time".localized(), app ?? "")
|
||||||
#else
|
#else
|
||||||
return String(format: "Share %@ link with time".localized(), app)
|
return String(format: "Share %@ link with time".localized(), app ?? "")
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
return String(format: "Copy %@ link".localized(), app)
|
return String(format: "Copy%@link".localized(), app == nil ? " " : " \(app!) ")
|
||||||
#else
|
#else
|
||||||
return String(format: "Share %@ link".localized(), app)
|
return String(format: "Share%@link".localized(), app == nil ? " " : " \(app!) ")
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user