Adds early work on managing appearance

This commit is contained in:
Stuart Breckenridge
2022-11-12 23:10:30 +08:00
parent bb49e744ae
commit 9fc6c54222
13 changed files with 194 additions and 9 deletions

View File

@@ -864,6 +864,7 @@
DFD406F7291FB1A600C02962 /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFD406F6291FB1A600C02962 /* SafariView.swift */; };
DFD406FA291FB5E400C02962 /* SettingsRows.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFD406F9291FB5E400C02962 /* SettingsRows.swift */; };
DFD406FC291FB63B00C02962 /* SettingsHelpSheets.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFD406FB291FB63B00C02962 /* SettingsHelpSheets.swift */; };
DFD406FF291FDC0C00C02962 /* AppearanceManagementView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFD406FE291FDC0C00C02962 /* AppearanceManagementView.swift */; };
DFFB8FC2279B75E300AC21D7 /* Account in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 51BC2F4A24D343A500E90810 /* Account */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
DFFC199827A0D0D7004B7AEF /* NotificationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFFC199727A0D0D7004B7AEF /* NotificationsViewController.swift */; };
DFFC199A27A0D32A004B7AEF /* NotificationsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFFC199927A0D32A004B7AEF /* NotificationsTableViewCell.swift */; };
@@ -1609,6 +1610,7 @@
DFD406F6291FB1A600C02962 /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = "<group>"; };
DFD406F9291FB5E400C02962 /* SettingsRows.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRows.swift; sourceTree = "<group>"; };
DFD406FB291FB63B00C02962 /* SettingsHelpSheets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsHelpSheets.swift; sourceTree = "<group>"; };
DFD406FE291FDC0C00C02962 /* AppearanceManagementView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceManagementView.swift; sourceTree = "<group>"; };
DFD6AACB27ADE80900463FAD /* NewsFax.nnwtheme */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = NewsFax.nnwtheme; sourceTree = "<group>"; };
DFFC199727A0D0D7004B7AEF /* NotificationsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsViewController.swift; sourceTree = "<group>"; };
DFFC199927A0D32A004B7AEF /* NotificationsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsTableViewCell.swift; sourceTree = "<group>"; };
@@ -2009,6 +2011,7 @@
519ED47924482AEB007F8E94 /* EnableExtensionPointViewController.swift */,
51A16990235E10D600EB091F /* Settings.storyboard */,
DFD406F8291FB5D500C02962 /* Settings View */,
DFD406FD291FDBD900C02962 /* Appearance View */,
516A09382360A2AE00EAE89B /* SettingsComboTableViewCell.swift */,
516A091D23609A3600EAE89B /* SettingsComboTableViewCell.xib */,
516A093A2360A4A000EAE89B /* SettingsTableViewCell.xib */,
@@ -2902,6 +2905,14 @@
path = "Settings View";
sourceTree = "<group>";
};
DFD406FD291FDBD900C02962 /* Appearance View */ = {
isa = PBXGroup;
children = (
DFD406FE291FDC0C00C02962 /* AppearanceManagementView.swift */,
);
path = "Appearance View";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -4058,6 +4069,7 @@
B2B80778239C4C7000F191E0 /* RSImage-AppIcons.swift in Sources */,
518ED21D23D0F26000E0A862 /* UIViewController-Extensions.swift in Sources */,
DFFC199827A0D0D7004B7AEF /* NotificationsViewController.swift in Sources */,
DFD406FF291FDC0C00C02962 /* AppearanceManagementView.swift in Sources */,
51A9A5F52380F6A60033AADF /* ModalNavigationController.swift in Sources */,
51EAED96231363EF00A9EEE3 /* NonIntrinsicButton.swift in Sources */,
51C4527B2265091600C03939 /* MasterUnreadIndicatorView.swift in Sources */,

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "app.appearance.automatic.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "app.appearance.automatic 1.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "app.appearance.dark.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "app.appearance.dark 1.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "app.appearance.light.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "app.appearance.light 1.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,108 @@
//
// AppearanceManagementView.swift
// NetNewsWire-iOS
//
// Created by Stuart Breckenridge on 12/11/2022.
// Copyright © 2022 Ranchero Software. All rights reserved.
//
import SwiftUI
struct AppearanceManagementView: View {
@StateObject private var appDefaults = AppDefaults.shared
var body: some View {
List {
Section("Application Appearance") {
HStack {
appLightButton()
Spacer()
appDarkButton()
Spacer()
appAutomaticButton()
}
.listRowBackground(Color.clear)
}
Section("Timeline Appearance") {
SettingsViewRows.SortOldestToNewest($appDefaults.timelineSortDirectionBool)
SettingsViewRows.GroupByFeed($appDefaults.timelineGroupByFeed)
SettingsViewRows.RefreshToClearReadArticles($appDefaults.refreshClearsReadArticles)
}
Section("Article Appearance") {
SettingsViewRows.ThemeSelection
SettingsViewRows.ConfirmMarkAllAsRead($appDefaults.confirmMarkAllAsRead)
SettingsViewRows.OpenLinksInNetNewsWire($appDefaults.useSystemBrowser)
SettingsViewRows.EnableFullScreenArticles($appDefaults.articleFullscreenEnabled)
}
}
.navigationTitle(Text("Appearance"))
.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
}
}
}
struct AppearanceManagementView_Previews: PreviewProvider {
static var previews: some View {
AppearanceManagementView()
}
}

View File

@@ -179,13 +179,12 @@ struct SettingsViewRows {
static var ThemeSelection: some View {
NavigationLink(destination: ArticleThemesViewControllerRepresentable().edgesIgnoringSafeArea(.all)) {
Label {
Text("Article Themes")
} icon: {
Image(systemName: "textformat")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 25.0, height: 25.0)
HStack {
Text("Article Theme")
Spacer()
Text(ArticleThemesManager.shared.currentTheme.name)
.font(.callout)
.foregroundColor(.secondary)
}
}
}
@@ -212,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: NotificationsViewControllerRepresentable().edgesIgnoringSafeArea(.all)) {
NavigationLink(destination: AppearanceManagementView()) {
Label {
Text("Appearance")
} icon: {

View File

@@ -32,8 +32,8 @@ struct SettingsView: View {
}
Section(footer: Text("Configure the look and feel of NetNewsWire.")) {
SettingsViewRows.ConfigureNewArticleNotifications
SettingsViewRows.ConfigureAppearance
SettingsViewRows.ConfigureNewArticleNotifications
}