Add vibrant button style

This commit is contained in:
Maurice Parker 2019-09-16 10:57:27 -05:00
parent 00310b7bd7
commit 7bda205af8
3 changed files with 60 additions and 30 deletions

View File

@ -25,6 +25,7 @@
512E09352268B25900BDCFDD /* UISplitViewController-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 512E092B2268B25500BDCFDD /* UISplitViewController-Extensions.swift */; }; 512E09352268B25900BDCFDD /* UISplitViewController-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 512E092B2268B25500BDCFDD /* UISplitViewController-Extensions.swift */; };
512E094D2268B8AB00BDCFDD /* DeleteCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C9C1FAE83C600ECDEDB /* DeleteCommand.swift */; }; 512E094D2268B8AB00BDCFDD /* DeleteCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C9C1FAE83C600ECDEDB /* DeleteCommand.swift */; };
51322855232EED360033D4ED /* VibrantSelectAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51322854232EED360033D4ED /* VibrantSelectAction.swift */; }; 51322855232EED360033D4ED /* VibrantSelectAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51322854232EED360033D4ED /* VibrantSelectAction.swift */; };
51322859232FDDB80033D4ED /* VibrantButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51322858232FDDB80033D4ED /* VibrantButtonStyle.swift */; };
513C5CE9232571C2003D4054 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513C5CE8232571C2003D4054 /* ShareViewController.swift */; }; 513C5CE9232571C2003D4054 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513C5CE8232571C2003D4054 /* ShareViewController.swift */; };
513C5CEC232571C2003D4054 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 513C5CEA232571C2003D4054 /* MainInterface.storyboard */; }; 513C5CEC232571C2003D4054 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 513C5CEA232571C2003D4054 /* MainInterface.storyboard */; };
513C5CF0232571C2003D4054 /* NetNewsWire iOS Share Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 513C5CE6232571C2003D4054 /* NetNewsWire iOS Share Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 513C5CF0232571C2003D4054 /* NetNewsWire iOS Share Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 513C5CE6232571C2003D4054 /* NetNewsWire iOS Share Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
@ -764,6 +765,7 @@
512E08F722688F7C00BDCFDD /* MasterFeedTableViewSectionHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterFeedTableViewSectionHeader.swift; sourceTree = "<group>"; }; 512E08F722688F7C00BDCFDD /* MasterFeedTableViewSectionHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterFeedTableViewSectionHeader.swift; sourceTree = "<group>"; };
512E092B2268B25500BDCFDD /* UISplitViewController-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UISplitViewController-Extensions.swift"; sourceTree = "<group>"; }; 512E092B2268B25500BDCFDD /* UISplitViewController-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UISplitViewController-Extensions.swift"; sourceTree = "<group>"; };
51322854232EED360033D4ED /* VibrantSelectAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VibrantSelectAction.swift; sourceTree = "<group>"; }; 51322854232EED360033D4ED /* VibrantSelectAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VibrantSelectAction.swift; sourceTree = "<group>"; };
51322858232FDDB80033D4ED /* VibrantButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VibrantButtonStyle.swift; sourceTree = "<group>"; };
513C5CE6232571C2003D4054 /* NetNewsWire iOS Share Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "NetNewsWire iOS Share Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; 513C5CE6232571C2003D4054 /* NetNewsWire iOS Share Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "NetNewsWire iOS Share Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
513C5CE8232571C2003D4054 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; }; 513C5CE8232571C2003D4054 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
513C5CEB232571C2003D4054 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; }; 513C5CEB232571C2003D4054 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
@ -1252,6 +1254,7 @@
children = ( children = (
DF999FF622B5AEFA0064B687 /* SafariView.swift */, DF999FF622B5AEFA0064B687 /* SafariView.swift */,
51322854232EED360033D4ED /* VibrantSelectAction.swift */, 51322854232EED360033D4ED /* VibrantSelectAction.swift */,
51322858232FDDB80033D4ED /* VibrantButtonStyle.swift */,
); );
path = "SwiftUI Extensions"; path = "SwiftUI Extensions";
sourceTree = "<group>"; sourceTree = "<group>";
@ -2652,6 +2655,7 @@
51C452772265091600C03939 /* MultilineUILabelSizer.swift in Sources */, 51C452772265091600C03939 /* MultilineUILabelSizer.swift in Sources */,
51C452A522650A2D00C03939 /* SmallIconProvider.swift in Sources */, 51C452A522650A2D00C03939 /* SmallIconProvider.swift in Sources */,
51D5948722668EFA00DFC836 /* MarkStatusCommand.swift in Sources */, 51D5948722668EFA00DFC836 /* MarkStatusCommand.swift in Sources */,
51322859232FDDB80033D4ED /* VibrantButtonStyle.swift in Sources */,
514B7C8323205EFB00BAC947 /* RootSplitViewController.swift in Sources */, 514B7C8323205EFB00BAC947 /* RootSplitViewController.swift in Sources */,
5152E0F923248F6200E5C7AD /* SettingsLocalAccountView.swift in Sources */, 5152E0F923248F6200E5C7AD /* SettingsLocalAccountView.swift in Sources */,
FF3ABF162325AF5D0074C542 /* ArticleSorter.swift in Sources */, FF3ABF162325AF5D0074C542 /* ArticleSorter.swift in Sources */,

View File

@ -36,6 +36,7 @@ struct SettingsView : View {
buildDatabaseSection() buildDatabaseSection()
buildAboutSection() buildAboutSection()
} }
.buttonStyle(VibrantButtonStyle())
.navigationBarTitle(Text("Settings"), displayMode: .inline) .navigationBarTitle(Text("Settings"), displayMode: .inline)
.navigationBarItems(leading: Button(action: { self.viewController?.dismiss(animated: true) }) { Text("Done") } ) .navigationBarItems(leading: Button(action: { self.viewController?.dismiss(animated: true) }) { Text("Done") } )
} }
@ -43,14 +44,20 @@ struct SettingsView : View {
func buildAccountsSection() -> some View { func buildAccountsSection() -> some View {
Section(header: Text("ACCOUNTS").padding(.top, 22.0)) { Section(header: Text("ACCOUNTS").padding(.top, 22.0)) {
ForEach(viewModel.accounts) { account in ForEach(0..<viewModel.accounts.count) { index in
NavigationLink(destination: SettingsDetailAccountView(viewModel: SettingsDetailAccountView.ViewModel(account))) { NavigationLink(destination: SettingsDetailAccountView(viewModel: SettingsDetailAccountView.ViewModel(self.viewModel.accounts[index])), tag: index, selection: self.$accountAction) {
Text(verbatim: account.nameForDisplay) Text(verbatim: self.viewModel.accounts[index].nameForDisplay)
} }
.modifier(VibrantSelectAction(action: {
self.accountAction = index
}))
} }
NavigationLink(destination: SettingsAddAccountView()) { NavigationLink(destination: SettingsAddAccountView(), tag: 1000, selection: $accountAction) {
Text("Add Account") Text("Add Account")
} }
.modifier(VibrantSelectAction(action: {
self.accountAction = 1000
}))
} }
} }
@ -77,7 +84,6 @@ struct SettingsView : View {
} }
} }
VStack {
Button("Import Subscriptions...") { Button("Import Subscriptions...") {
if AccountManager.shared.activeAccounts.count == 1 { if AccountManager.shared.activeAccounts.count == 1 {
self.opmlAccount = AccountManager.shared.activeAccounts.first self.opmlAccount = AccountManager.shared.activeAccounts.first
@ -85,14 +91,12 @@ struct SettingsView : View {
} else { } else {
self.isOPMLImportPresented = true self.isOPMLImportPresented = true
} }
}
}.actionSheet(isPresented: $isOPMLImportPresented) { }.actionSheet(isPresented: $isOPMLImportPresented) {
buildSubscriptionsImportAccounts() buildSubscriptionsImportAccounts()
}.sheet(isPresented: $isOPMLImportDocPickerPresented) { }.sheet(isPresented: $isOPMLImportDocPickerPresented) {
SettingsSubscriptionsImportDocumentPickerView(account: self.opmlAccount!) SettingsSubscriptionsImportDocumentPickerView(account: self.opmlAccount!)
}.foregroundColor(.primary) }
VStack {
Button("Export Subscriptions...") { Button("Export Subscriptions...") {
if AccountManager.shared.accounts.count == 1 { if AccountManager.shared.accounts.count == 1 {
self.opmlAccount = AccountManager.shared.accounts.first self.opmlAccount = AccountManager.shared.accounts.first
@ -100,12 +104,11 @@ struct SettingsView : View {
} else { } else {
self.isOPMLExportPresented = true self.isOPMLExportPresented = true
} }
}
}.actionSheet(isPresented: $isOPMLExportPresented) { }.actionSheet(isPresented: $isOPMLExportPresented) {
buildSubscriptionsExportAccounts() buildSubscriptionsExportAccounts()
}.sheet(isPresented: $isOPMLExportDocPickerPresented) { }.sheet(isPresented: $isOPMLExportDocPickerPresented) {
SettingsSubscriptionsExportDocumentPickerView(account: self.opmlAccount!) SettingsSubscriptionsExportDocumentPickerView(account: self.opmlAccount!)
}.foregroundColor(.primary) }
} }
} }
@ -118,35 +121,35 @@ struct SettingsView : View {
self.website = "https://ranchero.com/netnewswire/" self.website = "https://ranchero.com/netnewswire/"
}) { }) {
Text("Website") Text("Website")
}.foregroundColor(.primary) }
Button(action: { Button(action: {
self.isWebsitePresented.toggle() self.isWebsitePresented.toggle()
self.website = "https://github.com/brentsimmons/NetNewsWire" self.website = "https://github.com/brentsimmons/NetNewsWire"
}) { }) {
Text("Github Repository") Text("Github Repository")
}.foregroundColor(.primary) }
Button(action: { Button(action: {
self.isWebsitePresented.toggle() self.isWebsitePresented.toggle()
self.website = "https://github.com/brentsimmons/NetNewsWire/issues" self.website = "https://github.com/brentsimmons/NetNewsWire/issues"
}) { }) {
Text("Bug Tracker") Text("Bug Tracker")
}.foregroundColor(.primary) }
Button(action: { Button(action: {
self.isWebsitePresented.toggle() self.isWebsitePresented.toggle()
self.website = "https://github.com/brentsimmons/NetNewsWire/tree/master/Technotes" self.website = "https://github.com/brentsimmons/NetNewsWire/tree/master/Technotes"
}) { }) {
Text("Technotes") Text("Technotes")
}.foregroundColor(.primary) }
Button(action: { Button(action: {
self.isWebsitePresented.toggle() self.isWebsitePresented.toggle()
self.website = "https://github.com/brentsimmons/NetNewsWire/blob/master/Technotes/HowToSupportNetNewsWire.markdown" self.website = "https://github.com/brentsimmons/NetNewsWire/blob/master/Technotes/HowToSupportNetNewsWire.markdown"
}) { }) {
Text("How To Support NetNewsWire") Text("How To Support NetNewsWire")
}.foregroundColor(.primary) }
if !AccountManager.shared.anyAccountHasFeedWithURL("https://nnw.ranchero.com/feed.json") { if !AccountManager.shared.anyAccountHasFeedWithURL("https://nnw.ranchero.com/feed.json") {
Button(action: { Button(action: {
@ -156,7 +159,7 @@ struct SettingsView : View {
} }
}) { }) {
Text("Add NetNewsWire News Feed") Text("Add NetNewsWire News Feed")
}.foregroundColor(.primary) }
} }
}.sheet(isPresented: $isWebsitePresented) { }.sheet(isPresented: $isWebsitePresented) {

View File

@ -0,0 +1,23 @@
//
// VibrantButtonStyle.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 9/16/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import SwiftUI
struct VibrantButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
GeometryReader { geometry in
configuration.label
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .leading)
}
.foregroundColor(configuration.isPressed ? Color(AppAssets.tableViewCellHighlightedTextColor) : .primary)
.listRowBackground(configuration.isPressed ? Color(AppAssets.tableViewCellSelectionColor) : Color(.secondarySystemGroupedBackground))
.background(configuration.isPressed ? Color(AppAssets.tableViewCellSelectionColor) : Color(.secondarySystemGroupedBackground))
}
}