mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Replace NavigationView with WFNavigation in ContentView
This commit is contained in:
parent
4a244ae96d
commit
f0df99c1a8
@ -5,62 +5,61 @@ struct ContentView: View {
|
||||
@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)
|
||||
#if os(macOS)
|
||||
WFNavigation(
|
||||
collectionList: {
|
||||
CollectionListView()
|
||||
.withErrorHandling()
|
||||
.frame(width: 300)
|
||||
if model.isProcessingRequest {
|
||||
ZStack {
|
||||
Color(NSColor.controlBackgroundColor).opacity(0.75)
|
||||
ProgressView()
|
||||
.toolbar {
|
||||
if #available(macOS 13, *) {
|
||||
EmptyView()
|
||||
} else {
|
||||
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)
|
||||
},
|
||||
postList: {
|
||||
ZStack {
|
||||
PostListView(selectedCollection: model.selectedCollection, showAllPosts: model.showAllPosts)
|
||||
.withErrorHandling()
|
||||
.frame(width: 300)
|
||||
if model.isProcessingRequest {
|
||||
ZStack {
|
||||
Color(NSColor.controlBackgroundColor).opacity(0.75)
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
postDetail: {
|
||||
NoSelectedPostView(isConnected: $model.hasNetworkConnection)
|
||||
}
|
||||
#else
|
||||
PostListView(selectedCollection: model.selectedCollection, showAllPosts: model.showAllPosts)
|
||||
.withErrorHandling()
|
||||
#endif
|
||||
|
||||
NoSelectedPostView(isConnected: $model.hasNetworkConnection)
|
||||
}
|
||||
)
|
||||
.environmentObject(model)
|
||||
.onChange(of: model.hasError) { value in
|
||||
if value {
|
||||
@ -72,6 +71,32 @@ struct ContentView: View {
|
||||
model.hasError = false
|
||||
}
|
||||
}
|
||||
#else
|
||||
WFNavigation(
|
||||
collectionList: {
|
||||
CollectionListView()
|
||||
.withErrorHandling()
|
||||
},
|
||||
postList: {
|
||||
PostListView(selectedCollection: model.selectedCollection, showAllPosts: model.showAllPosts)
|
||||
.withErrorHandling()
|
||||
},
|
||||
postDetail: {
|
||||
NoSelectedPostView(isConnected: $model.hasNetworkConnection)
|
||||
}
|
||||
)
|
||||
.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
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user