Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F13784031
PostCellView.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
PostCellView.swift
View Options
import
SwiftUI
struct
PostCellView
:
View
{
@
ObservedObject
var
post
:
WFAPost
var
body
:
some
View
{
HStack
{
VStack
(
alignment
:
.
leading
)
{
Text
(
post
.
title
)
.
font
(.
headline
)
.
lineLimit
(
1
)
Text
(
buildDateString
(
from
:
post
.
createdDate
??
Date
()))
.
font
(.
caption
)
.
lineLimit
(
1
)
}
Spacer
()
PostStatusBadgeView
(
post
:
post
)
}
.
padding
(
5
)
}
func
buildDateString
(
from
date
:
Date
)
->
String
{
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateStyle
=
.
long
dateFormatter
.
timeStyle
=
.
short
return
dateFormatter
.
string
(
from
:
date
)
}
}
struct
PostCell_Previews
:
PreviewProvider
{
static
var
previews
:
some
View
{
let
context
=
LocalStorageManager
.
persistentContainer
.
viewContext
let
testPost
=
WFAPost
(
context
:
context
)
testPost
.
title
=
"Test Post Title"
testPost
.
body
=
"Here's some cool sample body text."
testPost
.
createdDate
=
Date
()
return
PostCellView
(
post
:
testPost
)
.
environment
(
\
.
managedObjectContext
,
context
)
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sat, Jan 31, 2:12 PM (20 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3612487
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment