Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F14174856
CollectionListView.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
CollectionListView.swift
View Options
import
SwiftUI
struct
CollectionListView
:
View
{
@
EnvironmentObject
var
model
:
WriteFreelyModel
@
FetchRequest
(
entity
:
WFACollection
.
entity
(),
sortDescriptors
:
[
NSSortDescriptor
(
keyPath
:
\
WFACollection
.
title
,
ascending
:
true
)]
)
var
collections
:
FetchedResults
<
WFACollection
>
var
body
:
some
View
{
List
{
if
model
.
account
.
isLoggedIn
{
NavigationLink
(
destination
:
PostListView
(
selectedCollection
:
nil
,
showAllPosts
:
true
))
{
Text
(
"All Posts"
)
}
NavigationLink
(
destination
:
PostListView
(
selectedCollection
:
nil
,
showAllPosts
:
false
))
{
Text
(
model
.
account
.
server
==
"https://write.as"
?
"Anonymous"
:
"Drafts"
)
}
Section
(
header
:
Text
(
"Your Blogs"
))
{
ForEach
(
collections
,
id
:
\
.
alias
)
{
collection
in
NavigationLink
(
destination
:
PostListView
(
selectedCollection
:
collection
,
showAllPosts
:
false
)
)
{
Text
(
collection
.
title
)
}
}
}
}
else
{
NavigationLink
(
destination
:
PostListView
(
selectedCollection
:
nil
,
showAllPosts
:
false
))
{
Text
(
"Drafts"
)
}
}
}
.
navigationTitle
(
model
.
account
.
isLoggedIn
?
"
\(
URL
(
string
:
model
.
account
.
server
)
?.
host
??
"WriteFreely"
)
"
:
"WriteFreely"
)
.
listStyle
(
SidebarListStyle
())
}
}
struct
CollectionListView_LoggedOutPreviews
:
PreviewProvider
{
static
var
previews
:
some
View
{
let
context
=
LocalStorageManager
.
persistentContainer
.
viewContext
let
model
=
WriteFreelyModel
()
return
CollectionListView
()
.
environment
(
\
.
managedObjectContext
,
context
)
.
environmentObject
(
model
)
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Thu, Apr 2, 4:29 AM (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3673369
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment