Refactors GeneralPrefs Model
This commit is contained in:
parent
c630bf3b9f
commit
d8c5d3719c
|
@ -7,17 +7,33 @@
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
|
enum PreferencePane: Int, CaseIterable {
|
||||||
|
case general = 0
|
||||||
|
case accounts = 1
|
||||||
|
case advanced = 2
|
||||||
|
|
||||||
|
var description: String {
|
||||||
|
switch self {
|
||||||
|
case .general:
|
||||||
|
return "General"
|
||||||
|
case .accounts:
|
||||||
|
return "Accounts"
|
||||||
|
case .advanced:
|
||||||
|
return "Advanced"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct MacPreferencesView: View {
|
struct MacPreferencesView: View {
|
||||||
|
|
||||||
@EnvironmentObject var defaults: AppDefaults
|
@EnvironmentObject var defaults: AppDefaults
|
||||||
@StateObject private var viewModel = MacPreferencesModel()
|
@State private var preferencePane: PreferencePane = .general
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
switch viewModel.currentPreferencePane {
|
switch preferencePane {
|
||||||
case .general:
|
case .general:
|
||||||
GeneralPreferencesView(preferences: viewModel)
|
GeneralPreferencesView()
|
||||||
.environmentObject(defaults)
|
.environmentObject(defaults)
|
||||||
case .accounts:
|
case .accounts:
|
||||||
AccountsPreferencesView()
|
AccountsPreferencesView()
|
||||||
|
@ -31,36 +47,36 @@ struct MacPreferencesView: View {
|
||||||
ToolbarItem {
|
ToolbarItem {
|
||||||
HStack {
|
HStack {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
viewModel.currentPreferencePane = .general
|
preferencePane = .general
|
||||||
}, label: {
|
}, label: {
|
||||||
VStack {
|
VStack {
|
||||||
Image(systemName: "gearshape")
|
Image(systemName: "gearshape")
|
||||||
.font(.title2)
|
.font(.title2)
|
||||||
Text("General")
|
Text("General")
|
||||||
}.foregroundColor(
|
}.foregroundColor(
|
||||||
viewModel.currentPreferencePane == .general ? Color("AccentColor") : Color.gray
|
preferencePane == .general ? Color("AccentColor") : Color.gray
|
||||||
)
|
)
|
||||||
}).frame(width: 70)
|
}).frame(width: 70)
|
||||||
Button(action: {
|
Button(action: {
|
||||||
viewModel.currentPreferencePane = .accounts
|
preferencePane = .accounts
|
||||||
}, label: {
|
}, label: {
|
||||||
VStack {
|
VStack {
|
||||||
Image(systemName: "at")
|
Image(systemName: "at")
|
||||||
.font(.title2)
|
.font(.title2)
|
||||||
Text("Accounts")
|
Text("Accounts")
|
||||||
}.foregroundColor(
|
}.foregroundColor(
|
||||||
viewModel.currentPreferencePane == .accounts ? Color("AccentColor") : Color.gray
|
preferencePane == .accounts ? Color("AccentColor") : Color.gray
|
||||||
)
|
)
|
||||||
}).frame(width: 70)
|
}).frame(width: 70)
|
||||||
Button(action: {
|
Button(action: {
|
||||||
viewModel.currentPreferencePane = .advanced
|
preferencePane = .advanced
|
||||||
}, label: {
|
}, label: {
|
||||||
VStack {
|
VStack {
|
||||||
Image(systemName: "scale.3d")
|
Image(systemName: "scale.3d")
|
||||||
.font(.title2)
|
.font(.title2)
|
||||||
Text("Advanced")
|
Text("Advanced")
|
||||||
}.foregroundColor(
|
}.foregroundColor(
|
||||||
viewModel.currentPreferencePane == .advanced ? Color("AccentColor") : Color.gray
|
preferencePane == .advanced ? Color("AccentColor") : Color.gray
|
||||||
)
|
)
|
||||||
}).frame(width: 70)
|
}).frame(width: 70)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,9 @@ import RSCore
|
||||||
class AddAccountModel: ObservableObject {
|
class AddAccountModel: ObservableObject {
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
var addableAccountTypes: [AccountType] = [.onMyMac, .feedbin, .feedly, .feedWrangler, .freshRSS, .cloudKit, .newsBlur]
|
let addableAccountTypes: [AccountType] = [.onMyMac, .feedbin, .feedly, .feedWrangler, .freshRSS, .cloudKit, .newsBlur]
|
||||||
#else
|
#else
|
||||||
var addableAccountTypes: [AccountType] = [.onMyMac, .feedbin, .feedly]
|
let addableAccountTypes: [AccountType] = [.onMyMac, .feedbin, .feedly]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Add Accounts
|
// Add Accounts
|
||||||
|
|
|
@ -44,13 +44,8 @@ struct AddAccountView: View {
|
||||||
case .newsBlur:
|
case .newsBlur:
|
||||||
userNameAndPasswordView
|
userNameAndPasswordView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
HStack {
|
HStack {
|
||||||
if viewModel.accountIsAuthenticating {
|
if viewModel.accountIsAuthenticating {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// MacPreferencesModel.swift
|
// GeneralPreferencesModel.swift
|
||||||
// Multiplatform macOS
|
// Multiplatform macOS
|
||||||
//
|
//
|
||||||
// Created by Stuart Breckenridge on 12/7/20.
|
// Created by Stuart Breckenridge on 12/7/20.
|
||||||
|
@ -8,26 +8,10 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum PreferencePane: Int, CaseIterable {
|
|
||||||
case general = 0
|
|
||||||
case accounts = 1
|
|
||||||
case advanced = 2
|
|
||||||
|
|
||||||
var description: String {
|
|
||||||
switch self {
|
|
||||||
case .general:
|
|
||||||
return "General"
|
|
||||||
case .accounts:
|
|
||||||
return "Accounts"
|
|
||||||
case .advanced:
|
|
||||||
return "Advanced"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MacPreferencesModel: ObservableObject {
|
|
||||||
|
class GeneralPreferencesModel: ObservableObject {
|
||||||
|
|
||||||
@Published var currentPreferencePane: PreferencePane = PreferencePane.general
|
|
||||||
@Published var rssReaders = [RSSReader]()
|
@Published var rssReaders = [RSSReader]()
|
||||||
@Published var readerSelection: Int = 0 {
|
@Published var readerSelection: Int = 0 {
|
||||||
willSet {
|
willSet {
|
||||||
|
@ -47,7 +31,7 @@ class MacPreferencesModel: ObservableObject {
|
||||||
|
|
||||||
// MARK:- RSS Readers
|
// MARK:- RSS Readers
|
||||||
|
|
||||||
private extension MacPreferencesModel {
|
private extension GeneralPreferencesModel {
|
||||||
|
|
||||||
func prepareRSSReaders() {
|
func prepareRSSReaders() {
|
||||||
|
|
|
@ -11,7 +11,7 @@ struct GeneralPreferencesView: View {
|
||||||
|
|
||||||
@EnvironmentObject private var defaults: AppDefaults
|
@EnvironmentObject private var defaults: AppDefaults
|
||||||
@Environment(\.colorScheme) private var colorScheme
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
@ObservedObject var preferences: MacPreferencesModel
|
@StateObject private var preferences = GeneralPreferencesModel()
|
||||||
private let colorPalettes = UserInterfaceColorPalette.allCases
|
private let colorPalettes = UserInterfaceColorPalette.allCases
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
1717535624BADF33004498C6 /* MacPreferencesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1717535524BADF33004498C6 /* MacPreferencesModel.swift */; };
|
1717535624BADF33004498C6 /* GeneralPreferencesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1717535524BADF33004498C6 /* GeneralPreferencesModel.swift */; };
|
||||||
172199C924AB228900A31D04 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172199C824AB228900A31D04 /* SettingsView.swift */; };
|
172199C924AB228900A31D04 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172199C824AB228900A31D04 /* SettingsView.swift */; };
|
||||||
172199ED24AB2E0100A31D04 /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172199EC24AB2E0100A31D04 /* SafariView.swift */; };
|
172199ED24AB2E0100A31D04 /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172199EC24AB2E0100A31D04 /* SafariView.swift */; };
|
||||||
172199F124AB716900A31D04 /* SidebarToolbarModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172199F024AB716900A31D04 /* SidebarToolbarModifier.swift */; };
|
172199F124AB716900A31D04 /* SidebarToolbarModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172199F024AB716900A31D04 /* SidebarToolbarModifier.swift */; };
|
||||||
|
@ -1788,7 +1788,7 @@
|
||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
1717535524BADF33004498C6 /* MacPreferencesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacPreferencesModel.swift; sourceTree = "<group>"; };
|
1717535524BADF33004498C6 /* GeneralPreferencesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralPreferencesModel.swift; sourceTree = "<group>"; };
|
||||||
172199C824AB228900A31D04 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
|
172199C824AB228900A31D04 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
|
||||||
172199EC24AB2E0100A31D04 /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = "<group>"; };
|
172199EC24AB2E0100A31D04 /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = "<group>"; };
|
||||||
172199F024AB716900A31D04 /* SidebarToolbarModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarToolbarModifier.swift; sourceTree = "<group>"; };
|
172199F024AB716900A31D04 /* SidebarToolbarModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarToolbarModifier.swift; sourceTree = "<group>"; };
|
||||||
|
@ -2523,7 +2523,6 @@
|
||||||
1729528F24AA1A4F00D65E66 /* Preferences */ = {
|
1729528F24AA1A4F00D65E66 /* Preferences */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
1717535524BADF33004498C6 /* MacPreferencesModel.swift */,
|
|
||||||
1729529624AA1CD000D65E66 /* MacPreferencesView.swift */,
|
1729529624AA1CD000D65E66 /* MacPreferencesView.swift */,
|
||||||
1729529924AA1CE100D65E66 /* Preference Panes */,
|
1729529924AA1CE100D65E66 /* Preference Panes */,
|
||||||
);
|
);
|
||||||
|
@ -2543,6 +2542,7 @@
|
||||||
1769E2FD24BC589E000E1E8E /* General */ = {
|
1769E2FD24BC589E000E1E8E /* General */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
1717535524BADF33004498C6 /* GeneralPreferencesModel.swift */,
|
||||||
1729529224AA1CAA00D65E66 /* GeneralPreferencesView.swift */,
|
1729529224AA1CAA00D65E66 /* GeneralPreferencesView.swift */,
|
||||||
);
|
);
|
||||||
path = General;
|
path = General;
|
||||||
|
@ -5216,7 +5216,7 @@
|
||||||
51E4996C24A8762D00B667CB /* ExtractedArticle.swift in Sources */,
|
51E4996C24A8762D00B667CB /* ExtractedArticle.swift in Sources */,
|
||||||
51E4990824A808C300B667CB /* RSHTMLMetadata+Extension.swift in Sources */,
|
51E4990824A808C300B667CB /* RSHTMLMetadata+Extension.swift in Sources */,
|
||||||
51919FF824AB8B7700541E64 /* TimelineView.swift in Sources */,
|
51919FF824AB8B7700541E64 /* TimelineView.swift in Sources */,
|
||||||
1717535624BADF33004498C6 /* MacPreferencesModel.swift in Sources */,
|
1717535624BADF33004498C6 /* GeneralPreferencesModel.swift in Sources */,
|
||||||
51E4992B24A8676300B667CB /* ArticleArray.swift in Sources */,
|
51E4992B24A8676300B667CB /* ArticleArray.swift in Sources */,
|
||||||
51B54AB324B5AC830014348B /* ArticleButtonState.swift in Sources */,
|
51B54AB324B5AC830014348B /* ArticleButtonState.swift in Sources */,
|
||||||
17D5F17224B0BC6700375168 /* SidebarToolbarModel.swift in Sources */,
|
17D5F17224B0BC6700375168 /* SidebarToolbarModel.swift in Sources */,
|
||||||
|
|
Loading…
Reference in New Issue