diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index aa8e3af5d..60d95cad5 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 512E09012268907400BDCFDD /* MasterFeedTableViewSectionHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 512E08F722688F7C00BDCFDD /* MasterFeedTableViewSectionHeader.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 */; }; + 51322855232EED360033D4ED /* VibrantSelectAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51322854232EED360033D4ED /* VibrantSelectAction.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, ); }; }; @@ -762,6 +763,7 @@ 5127B237222B4849006D641D /* DetailKeyboardShortcuts.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = DetailKeyboardShortcuts.plist; sourceTree = ""; }; 512E08F722688F7C00BDCFDD /* MasterFeedTableViewSectionHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterFeedTableViewSectionHeader.swift; sourceTree = ""; }; 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 = ""; }; 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 = ""; }; @@ -1245,12 +1247,13 @@ path = Activity; sourceTree = ""; }; - 5194B5E222B693EC00144881 /* Wrappers */ = { + 5194B5E222B693EC00144881 /* SwiftUI Extensions */ = { isa = PBXGroup; children = ( DF999FF622B5AEFA0064B687 /* SafariView.swift */, + 51322854232EED360033D4ED /* VibrantSelectAction.swift */, ); - path = Wrappers; + path = "SwiftUI Extensions"; sourceTree = ""; }; 519D740423243C68008BB345 /* Model Extensions */ = { @@ -1922,10 +1925,10 @@ 51C452802265093600C03939 /* Add */, 5183CCEB227117C70010922C /* Settings */, 5183CCDB226F1EEB0010922C /* Progress */, - 519D740423243C68008BB345 /* Model Extensions */, - 51C45245226506C800C03939 /* UIKit Extensions */, 5F3237FF231DF9D000706F6B /* Views */, - 5194B5E222B693EC00144881 /* Wrappers */, + 519D740423243C68008BB345 /* Model Extensions */, + 5194B5E222B693EC00144881 /* SwiftUI Extensions */, + 51C45245226506C800C03939 /* UIKit Extensions */, 513C5CE7232571C2003D4054 /* ShareExtension */, 84C9FC9A2262A1A900D921D6 /* Resources */, ); @@ -2712,6 +2715,7 @@ 84DEE56622C32CA4005FC42C /* SmartFeedDelegate.swift in Sources */, 512E09012268907400BDCFDD /* MasterFeedTableViewSectionHeader.swift in Sources */, 519D740623243CC0008BB345 /* RefreshInterval-Extensions.swift in Sources */, + 51322855232EED360033D4ED /* VibrantSelectAction.swift in Sources */, 51C45268226508F600C03939 /* MasterFeedUnreadCountView.swift in Sources */, 5183CCD0226E1E880010922C /* NonIntrinsicLabel.swift in Sources */, 51C4529F22650A1900C03939 /* AuthorAvatarDownloader.swift in Sources */, diff --git a/iOS/Settings/SettingsView.swift b/iOS/Settings/SettingsView.swift index 041310167..219a231eb 100644 --- a/iOS/Settings/SettingsView.swift +++ b/iOS/Settings/SettingsView.swift @@ -68,41 +68,40 @@ 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) } } - VStack { - Button("Import Subscriptions...") { - if AccountManager.shared.activeAccounts.count == 1 { - self.opmlAccount = AccountManager.shared.activeAccounts.first - self.isOPMLImportDocPickerPresented = true - } else { - self.isOPMLImportPresented = true - } - } - }.actionSheet(isPresented: $isOPMLImportPresented) { + Text("Import Subscriptions...") + .actionSheet(isPresented: $isOPMLImportPresented) { buildSubscriptionsImportAccounts() }.sheet(isPresented: $isOPMLImportDocPickerPresented) { SettingsSubscriptionsImportDocumentPickerView(account: self.opmlAccount!) - }.foregroundColor(.primary) - - VStack { - Button("Export Subscriptions...") { - if AccountManager.shared.accounts.count == 1 { - self.opmlAccount = AccountManager.shared.accounts.first - self.isOPMLImportDocPickerPresented = true - } else { - self.isOPMLExportPresented = true - } - } - }.actionSheet(isPresented: $isOPMLExportPresented) { - buildSubscriptionsExportAccounts() - }.sheet(isPresented: $isOPMLExportDocPickerPresented) { - SettingsSubscriptionsExportDocumentPickerView(account: self.opmlAccount!) - }.foregroundColor(.primary) + }.modifier(VibrantSelectAction(action: { + if AccountManager.shared.activeAccounts.count == 1 { + self.opmlAccount = AccountManager.shared.activeAccounts.first + self.isOPMLImportDocPickerPresented = true + } else { + self.isOPMLImportPresented = true + } + })) + + Text("Export Subscriptions...") + .actionSheet(isPresented: $isOPMLExportPresented) { + buildSubscriptionsExportAccounts() + }.sheet(isPresented: $isOPMLExportDocPickerPresented) { + SettingsSubscriptionsExportDocumentPickerView(account: self.opmlAccount!) + }.modifier(VibrantSelectAction(action: { + if AccountManager.shared.accounts.count == 1 { + self.opmlAccount = AccountManager.shared.accounts.first + self.isOPMLImportDocPickerPresented = true + } else { + self.isOPMLExportPresented = true + } + })) } } diff --git a/iOS/Wrappers/SafariView.swift b/iOS/SwiftUI Extensions/SafariView.swift similarity index 100% rename from iOS/Wrappers/SafariView.swift rename to iOS/SwiftUI Extensions/SafariView.swift diff --git a/iOS/SwiftUI Extensions/VibrantSelectAction.swift b/iOS/SwiftUI Extensions/VibrantSelectAction.swift new file mode 100644 index 000000000..0660b5450 --- /dev/null +++ b/iOS/SwiftUI Extensions/VibrantSelectAction.swift @@ -0,0 +1,36 @@ +// +// VibrantSelectAction.swift +// NetNewsWire-iOS +// +// Created by Maurice Parker on 9/15/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import SwiftUI + +struct VibrantSelectAction: ViewModifier { + + let action: () -> Void + @State var isTapped = false + @GestureState var isLongPressed = false + + func body(content: Content) -> some View { + content + .foregroundColor(isLongPressed || isTapped ? Color(AppAssets.tableViewCellHighlightedTextColor) : .primary) + .listRowBackground(isLongPressed || isTapped ? Color(AppAssets.tableViewCellSelectionColor) : nil) + .gesture( + LongPressGesture().onEnded( { _ in self.action() }) + .updating($isLongPressed) { value, state, transcation in state = value } + .simultaneously(with: + TapGesture().onEnded( { + self.isTapped = true + self.action() + DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { + self.isTapped = false + } + }) + ) + ) + } + +}