mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Remove reload button from toolbar
This commit is contained in:
parent
24897aae93
commit
7902bff33d
@ -2,7 +2,6 @@ import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@EnvironmentObject var model: WriteFreelyModel
|
||||
@Binding var sidebarIsHidden: Bool
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
@ -14,7 +13,6 @@ struct ContentView: View {
|
||||
NSApp.keyWindow?.contentViewController?.tryToPerform(
|
||||
#selector(NSSplitViewController.toggleSidebar(_:)), with: nil
|
||||
)
|
||||
withAnimation { self.sidebarIsHidden.toggle() }
|
||||
},
|
||||
label: { Image(systemName: "sidebar.left") }
|
||||
)
|
||||
@ -55,31 +53,20 @@ struct ContentView: View {
|
||||
#if os(macOS)
|
||||
PostListView(selectedCollection: nil, showAllPosts: model.account.isLoggedIn)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigation) {
|
||||
Button(action: {
|
||||
DispatchQueue.main.async {
|
||||
model.fetchUserCollections()
|
||||
model.fetchUserPosts()
|
||||
}
|
||||
}, label: { Image(systemName: "arrow.clockwise") })
|
||||
.disabled(!model.account.isLoggedIn)
|
||||
.padding(.leading, sidebarIsHidden ? 8 : 0)
|
||||
.animation(.linear)
|
||||
.alert(isPresented: $model.isPresentingNetworkErrorAlert, content: {
|
||||
Alert(
|
||||
title: Text("Connection Error"),
|
||||
message: Text("""
|
||||
There is no internet connection at the moment. Please reconnect or try again later.
|
||||
"""),
|
||||
dismissButton: .default(Text("OK"), action: {
|
||||
model.isPresentingNetworkErrorAlert = false
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
ToolbarItemGroup(placement: .primaryAction) {
|
||||
if let selectedPost = model.selectedPost {
|
||||
ActivePostToolbarView(activePost: selectedPost)
|
||||
.alert(isPresented: $model.isPresentingNetworkErrorAlert, content: {
|
||||
Alert(
|
||||
title: Text("Connection Error"),
|
||||
message: Text("""
|
||||
There is no internet connection at the moment. Please reconnect or try again later.
|
||||
"""),
|
||||
dismissButton: .default(Text("OK"), action: {
|
||||
model.isPresentingNetworkErrorAlert = false
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,7 +109,7 @@ struct ContentView_Previews: PreviewProvider {
|
||||
let context = LocalStorageManager.persistentContainer.viewContext
|
||||
let model = WriteFreelyModel()
|
||||
|
||||
return ContentView(sidebarIsHidden: .constant(false))
|
||||
return ContentView()
|
||||
.environment(\.managedObjectContext, context)
|
||||
.environmentObject(model)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import SwiftUI
|
||||
@main
|
||||
struct WriteFreely_MultiPlatformApp: App {
|
||||
@StateObject private var model = WriteFreelyModel()
|
||||
@State private var sidebarIsHidden: Bool = false
|
||||
|
||||
#if os(macOS)
|
||||
@State private var selectedTab = 0
|
||||
@ -11,7 +10,7 @@ struct WriteFreely_MultiPlatformApp: App {
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView(sidebarIsHidden: $sidebarIsHidden)
|
||||
ContentView()
|
||||
.onAppear(perform: {
|
||||
if let lastDraft = model.editor.fetchLastDraftFromUserDefaults() {
|
||||
self.model.selectedPost = lastDraft
|
||||
|
Loading…
Reference in New Issue
Block a user