mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Use a share view for copying the group invite link
This commit is contained in:
parent
d57cac47e7
commit
c03c6e2a51
3 changed files with 30 additions and 11 deletions
|
|
@ -29,6 +29,8 @@ struct RecommendationGroupView: View {
|
|||
@EnvironmentObject var dataService: DataService
|
||||
@StateObject var viewModel: RecommendationsGroupViewModel
|
||||
|
||||
@State var presentShareSheet = false
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
#if os(iOS)
|
||||
|
|
@ -45,6 +47,14 @@ struct RecommendationGroupView: View {
|
|||
.task { await viewModel.loadGroups(dataService: dataService) }
|
||||
}
|
||||
|
||||
private var shareView: some View {
|
||||
if let shareLink = URL(string: viewModel.recommendationGroup.inviteUrl) {
|
||||
return AnyView(ShareSheet(activityItems: [shareLink]))
|
||||
} else {
|
||||
return AnyView(Text("Error copying invite URL"))
|
||||
}
|
||||
}
|
||||
|
||||
private var innerBody: some View {
|
||||
Group {
|
||||
Section("Name") {
|
||||
|
|
@ -53,22 +63,15 @@ struct RecommendationGroupView: View {
|
|||
|
||||
Section("Invite Link") {
|
||||
Button(action: {
|
||||
#if os(iOS)
|
||||
UIPasteboard.general.string = viewModel.recommendationGroup.inviteUrl
|
||||
#endif
|
||||
|
||||
#if os(macOS)
|
||||
let pasteBoard = NSPasteboard.general
|
||||
pasteBoard.clearContents()
|
||||
pasteBoard.writeObjects([viewModel.recommendationGroup.inviteUrl as NSString])
|
||||
#endif
|
||||
|
||||
Snackbar.show(message: "Invite link copied")
|
||||
presentShareSheet = true
|
||||
}, label: {
|
||||
Text("[\(viewModel.recommendationGroup.inviteUrl)](\(viewModel.recommendationGroup.inviteUrl))")
|
||||
})
|
||||
}
|
||||
}
|
||||
.formSheet(isPresented: $presentShareSheet) {
|
||||
shareView
|
||||
}
|
||||
.navigationTitle(viewModel.recommendationGroup.name)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by Jackson Harper on 12/5/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
//
|
||||
// File.swift
|
||||
//
|
||||
//
|
||||
// Created by Jackson Harper on 12/5/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
Loading…
Reference in a new issue