From 46c1dabe62a3e05e7ef0b903b4486dcf2ff1ca14 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 16 Sep 2019 12:06:47 -0500 Subject: [PATCH] Add simulated refresh interval picker --- NetNewsWire.xcodeproj/project.pbxproj | 4 +++ .../SettingsRefreshSelectionView.swift | 35 +++++++++++++++++++ iOS/Settings/SettingsView.swift | 16 ++++++--- 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 iOS/Settings/SettingsRefreshSelectionView.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 140d1cb60..b47f3eee6 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 512E094D2268B8AB00BDCFDD /* DeleteCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C9C1FAE83C600ECDEDB /* DeleteCommand.swift */; }; 51322855232EED360033D4ED /* VibrantSelectAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51322854232EED360033D4ED /* VibrantSelectAction.swift */; }; 51322859232FDDB80033D4ED /* VibrantButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51322858232FDDB80033D4ED /* VibrantButtonStyle.swift */; }; + 5132285B232FF2C40033D4ED /* SettingsRefreshSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5132285A232FF2C40033D4ED /* SettingsRefreshSelectionView.swift */; }; 513C5CE9232571C2003D4054 /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 513C5CE8232571C2003D4054 /* ShareViewController.swift */; }; 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, ); }; }; @@ -766,6 +767,7 @@ 512E092B2268B25500BDCFDD /* UISplitViewController-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UISplitViewController-Extensions.swift"; sourceTree = ""; }; 51322854232EED360033D4ED /* VibrantSelectAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VibrantSelectAction.swift; sourceTree = ""; }; 51322858232FDDB80033D4ED /* VibrantButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VibrantButtonStyle.swift; sourceTree = ""; }; + 5132285A232FF2C40033D4ED /* SettingsRefreshSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRefreshSelectionView.swift; sourceTree = ""; }; 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 = ""; }; 513C5CEB232571C2003D4054 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; @@ -1231,6 +1233,7 @@ isa = PBXGroup; children = ( 51F35D0822AFD4760003CE1B /* SettingsView.swift */, + 5132285A232FF2C40033D4ED /* SettingsRefreshSelectionView.swift */, 5194B5F122B69FCC00144881 /* SettingsSubscriptionsExportDocumentPickerView.swift */, 5194B5ED22B6965300144881 /* SettingsSubscriptionsImportDocumentPickerView.swift */, 515E4F06232506240057B0E7 /* Account */, @@ -2662,6 +2665,7 @@ 510BD15D232D765D002692E4 /* SettingsReaderAPIAccountView.swift in Sources */, 51C4525C226508DF00C03939 /* String-Extensions.swift in Sources */, 51C452792265091600C03939 /* MasterTimelineTableViewCell.swift in Sources */, + 5132285B232FF2C40033D4ED /* SettingsRefreshSelectionView.swift in Sources */, 51C452852265093600C03939 /* FlattenedAccountFolderPickerData.swift in Sources */, 51C4526B226508F600C03939 /* MasterFeedViewController.swift in Sources */, 5126EE97226CB48A00C22AFC /* SceneCoordinator.swift in Sources */, diff --git a/iOS/Settings/SettingsRefreshSelectionView.swift b/iOS/Settings/SettingsRefreshSelectionView.swift new file mode 100644 index 000000000..22fcce129 --- /dev/null +++ b/iOS/Settings/SettingsRefreshSelectionView.swift @@ -0,0 +1,35 @@ +// +// SettingsRefreshSelectionView.swift +// NetNewsWire-iOS +// +// Created by Maurice Parker on 9/16/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import SwiftUI + +struct SettingsRefreshSelectionView: View { + + @Environment(\.presentationMode) var presentation + @Binding var selectedInterval: RefreshInterval + + var body: some View { + Form { + ForEach(RefreshInterval.allCases) { interval in + Button(action: { + self.selectedInterval = interval + self.presentation.wrappedValue.dismiss() + }) { + HStack { + Text(interval.description()) + Spacer() + if interval == self.selectedInterval { + Image(systemName: "checkmark") + } + } + }.buttonStyle(VibrantButtonStyle(alignment: .leading)) + } + } + } + +} diff --git a/iOS/Settings/SettingsView.swift b/iOS/Settings/SettingsView.swift index fd397b2e9..8def382fa 100644 --- a/iOS/Settings/SettingsView.swift +++ b/iOS/Settings/SettingsView.swift @@ -18,7 +18,8 @@ struct SettingsView : View { @Environment(\.sceneCoordinator) private var coordinator: SceneCoordinator? @State private var accountAction: Int? = nil - + @State private var refreshAction: Int? = nil + @State private var isWebsitePresented: Bool = false @State private var website: String? = nil @@ -78,13 +79,18 @@ struct SettingsView : View { func buildDatabaseSection() -> some View { Section(header: Text("DATABASE")) { - Picker(selection: $viewModel.refreshInterval, label: Text("Refresh Interval")) { - ForEach(RefreshInterval.allCases) { interval in - Text(interval.description()).tag(interval) + NavigationLink(destination: SettingsRefreshSelectionView(selectedInterval: $viewModel.refreshInterval), tag: 1, selection: $refreshAction) { + HStack { + Text("Refresh Interval") + Spacer() + Text(verbatim: self.viewModel.refreshInterval.description()).foregroundColor(.secondary) } } + .modifier(VibrantSelectAction(action: { + self.refreshAction = 1 + })) - Button("Import Subscriptions...") { + Button("Import Subscriptions...") { if AccountManager.shared.activeAccounts.count == 1 { self.opmlAccount = AccountManager.shared.activeAccounts.first self.isOPMLImportDocPickerPresented = true