Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F12142980
PostEditorSharingPicker.swift
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
PostEditorSharingPicker.swift
View Options
import
SwiftUI
struct
PostEditorSharingPicker
:
NSViewRepresentable
{
@
Binding
var
isPresented
:
Bool
var
sharingItems
:
[
Any
]
=
[]
func
makeNSView
(
context
:
Context
)
->
some
NSView
{
let
view
=
NSView
()
let
picker
=
NSSharingServicePicker
(
items
:
sharingItems
)
picker
.
delegate
=
context
.
coordinator
DispatchQueue
.
main
.
async
{
picker
.
show
(
relativeTo
:
.
zero
,
of
:
view
,
preferredEdge
:
.
minY
)
}
return
view
}
func
updateNSView
(
_
nsView
:
NSViewType
,
context
:
Context
)
{
}
func
makeCoordinator
()
->
Coordinator
{
Coordinator
(
owner
:
self
)
}
class
Coordinator
:
NSObject
,
NSSharingServicePickerDelegate
{
let
owner
:
PostEditorSharingPicker
init
(
owner
:
PostEditorSharingPicker
)
{
self
.
owner
=
owner
}
func
sharingServicePicker
(
_
sharingServicePicker
:
NSSharingServicePicker
,
didChoose
service
:
NSSharingService
?
)
{
sharingServicePicker
.
delegate
=
nil
self
.
owner
.
isPresented
=
false
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Fri, Oct 10, 3:38 AM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3441064
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment