Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F13828739
ActivePostToolbarView.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
ActivePostToolbarView.swift
View Options
import
SwiftUI
struct
ActivePostToolbarView
:
View
{
@
EnvironmentObject
var
model
:
WriteFreelyModel
@
ObservedObject
var
activePost
:
WFAPost
@
State
private
var
isPresentingSharingServicePicker
:
Bool
=
false
var
body
:
some
View
{
HStack
(
spacing
:
16
)
{
PostEditorStatusToolbarView
(
post
:
activePost
)
HStack
(
spacing
:
4
)
{
Button
(
action
:
{
self
.
isPresentingSharingServicePicker
=
true
},
label
:
{
Image
(
systemName
:
"square.and.arrow.up"
)
}
)
.
disabled
(
activePost
.
status
==
PostStatus
.
local
.
rawValue
)
.
popover
(
isPresented
:
$
isPresentingSharingServicePicker
)
{
PostEditorSharingPicker
(
isPresented
:
$
isPresentingSharingServicePicker
,
sharingItems
:
createPostUrl
()
)
.
frame
(
width
:
.
zero
,
height
:
.
zero
)
}
Button
(
action
:
{
publishPost
(
activePost
)
},
label
:
{
Image
(
systemName
:
"paperplane"
)
})
.
disabled
(
activePost
.
body
.
isEmpty
||
activePost
.
status
==
PostStatus
.
published
.
rawValue
)
}
}
}
private
func
createPostUrl
()
->
[
Any
]
{
guard
let
postId
=
activePost
.
postId
else
{
return
[]
}
guard
let
urlString
=
activePost
.
slug
!=
nil
?
"
\(
model
.
account
.
server
)
/
\((
activePost
.
collectionAlias
)
!
)
/
\((
activePost
.
slug
)
!
)
"
:
"
\(
model
.
account
.
server
)
/
\((
postId
))
"
else
{
return
[]
}
guard
let
data
=
URL
(
string
:
urlString
)
else
{
return
[]
}
return
[
data
as
NSURL
]
}
private
func
publishPost
(
_
post
:
WFAPost
)
{
DispatchQueue
.
main
.
async
{
LocalStorageManager
().
saveContext
()
model
.
publish
(
post
:
post
)
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Thu, Feb 19, 8:53 PM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3632601
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment