Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F12142516
PostListFilteredView.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
PostListFilteredView.swift
View Options
import
SwiftUI
struct
PostListFilteredView
:
View
{
var
fetchRequest
:
FetchRequest
<
WFAPost
>
init
(
filter
:
String
?,
showAllPosts
:
Bool
)
{
if
showAllPosts
{
fetchRequest
=
FetchRequest
<
WFAPost
>(
entity
:
WFAPost
.
entity
(),
sortDescriptors
:
[
NSSortDescriptor
(
key
:
"createdDate"
,
ascending
:
false
)]
)
}
else
{
if
let
filter
=
filter
{
fetchRequest
=
FetchRequest
<
WFAPost
>(
entity
:
WFAPost
.
entity
(),
sortDescriptors
:
[
NSSortDescriptor
(
key
:
"createdDate"
,
ascending
:
false
)],
predicate
:
NSPredicate
(
format
:
"collectionAlias == %@"
,
filter
)
)
}
else
{
fetchRequest
=
FetchRequest
<
WFAPost
>(
entity
:
WFAPost
.
entity
(),
sortDescriptors
:
[
NSSortDescriptor
(
key
:
"createdDate"
,
ascending
:
false
)],
predicate
:
NSPredicate
(
format
:
"collectionAlias == nil"
)
)
}
}
}
var
body
:
some
View
{
List
(
fetchRequest
.
wrappedValue
,
id
:
\
.
self
)
{
post
in
NavigationLink
(
destination
:
PostEditorView
(
post
:
post
))
{
PostCellView
(
post
:
post
)
}
}
}
}
struct
PostListFilteredView_Previews
:
PreviewProvider
{
static
var
previews
:
some
View
{
let
context
=
LocalStorageManager
.
persistentContainer
.
viewContext
return
PostListFilteredView
(
filter
:
nil
,
showAllPosts
:
false
)
.
environment
(
\
.
managedObjectContext
,
context
)
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Thu, Oct 9, 10:15 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3440843
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment