mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Minor refactor and renaming
This commit is contained in:
87
iOS/Settings/Appearance View/ColorPaletteSelectorView.swift
Normal file
87
iOS/Settings/Appearance View/ColorPaletteSelectorView.swift
Normal file
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// ColorPaletteSelectorView.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Stuart Breckenridge on 13/11/2022.
|
||||
// Copyright © 2022 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ColorPaletteSelectorView: View {
|
||||
|
||||
@StateObject private var appDefaults = AppDefaults.shared
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
appLightButton()
|
||||
Spacer()
|
||||
appDarkButton()
|
||||
Spacer()
|
||||
appAutomaticButton()
|
||||
}
|
||||
}
|
||||
|
||||
func appLightButton() -> some View {
|
||||
VStack(spacing: 4) {
|
||||
Image("app.appearance.light")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 40.0, height: 40.0)
|
||||
Text("Always Light")
|
||||
.font(.subheadline)
|
||||
if AppDefaults.userInterfaceColorPalette == .light {
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.foregroundColor(Color(uiColor: AppAssets.primaryAccentColor))
|
||||
} else {
|
||||
Image(systemName: "circle")
|
||||
}
|
||||
}.onTapGesture {
|
||||
AppDefaults.userInterfaceColorPalette = .light
|
||||
}
|
||||
}
|
||||
|
||||
func appDarkButton() -> some View {
|
||||
VStack(spacing: 4) {
|
||||
Image("app.appearance.dark")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 40.0, height: 40.0)
|
||||
Text("Always Dark")
|
||||
.font(.subheadline)
|
||||
if AppDefaults.userInterfaceColorPalette == .dark {
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.foregroundColor(Color(uiColor: AppAssets.primaryAccentColor))
|
||||
} else {
|
||||
Image(systemName: "circle")
|
||||
}
|
||||
}.onTapGesture {
|
||||
AppDefaults.userInterfaceColorPalette = .dark
|
||||
}
|
||||
}
|
||||
|
||||
func appAutomaticButton() -> some View {
|
||||
VStack(spacing: 4) {
|
||||
Image("app.appearance.automatic")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 40.0, height: 40.0)
|
||||
Text("Use System")
|
||||
.font(.subheadline)
|
||||
if AppDefaults.userInterfaceColorPalette == .automatic {
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.foregroundColor(Color(uiColor: AppAssets.primaryAccentColor))
|
||||
} else {
|
||||
Image(systemName: "circle")
|
||||
}
|
||||
}.onTapGesture {
|
||||
AppDefaults.userInterfaceColorPalette = .automatic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct DisplayModeView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ColorPaletteSelectorView()
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,7 @@ struct DisplayAndBehaviorsView: View {
|
||||
var body: some View {
|
||||
List {
|
||||
Section("Application") {
|
||||
HStack {
|
||||
appLightButton()
|
||||
Spacer()
|
||||
appDarkButton()
|
||||
Spacer()
|
||||
appAutomaticButton()
|
||||
}
|
||||
ColorPaletteSelectorView()
|
||||
.listRowBackground(Color.clear)
|
||||
}
|
||||
|
||||
@@ -44,62 +38,7 @@ struct DisplayAndBehaviorsView: View {
|
||||
.tint(Color(uiColor: AppAssets.primaryAccentColor))
|
||||
}
|
||||
|
||||
func appLightButton() -> some View {
|
||||
VStack(spacing: 4) {
|
||||
Image("app.appearance.light")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 40.0, height: 40.0)
|
||||
Text("Always Light")
|
||||
.font(.subheadline)
|
||||
if AppDefaults.userInterfaceColorPalette == .light {
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.foregroundColor(Color(uiColor: AppAssets.primaryAccentColor))
|
||||
} else {
|
||||
Image(systemName: "circle")
|
||||
}
|
||||
}.onTapGesture {
|
||||
AppDefaults.userInterfaceColorPalette = .light
|
||||
}
|
||||
}
|
||||
|
||||
func appDarkButton() -> some View {
|
||||
VStack(spacing: 4) {
|
||||
Image("app.appearance.dark")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 40.0, height: 40.0)
|
||||
Text("Always Dark")
|
||||
.font(.subheadline)
|
||||
if AppDefaults.userInterfaceColorPalette == .dark {
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.foregroundColor(Color(uiColor: AppAssets.primaryAccentColor))
|
||||
} else {
|
||||
Image(systemName: "circle")
|
||||
}
|
||||
}.onTapGesture {
|
||||
AppDefaults.userInterfaceColorPalette = .dark
|
||||
}
|
||||
}
|
||||
|
||||
func appAutomaticButton() -> some View {
|
||||
VStack(spacing: 4) {
|
||||
Image("app.appearance.automatic")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 40.0, height: 40.0)
|
||||
Text("Use System")
|
||||
.font(.subheadline)
|
||||
if AppDefaults.userInterfaceColorPalette == .automatic {
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.foregroundColor(Color(uiColor: AppAssets.primaryAccentColor))
|
||||
} else {
|
||||
Image(systemName: "circle")
|
||||
}
|
||||
}.onTapGesture {
|
||||
AppDefaults.userInterfaceColorPalette = .automatic
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ struct SettingsViewRows {
|
||||
/// This row, when tapped, will push the New Article Notifications
|
||||
/// screen in to view.
|
||||
static var ConfigureAppearance: some View {
|
||||
NavigationLink(destination: AppearanceManagementView()) {
|
||||
NavigationLink(destination: DisplayAndBehaviorsView()) {
|
||||
Label {
|
||||
Text("Display & Behaviors")
|
||||
} icon: {
|
||||
|
||||
Reference in New Issue
Block a user