mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
refactoring
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// AccountsPreferenceModel.swift
|
||||
// AccountsPreferencesModel.swift
|
||||
// Multiplatform macOS
|
||||
//
|
||||
// Created by Stuart Breckenridge on 13/7/20.
|
||||
@@ -10,8 +10,7 @@ import Foundation
|
||||
import Account
|
||||
import Combine
|
||||
|
||||
class AccountsPreferenceModel: ObservableObject {
|
||||
|
||||
class AccountsPreferencesModel: ObservableObject {
|
||||
|
||||
@Published var sortedAccounts: [Account] = []
|
||||
@Published var selectedConfiguredAccountID: String? = nil
|
||||
@@ -11,8 +11,7 @@ import Account
|
||||
|
||||
struct AccountsPreferencesView: View {
|
||||
|
||||
@StateObject var viewModel = AccountsPreferenceModel()
|
||||
|
||||
@StateObject var viewModel = AccountsPreferencesModel()
|
||||
@State private var hoverOnAdd: Bool = false
|
||||
@State private var hoverOnRemove: Bool = false
|
||||
|
||||
@@ -88,64 +87,6 @@ struct AccountsPreferencesView: View {
|
||||
}
|
||||
.background(Color.white)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct ConfiguredAccountRow: View {
|
||||
|
||||
var account: Account
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center) {
|
||||
if let img = account.smallIcon?.image {
|
||||
Image(rsImage: img)
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
.aspectRatio(contentMode: .fit)
|
||||
}
|
||||
Text(account.nameForDisplay)
|
||||
}.padding(.vertical, 4)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct AddAccountPickerRow: View {
|
||||
|
||||
var accountType: AccountType
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
if let img = AppAssets.image(for: accountType) {
|
||||
Image(rsImage: img)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 15, height: 15)
|
||||
}
|
||||
|
||||
switch accountType {
|
||||
case .onMyMac:
|
||||
Text(Account.defaultLocalAccountName)
|
||||
case .cloudKit:
|
||||
Text("iCloud")
|
||||
case .feedbin:
|
||||
Text("Feedbin")
|
||||
case .feedWrangler:
|
||||
Text("FeedWrangler")
|
||||
case .freshRSS:
|
||||
Text("FreshRSS")
|
||||
case .feedly:
|
||||
Text("Feedly")
|
||||
case .newsBlur:
|
||||
Text("NewsBlur")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// AddAccountPickerRow.swift
|
||||
// Multiplatform macOS
|
||||
//
|
||||
// Created by Stuart Breckenridge on 13/7/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Account
|
||||
|
||||
struct AddAccountPickerRow: View {
|
||||
|
||||
var accountType: AccountType
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
if let img = AppAssets.image(for: accountType) {
|
||||
Image(rsImage: img)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 15, height: 15)
|
||||
}
|
||||
|
||||
switch accountType {
|
||||
case .onMyMac:
|
||||
Text(Account.defaultLocalAccountName)
|
||||
case .cloudKit:
|
||||
Text("iCloud")
|
||||
case .feedbin:
|
||||
Text("Feedbin")
|
||||
case .feedWrangler:
|
||||
Text("FeedWrangler")
|
||||
case .freshRSS:
|
||||
Text("FreshRSS")
|
||||
case .feedly:
|
||||
Text("Feedly")
|
||||
case .newsBlur:
|
||||
Text("NewsBlur")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AddAccountPickerRow_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AddAccountPickerRow(accountType: .onMyMac)
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import Account
|
||||
struct AddAccountView: View {
|
||||
|
||||
@Environment(\.presentationMode) private var presentationMode
|
||||
@ObservedObject var preferencesModel: AccountsPreferenceModel
|
||||
@ObservedObject var preferencesModel: AccountsPreferencesModel
|
||||
@StateObject private var viewModel = AddAccountModel()
|
||||
|
||||
var body: some View {
|
||||
@@ -133,6 +133,6 @@ struct AddAccountView: View {
|
||||
}
|
||||
struct AddAccountView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AddAccountView(preferencesModel: AccountsPreferenceModel())
|
||||
AddAccountView(preferencesModel: AccountsPreferencesModel())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// ConfiguredAccountRow.swift
|
||||
// Multiplatform macOS
|
||||
//
|
||||
// Created by Stuart Breckenridge on 13/7/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Account
|
||||
|
||||
struct ConfiguredAccountRow: View {
|
||||
|
||||
var account: Account
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center) {
|
||||
if let img = account.smallIcon?.image {
|
||||
Image(rsImage: img)
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
.aspectRatio(contentMode: .fit)
|
||||
}
|
||||
Text(account.nameForDisplay)
|
||||
}.padding(.vertical, 4)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct ConfiguredAccountRow_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ConfiguredAccountRow()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user