Merges fixes from colorPalette work

This commit is contained in:
Stuart Breckenridge 2020-07-04 00:06:43 +08:00
parent 75166b404e
commit 8840bf535f

View File

@ -8,26 +8,28 @@
import SwiftUI import SwiftUI
struct SidebarToolbar: View { fileprivate enum ToolbarSheets {
<<<<<<< HEAD case none, web, twitter, reddit, folder, settings
}
enum ToolbarSheets { fileprivate class SidebarViewModel: ObservableObject {
case none, web, twitter, reddit, folder, settings
}
@State private var showSheet: Bool = false @Published var showSheet: Bool = false
@State private var sheetToShow: ToolbarSheets = .none { @Published var sheetToShow: ToolbarSheets = .none {
didSet { didSet {
sheetToShow != .none ? (showSheet = true) : (showSheet = false) sheetToShow != .none ? (showSheet = true) : (showSheet = false)
} }
} }
@State private var showActionSheet: Bool = false @Published var showActionSheet: Bool = false
======= @Published var showAddSheet: Bool = false
}
struct SidebarToolbar: View {
@EnvironmentObject private var appSettings: AppDefaults @EnvironmentObject private var appSettings: AppDefaults
@State private var showSettings: Bool = false @StateObject private var viewModel = SidebarViewModel()
@State private var showAddSheet: Bool = false
>>>>>>> pr/7
var addActionSheetButtons = [ var addActionSheetButtons = [
Button(action: {}, label: { Text("Add Feed") }) Button(action: {}, label: { Text("Add Feed") })
@ -38,53 +40,51 @@ struct SidebarToolbar: View {
Divider() Divider()
HStack(alignment: .center) { HStack(alignment: .center) {
Button(action: { Button(action: {
sheetToShow = .settings viewModel.sheetToShow = .settings
}, label: { }, label: {
Image(systemName: "gear") Image(systemName: "gear")
.font(.title3) .font(.title3)
.foregroundColor(.accentColor) .foregroundColor(.accentColor)
}).help("Settings") }).help("Settings")
Spacer() Spacer()
Text("Last updated") Text("Last updated")
.font(.caption) .font(.caption)
.foregroundColor(.secondary) .foregroundColor(.secondary)
Spacer() Spacer()
Button(action: { Button(action: {
showActionSheet = true viewModel.showActionSheet = true
}, label: { }, label: {
Image(systemName: "plus") Image(systemName: "plus")
.font(.title3) .font(.title3)
.foregroundColor(.accentColor) .foregroundColor(.accentColor)
}) })
.help("Add") .help("Add")
.actionSheet(isPresented: $showActionSheet) { .actionSheet(isPresented: $viewModel.showActionSheet) {
ActionSheet(title: Text("Add"), buttons: [ ActionSheet(title: Text("Add"), buttons: [
.cancel(), .cancel(),
.default(Text("Add Web Feed"), action: { sheetToShow = .web }), .default(Text("Add Web Feed"), action: { viewModel.sheetToShow = .web }),
.default(Text("Add Twitter Feed")), .default(Text("Add Twitter Feed")),
.default(Text("Add Reddit Feed")), .default(Text("Add Reddit Feed")),
.default(Text("Add Folder")) .default(Text("Add Folder"))
]) ])
} }
} }
.padding(.horizontal, 16) .padding(.horizontal, 16)
.padding(.bottom, 12) .padding(.bottom, 12)
.padding(.top, 4) .padding(.top, 4)
} }
.background(VisualEffectBlur(blurStyle: .systemChromeMaterial).edgesIgnoringSafeArea(.bottom)) .background(VisualEffectBlur(blurStyle: .systemChromeMaterial).edgesIgnoringSafeArea(.bottom))
<<<<<<< HEAD .sheet(isPresented: $viewModel.showSheet, onDismiss: { viewModel.sheetToShow = .none }) {
.sheet(isPresented: $showSheet, onDismiss: { sheetToShow = .none }) { if viewModel.sheetToShow == .web {
switch sheetToShow {
case .web:
AddWebFeedView() AddWebFeedView()
default:
EmptyView()
} }
======= if viewModel.sheetToShow == .settings {
.sheet(isPresented: $showSettings, onDismiss: { showSettings = false }) { SettingsView().modifier(PreferredColorSchemeModifier(preferredColorScheme: appSettings.userInterfaceColorPalette))
SettingsView().modifier(PreferredColorSchemeModifier(preferredColorScheme: appSettings.userInterfaceColorPalette)) }
>>>>>>> pr/7
} }
} }