From cabd2b8efcb8690c35b5ae3af9465bbeca186bf5 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 25 Apr 2019 06:05:49 -0500 Subject: [PATCH] Implement Settings layout. --- NetNewsWire.xcodeproj/project.pbxproj | 16 + iOS/Base.lproj/Main.storyboard | 34 +- iOS/Extensions/UIStoryboard-Extensions.swift | 4 + iOS/MasterFeed/MasterFeedViewController.swift | 102 +++--- iOS/Settings/Settings.storyboard | 299 ++++++++++++++++++ iOS/Settings/SettingsViewController.swift | 34 ++ 6 files changed, 425 insertions(+), 64 deletions(-) create mode 100644 iOS/Settings/Settings.storyboard create mode 100644 iOS/Settings/SettingsViewController.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index bf5af2102..b6ef62f7c 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -26,6 +26,8 @@ 5183CCE6226F4E110010922C /* RefreshInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCE4226F4DFA0010922C /* RefreshInterval.swift */; }; 5183CCE8226F68D90010922C /* RefreshTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCE7226F68D90010922C /* RefreshTimer.swift */; }; 5183CCE9226F68D90010922C /* RefreshTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCE7226F68D90010922C /* RefreshTimer.swift */; }; + 5183CCED22711DCE0010922C /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5183CCEC22711DCE0010922C /* Settings.storyboard */; }; + 5183CCEF227125970010922C /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCEE227125970010922C /* SettingsViewController.swift */; }; 519B8D332143397200FA689C /* SharingServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519B8D322143397200FA689C /* SharingServiceDelegate.swift */; }; 51C451A9226377C200C03939 /* ArticlesDatabase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8407167F2262A61100344432 /* ArticlesDatabase.framework */; }; 51C451AA226377C200C03939 /* ArticlesDatabase.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8407167F2262A61100344432 /* ArticlesDatabase.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -623,6 +625,8 @@ 5183CCE2226F314C0010922C /* ProgressTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressTableViewController.swift; sourceTree = ""; }; 5183CCE4226F4DFA0010922C /* RefreshInterval.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshInterval.swift; sourceTree = ""; }; 5183CCE7226F68D90010922C /* RefreshTimer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshTimer.swift; sourceTree = ""; }; + 5183CCEC22711DCE0010922C /* Settings.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = ""; }; + 5183CCEE227125970010922C /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = ""; }; 519B8D322143397200FA689C /* SharingServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingServiceDelegate.swift; sourceTree = ""; }; 51C4524E226506F400C03939 /* UIStoryboard-Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIStoryboard-Extensions.swift"; sourceTree = ""; }; 51C4524F226506F400C03939 /* UIImage-Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage-Extensions.swift"; sourceTree = ""; }; @@ -934,6 +938,15 @@ path = Refresh; sourceTree = ""; }; + 5183CCEB227117C70010922C /* Settings */ = { + isa = PBXGroup; + children = ( + 5183CCEC22711DCE0010922C /* Settings.storyboard */, + 5183CCEE227125970010922C /* SettingsViewController.swift */, + ); + path = Settings; + sourceTree = ""; + }; 51C45245226506C800C03939 /* Extensions */ = { isa = PBXGroup; children = ( @@ -1554,6 +1567,7 @@ 51C4526D2265091600C03939 /* MasterTimeline */, 51C4527D2265092C00C03939 /* Detail */, 51C452802265093600C03939 /* Add */, + 5183CCEB227117C70010922C /* Settings */, 5183CCDB226F1EEB0010922C /* Progress */, 51C45245226506C800C03939 /* Extensions */, 84C9FC9A2262A1A900D921D6 /* Resources */, @@ -2071,6 +2085,7 @@ 51C452862265093600C03939 /* Add.storyboard in Resources */, 84C9FCA12262A1B300D921D6 /* Main.storyboard in Resources */, 84C9FCA42262A1B800D921D6 /* LaunchScreen.storyboard in Resources */, + 5183CCED22711DCE0010922C /* Settings.storyboard in Resources */, 51C452AB22650DC600C03939 /* template.html in Resources */, 84A3EE61223B667F00557320 /* DefaultFeeds.opml in Resources */, 84C9FC9D2262A1A900D921D6 /* Assets.xcassets in Resources */, @@ -2194,6 +2209,7 @@ 51C4526B226508F600C03939 /* MasterFeedViewController.swift in Sources */, 5126EE97226CB48A00C22AFC /* NavigationStateController.swift in Sources */, 51C4525A226508D600C03939 /* UIStoryboard-Extensions.swift in Sources */, + 5183CCEF227125970010922C /* SettingsViewController.swift in Sources */, 51C452A622650A3500C03939 /* Node-Extensions.swift in Sources */, 5183CCDF226F1FCC0010922C /* UINavigationController+Progress.swift in Sources */, 51C45294226509C800C03939 /* SearchFeedDelegate.swift in Sources */, diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard index 857809758..80af1fabf 100644 --- a/iOS/Base.lproj/Main.storyboard +++ b/iOS/Base.lproj/Main.storyboard @@ -1,6 +1,10 @@ + + + + @@ -11,11 +15,11 @@ - + - + @@ -31,11 +35,11 @@ - + - + @@ -117,15 +121,15 @@ - + - + - + @@ -167,11 +171,11 @@ - + - + @@ -201,15 +205,15 @@ - + - + - + @@ -236,7 +240,7 @@ - + @@ -254,11 +258,11 @@ - + - + diff --git a/iOS/Extensions/UIStoryboard-Extensions.swift b/iOS/Extensions/UIStoryboard-Extensions.swift index 540b96e22..f0b67d6ff 100644 --- a/iOS/Extensions/UIStoryboard-Extensions.swift +++ b/iOS/Extensions/UIStoryboard-Extensions.swift @@ -18,6 +18,10 @@ extension UIStoryboard { return UIStoryboard(name: "Add", bundle: nil) } + static var settings: UIStoryboard { + return UIStoryboard(name: "Settings", bundle: nil) + } + func instantiateController(ofType type: T.Type = T.self) -> T where T: UIViewController { let storyboardId = String(describing: type) diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index c1e4952b1..c29ac5c88 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -351,53 +351,57 @@ class MasterFeedViewController: ProgressTableViewController, UndoableCommandRunn // MARK: Actions - @IBAction func showTools(_ sender: UIBarButtonItem) { + @IBAction func settings(_ sender: UIBarButtonItem) { - let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) + let settingsViewController = UIStoryboard.settings.instantiateInitialViewController()! + settingsViewController.modalPresentationStyle = .formSheet + self.present(settingsViewController, animated: true) - // Settings Button - let settingsTitle = NSLocalizedString("Settings", comment: "Settings") - let setting = UIAlertAction(title: settingsTitle, style: .default) { alertAction in - - } - optionMenu.addAction(setting) - - // Import Button - let importOPMLTitle = NSLocalizedString("Import OPML", comment: "Import OPML") - let importOPML = UIAlertAction(title: importOPMLTitle, style: .default) { [unowned self] alertAction in - let docPicker = UIDocumentPickerViewController(documentTypes: ["public.xml", "org.opml.opml"], in: .import) - docPicker.delegate = self - docPicker.modalPresentationStyle = .formSheet - self.present(docPicker, animated: true) - } - optionMenu.addAction(importOPML) - - // Export Button - let exportOPMLTitle = NSLocalizedString("Export OPML", comment: "Export OPML") - let exportOPML = UIAlertAction(title: exportOPMLTitle, style: .default) { [unowned self] alertAction in - - let filename = "MySubscriptions.opml" - let tempFile = FileManager.default.temporaryDirectory.appendingPathComponent(filename) - let opmlString = OPMLExporter.OPMLString(with: AccountManager.shared.localAccount, title: filename) - do { - try opmlString.write(to: tempFile, atomically: true, encoding: String.Encoding.utf8) - } catch { - self.presentError(title: "OPML Export Error", message: error.localizedDescription) - } - - let docPicker = UIDocumentPickerViewController(url: tempFile, in: .exportToService) - docPicker.modalPresentationStyle = .formSheet - self.present(docPicker, animated: true) - - } - optionMenu.addAction(exportOPML) - optionMenu.addAction(UIAlertAction(title: "Cancel", style: .cancel)) - - if let popoverController = optionMenu.popoverPresentationController { - popoverController.barButtonItem = sender - } - - self.present(optionMenu, animated: true) +// let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) +// +// // Settings Button +// let settingsTitle = NSLocalizedString("Settings", comment: "Settings") +// let setting = UIAlertAction(title: settingsTitle, style: .default) { alertAction in +// +// } +// optionMenu.addAction(setting) +// +// // Import Button +// let importOPMLTitle = NSLocalizedString("Import OPML", comment: "Import OPML") +// let importOPML = UIAlertAction(title: importOPMLTitle, style: .default) { [unowned self] alertAction in +// let docPicker = UIDocumentPickerViewController(documentTypes: ["public.xml", "org.opml.opml"], in: .import) +// docPicker.delegate = self +// docPicker.modalPresentationStyle = .formSheet +// self.present(docPicker, animated: true) +// } +// optionMenu.addAction(importOPML) +// +// // Export Button +// let exportOPMLTitle = NSLocalizedString("Export OPML", comment: "Export OPML") +// let exportOPML = UIAlertAction(title: exportOPMLTitle, style: .default) { [unowned self] alertAction in +// +// let filename = "MySubscriptions.opml" +// let tempFile = FileManager.default.temporaryDirectory.appendingPathComponent(filename) +// let opmlString = OPMLExporter.OPMLString(with: AccountManager.shared.localAccount, title: filename) +// do { +// try opmlString.write(to: tempFile, atomically: true, encoding: String.Encoding.utf8) +// } catch { +// self.presentError(title: "OPML Export Error", message: error.localizedDescription) +// } +// +// let docPicker = UIDocumentPickerViewController(url: tempFile, in: .exportToService) +// docPicker.modalPresentationStyle = .formSheet +// self.present(docPicker, animated: true) +// +// } +// optionMenu.addAction(exportOPML) +// optionMenu.addAction(UIAlertAction(title: "Cancel", style: .cancel)) +// +// if let popoverController = optionMenu.popoverPresentationController { +// popoverController.barButtonItem = sender +// } +// +// self.present(optionMenu, animated: true) } @@ -436,10 +440,10 @@ class MasterFeedViewController: ProgressTableViewController, UndoableCommandRunn } @IBAction func add(_ sender: UIBarButtonItem) { - let feedViewController = UIStoryboard.add.instantiateInitialViewController()! - feedViewController.modalPresentationStyle = .popover - feedViewController.popoverPresentationController?.barButtonItem = sender - self.present(feedViewController, animated: true) + let addViewController = UIStoryboard.add.instantiateInitialViewController()! + addViewController.modalPresentationStyle = .popover + addViewController.popoverPresentationController?.barButtonItem = sender + self.present(addViewController, animated: true) } @objc func toggleSectionHeader(_ sender: UITapGestureRecognizer) { diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard new file mode 100644 index 000000000..4d3c41be6 --- /dev/null +++ b/iOS/Settings/Settings.storyboard @@ -0,0 +1,299 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/Settings/SettingsViewController.swift b/iOS/Settings/SettingsViewController.swift new file mode 100644 index 000000000..5ee05b785 --- /dev/null +++ b/iOS/Settings/SettingsViewController.swift @@ -0,0 +1,34 @@ +// +// SettingsViewController.swift +// NetNewsWire-iOS +// +// Created by Maurice Parker on 4/24/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import UIKit + +class SettingsViewController: UITableViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + + @IBAction func done(_ sender: Any) { + dismiss(animated: true) + } + +}