Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F14178454
ContentView.swift
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
ContentView.swift
View Options
import
SwiftUI
struct
ContentView
:
View
{
@
EnvironmentObject
var
model
:
WriteFreelyModel
@
EnvironmentObject
var
errorHandling
:
ErrorHandling
var
body
:
some
View
{
NavigationView
{
#if
os
(
macOS
)
CollectionListView
()
.
withErrorHandling
()
.
toolbar
{
Button
(
action
:
{
NSApp
.
keyWindow
?.
contentViewController
?.
tryToPerform
(
#
selector
(
NSSplitViewController
.
toggleSidebar
(
_
:)),
with
:
nil
)
},
label
:
{
Image
(
systemName
:
"sidebar.left"
)
}
)
.
help
(
"Toggle the sidebar's visibility."
)
Spacer
()
Button
(
action
:
{
withAnimation
{
// Un-set the currently selected post
self
.
model
.
selectedPost
=
nil
}
// Create the new-post managed object
let
managedPost
=
model
.
editor
.
generateNewLocalPost
(
withFont
:
model
.
preferences
.
font
)
withAnimation
{
DispatchQueue
.
main
.
async
{
// Load the new post in the editor
self
.
model
.
selectedPost
=
managedPost
}
}
},
label
:
{
Image
(
systemName
:
"square.and.pencil"
)
})
.
help
(
"Create a new local draft."
)
}
.
frame
(
width
:
200
)
#else
CollectionListView
()
.
withErrorHandling
()
#endif
#if
os
(
macOS
)
ZStack
{
PostListView
(
selectedCollection
:
model
.
selectedCollection
,
showAllPosts
:
model
.
showAllPosts
)
.
withErrorHandling
()
.
frame
(
width
:
300
)
if
model
.
isProcessingRequest
{
ZStack
{
Color
(
NSColor
.
controlBackgroundColor
).
opacity
(
0.75
)
ProgressView
()
}
}
}
#else
PostListView
(
selectedCollection
:
model
.
selectedCollection
,
showAllPosts
:
model
.
showAllPosts
)
.
withErrorHandling
()
#endif
#if
os
(
macOS
)
Text
(
"Select a post, or create a new local draft."
)
.
foregroundColor
(.
secondary
)
.
frame
(
width
:
500
,
height
:
500
)
#else
Text
(
"Select a post, or create a new local draft."
)
.
foregroundColor
(.
secondary
)
#endif
}
.
environmentObject
(
model
)
.
onChange
(
of
:
model
.
hasError
)
{
value
in
if
value
{
if
let
error
=
model
.
currentError
{
self
.
errorHandling
.
handle
(
error
:
error
)
}
else
{
self
.
errorHandling
.
handle
(
error
:
AppError
.
genericError
())
}
model
.
hasError
=
false
}
}
}
}
struct
ContentView_Previews
:
PreviewProvider
{
static
var
previews
:
some
View
{
let
context
=
LocalStorageManager
.
standard
.
container
.
viewContext
let
model
=
WriteFreelyModel
()
return
ContentView
()
.
environment
(
\
.
managedObjectContext
,
context
)
.
environmentObject
(
model
)
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Thu, Apr 2, 6:27 AM (8 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3673578
Attached To
rWFSUI WriteFreely SwiftUI
Event Timeline
Log In to Comment