Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F12142568
CollectionPicker.swift
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1003 B
Subscribers
None
CollectionPicker.swift
View Options
import
SwiftUI
struct
CollectionSidebar
:
View
{
@
EnvironmentObject
var
postStore
:
PostStore
@
Binding
var
selectedCollection
:
PostCollection
?
private
let
collections
=
[
allPostsCollection
,
defaultDraftCollection
,
testPostCollection1
,
testPostCollection2
,
testPostCollection3
]
var
body
:
some
View
{
List
{
ForEach
(
collections
)
{
collection
in
NavigationLink
(
destination
:
PostList
(
title
:
collection
.
title
,
posts
:
showPosts
(
for
:
collection
)).
tag
(
collection
))
{
Text
(
collection
.
title
)
}
}
}
.
listStyle
(
SidebarListStyle
())
}
func
showPosts
(
for
collection
:
PostCollection
)
->
[
Post
]
{
if
collection
==
allPostsCollection
{
return
postStore
.
posts
}
else
{
return
postStore
.
posts
.
filter
{
$0
.
collection
.
title
==
collection
.
title
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Thu, Oct 9, 10:39 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3428435
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment