2020-06-30 15:22:23 +02:00
|
|
|
//
|
2020-07-05 21:45:19 +02:00
|
|
|
// SidebarToolbarModifier.swift
|
2020-06-30 15:22:23 +02:00
|
|
|
// Multiplatform iOS
|
|
|
|
//
|
|
|
|
// Created by Stuart Breckenridge on 30/6/20.
|
|
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
2020-07-05 21:45:19 +02:00
|
|
|
struct SidebarToolbarModifier: ViewModifier {
|
2020-07-03 18:06:43 +02:00
|
|
|
|
2020-07-12 17:52:42 +02:00
|
|
|
@EnvironmentObject private var sidebarModel: SidebarModel
|
2020-07-06 14:18:50 +02:00
|
|
|
@EnvironmentObject private var defaults: AppDefaults
|
2020-07-04 15:34:15 +02:00
|
|
|
@StateObject private var viewModel = SidebarToolbarModel()
|
2020-07-03 18:06:43 +02:00
|
|
|
|
2020-07-04 16:01:01 +02:00
|
|
|
@ViewBuilder func body(content: Content) -> some View {
|
|
|
|
#if os(iOS)
|
2020-07-04 15:34:15 +02:00
|
|
|
content
|
|
|
|
.toolbar {
|
2020-07-05 22:11:45 +02:00
|
|
|
|
|
|
|
ToolbarItem(placement: .navigation) {
|
2020-07-12 17:52:42 +02:00
|
|
|
Button (action: {
|
|
|
|
withAnimation {
|
|
|
|
sidebarModel.isReadFiltered.toggle()
|
|
|
|
}
|
2020-07-05 22:11:45 +02:00
|
|
|
}, label: {
|
2020-07-12 17:52:42 +02:00
|
|
|
if sidebarModel.isReadFiltered {
|
|
|
|
AppAssets.filterActiveImage.font(.title3)
|
|
|
|
} else {
|
|
|
|
AppAssets.filterInactiveImage.font(.title3)
|
|
|
|
}
|
2020-07-12 22:03:43 +02:00
|
|
|
}).help(sidebarModel.isReadFiltered ? "Show Read Feeds" : "Filter Read Feeds")
|
2020-07-05 22:11:45 +02:00
|
|
|
}
|
|
|
|
|
2020-07-04 15:34:15 +02:00
|
|
|
ToolbarItem(placement: .automatic) {
|
|
|
|
Button(action: {
|
|
|
|
viewModel.sheetToShow = .settings
|
|
|
|
}, label: {
|
|
|
|
AppAssets.settingsImage
|
|
|
|
.font(.title3)
|
|
|
|
}).help("Settings")
|
|
|
|
}
|
2020-07-03 18:06:43 +02:00
|
|
|
|
2020-07-04 16:34:56 +02:00
|
|
|
ToolbarItem {
|
2020-07-04 15:34:15 +02:00
|
|
|
Spacer()
|
2020-07-04 16:34:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ToolbarItem(placement: .automatic) {
|
2020-07-04 16:20:51 +02:00
|
|
|
RefreshProgressView()
|
2020-07-04 16:34:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ToolbarItem {
|
2020-07-04 15:34:15 +02:00
|
|
|
Spacer()
|
2020-07-04 16:34:56 +02:00
|
|
|
}
|
2020-07-03 18:06:43 +02:00
|
|
|
|
2020-07-04 15:34:15 +02:00
|
|
|
ToolbarItem(placement: .automatic, content: {
|
|
|
|
Button(action: {
|
|
|
|
viewModel.showActionSheet = true
|
|
|
|
}, label: {
|
|
|
|
AppAssets.addMenuImage
|
|
|
|
.font(.title3)
|
|
|
|
})
|
|
|
|
.help("Add")
|
|
|
|
.actionSheet(isPresented: $viewModel.showActionSheet) {
|
|
|
|
ActionSheet(title: Text("Add"), buttons: [
|
|
|
|
.cancel(),
|
|
|
|
.default(Text("Add Web Feed"), action: { viewModel.sheetToShow = .web }),
|
|
|
|
.default(Text("Add Twitter Feed")),
|
|
|
|
.default(Text("Add Reddit Feed")),
|
2020-07-04 15:36:41 +02:00
|
|
|
.default(Text("Add Folder"), action: { viewModel.sheetToShow = .folder })
|
2020-07-04 15:34:15 +02:00
|
|
|
])
|
|
|
|
}
|
2020-07-02 23:18:59 +02:00
|
|
|
})
|
2020-07-04 15:34:15 +02:00
|
|
|
|
2020-07-03 17:43:20 +02:00
|
|
|
}
|
2020-07-04 15:34:15 +02:00
|
|
|
.sheet(isPresented: $viewModel.showSheet, onDismiss: { viewModel.sheetToShow = .none }) {
|
|
|
|
if viewModel.sheetToShow == .web {
|
|
|
|
AddWebFeedView()
|
|
|
|
}
|
2020-07-04 15:36:41 +02:00
|
|
|
if viewModel.sheetToShow == .folder {
|
|
|
|
AddFolderView()
|
|
|
|
}
|
2020-07-04 15:34:15 +02:00
|
|
|
if viewModel.sheetToShow == .settings {
|
2020-07-06 11:54:11 +02:00
|
|
|
SettingsView().modifier(PreferredColorSchemeModifier(preferredColorScheme: defaults.userInterfaceColorPalette))
|
2020-07-04 15:34:15 +02:00
|
|
|
}
|
2020-07-03 18:06:43 +02:00
|
|
|
}
|
2020-07-04 16:01:01 +02:00
|
|
|
#else
|
|
|
|
content
|
|
|
|
.toolbar {
|
|
|
|
ToolbarItem {
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2020-07-04 15:34:15 +02:00
|
|
|
}
|
2020-06-30 15:22:23 +02:00
|
|
|
}
|
|
|
|
|
2020-07-04 15:34:15 +02:00
|
|
|
|