Move Mac toolbar to SceneNavigationView so that it operates properly. Issue #2217

This commit is contained in:
Maurice Parker 2020-07-07 16:05:26 -05:00
parent 265899f6e2
commit 8064e65e68
2 changed files with 70 additions and 79 deletions

View File

@ -18,86 +18,16 @@ struct MainApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) private var delegate
#endif
@StateObject private var sceneModel = SceneModel()
@StateObject private var defaults = AppDefaults.shared
@State private var showSheet = false
@SceneBuilder var body: some Scene {
#if os(macOS)
WindowGroup {
SceneNavigationView()
.frame(minWidth: 600, idealWidth: 1000, maxWidth: .infinity, minHeight: 600, idealHeight: 700, maxHeight: .infinity)
.environmentObject(sceneModel)
.environmentObject(defaults)
.onAppear {
sceneModel.startup()
}
.sheet(isPresented: $showSheet, onDismiss: { showSheet = false }) {
AddWebFeedView()
}
.toolbar {
ToolbarItem() {
Menu {
Button("Add Web Feed", action: { showSheet = true })
Button("Add Reddit Feed", action: { })
Button("Add Twitter Feed", action: { })
Button("Add Folder", action: { })
} label : {
AppAssets.addMenuImage
}
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.refreshImage
}).help("Refresh").padding(.trailing, 40)
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.markAllAsReadImagePDF
.resizable()
.scaledToFit()
.frame(width: 20, height: 20, alignment: .center)
}).help("Mark All as Read")
}
ToolbarItem {
MacSearchField()
.frame(width: 200)
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.nextUnreadArticleImage
}).help("Go to Next Unread").padding(.trailing, 40)
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.starOpenImage
}).help("Mark as Starred")
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.readClosedImage
}).help("Mark as Unread")
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.openInBrowserImage
}).help("Open in Browser")
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.shareImage
}).help("Share")
}
}
}
.windowToolbarStyle(UnifiedWindowToolbarStyle())
.commands {
CommandGroup(after: .newItem, addition: {
Button("New Feed", action: {})
@ -138,7 +68,6 @@ struct MainApp: App {
.keyboardShortcut(.rightArrow, modifiers: [.command])
})
}
.windowToolbarStyle(UnifiedWindowToolbarStyle())
// Mac Preferences
Settings {
@ -155,12 +84,8 @@ struct MainApp: App {
#if os(iOS)
WindowGroup {
SceneNavigationView()
.environmentObject(sceneModel)
.environmentObject(defaults)
.modifier(PreferredColorSchemeModifier(preferredColorScheme: defaults.userInterfaceColorPalette))
.onAppear {
sceneModel.startup()
}
}
.commands {
CommandGroup(after: .newItem, addition: {

View File

@ -9,7 +9,10 @@
import SwiftUI
struct SceneNavigationView: View {
@StateObject private var sceneModel = SceneModel()
@State private var showSheet = false
#if os(iOS)
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
#endif
@ -42,7 +45,70 @@ struct SceneNavigationView: View {
.frame(maxWidth: .infinity, maxHeight: .infinity)
#endif
}
.environmentObject(sceneModel)
.onAppear {
sceneModel.startup()
}
.sheet(isPresented: $showSheet, onDismiss: { showSheet = false }) {
AddWebFeedView()
}
.toolbar {
#if os(macOS)
ToolbarItem() {
Menu {
Button("Add Web Feed", action: { showSheet = true })
Button("Add Reddit Feed", action: { })
Button("Add Twitter Feed", action: { })
Button("Add Folder", action: { })
} label : {
AppAssets.addMenuImage
}
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.refreshImage
}).help("Refresh").padding(.trailing, 40)
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.markAllAsReadImagePDF
.resizable()
.scaledToFit()
.frame(width: 20, height: 20, alignment: .center)
}).help("Mark All as Read")
}
ToolbarItem {
MacSearchField()
.frame(width: 200)
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.nextUnreadArticleImage
}).help("Go to Next Unread").padding(.trailing, 40)
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.starOpenImage
}).help("Mark as Starred")
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.readClosedImage
}).help("Mark as Unread")
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.openInBrowserImage
}).help("Open in Browser")
}
ToolbarItem {
Button(action: {}, label: {
AppAssets.shareImage
}).help("Share")
}
#endif
}
}
}