Implement Settings layout.

This commit is contained in:
Maurice Parker
2019-04-25 06:05:49 -05:00
parent 4135ba54fb
commit cabd2b8efc
6 changed files with 425 additions and 64 deletions

View File

@@ -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) {