diff --git a/JSONCreator_iOS/JSONCreator/Assets.xcassets/alternate.imageset/Contents.json b/JSONCreator_iOS/JSONCreator/Assets.xcassets/alternate.imageset/Contents.json new file mode 100644 index 0000000..cfef8eb --- /dev/null +++ b/JSONCreator_iOS/JSONCreator/Assets.xcassets/alternate.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "icons8-flip-vertical-50.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "icons8-flip-vertical-100.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/JSONCreator_iOS/JSONCreator/Assets.xcassets/alternate.imageset/icons8-flip-vertical-100.png b/JSONCreator_iOS/JSONCreator/Assets.xcassets/alternate.imageset/icons8-flip-vertical-100.png new file mode 100644 index 0000000..aefe956 Binary files /dev/null and b/JSONCreator_iOS/JSONCreator/Assets.xcassets/alternate.imageset/icons8-flip-vertical-100.png differ diff --git a/JSONCreator_iOS/JSONCreator/Assets.xcassets/alternate.imageset/icons8-flip-vertical-50.png b/JSONCreator_iOS/JSONCreator/Assets.xcassets/alternate.imageset/icons8-flip-vertical-50.png new file mode 100644 index 0000000..80305ac Binary files /dev/null and b/JSONCreator_iOS/JSONCreator/Assets.xcassets/alternate.imageset/icons8-flip-vertical-50.png differ diff --git a/JSONCreator_iOS/JSONCreator/DetailViewController.swift b/JSONCreator_iOS/JSONCreator/DetailViewController.swift index f75cba8..3355551 100644 --- a/JSONCreator_iOS/JSONCreator/DetailViewController.swift +++ b/JSONCreator_iOS/JSONCreator/DetailViewController.swift @@ -27,27 +27,31 @@ class DetailViewController: UIViewController { guard textView.superview == nil else { return } textView.textDropDelegate = self - - view.addSubview(textView) - if UIDevice.current.userInterfaceIdiom == .pad { - textView.font = UIFont.systemFont(ofSize: 20) - } else { - textView.font = UIFont.systemFont(ofSize: 14) - } - textView.translatesAutoresizingMaskIntoConstraints = false - textView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true - textView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true - view.trailingAnchor.constraint(equalTo: textView.trailingAnchor).isActive = true - view.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: textView.bottomAnchor).isActive = true textView.delegate = self textView.smartDashesType = .no textView.smartQuotesType = .no textView.smartInsertDeleteType = .no + view.addSubview(textView) + + if UIDevice.current.userInterfaceIdiom == .pad { + textView.font = UIFont.systemFont(ofSize: 20) + } else { + textView.font = UIFont.systemFont(ofSize: 14) + } + + textView.translatesAutoresizingMaskIntoConstraints = false + textView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true + textView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true + view.trailingAnchor.constraint(equalTo: textView.trailingAnchor).isActive = true + view.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: textView.bottomAnchor).isActive = true + let shareButton = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(shareButtonPressed)) let buildButton = UIBarButtonItem(barButtonSystemItem: .play, target: self, action: #selector(play)) let clearButton = UIBarButtonItem(barButtonSystemItem: .trash, target: self, action: #selector(clearTextView)) - navigationItem.setRightBarButtonItems([clearButton, shareButton, buildButton], animated: true) + let altButton = UIBarButtonItem(barButtonSystemItem: .bookmarks, target: self, action: #selector(clearTextView)) + + navigationItem.setRightBarButtonItems([altButton, clearButton, shareButton, buildButton], animated: true) } //-------------------------------------------------- @@ -61,6 +65,10 @@ class DetailViewController: UIViewController { present(alert, animated: true, completion: nil) } + //-------------------------------------------------- + // MARK: - Actions + //-------------------------------------------------- + @objc func shareButtonPressed() { if let text = textView.text { @@ -71,6 +79,7 @@ class DetailViewController: UIViewController { } @objc func clearTextView() { + textView.text = "" } diff --git a/JSONCreator_iOS/JSONCreator/MasterViewController.swift b/JSONCreator_iOS/JSONCreator/MasterViewController.swift index 57de0fe..9eff061 100644 --- a/JSONCreator_iOS/JSONCreator/MasterViewController.swift +++ b/JSONCreator_iOS/JSONCreator/MasterViewController.swift @@ -6,7 +6,6 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // -import UIKit import MVMCore @@ -69,10 +68,10 @@ class MasterViewController: UIViewController, UITableViewDelegate, UITableViewDa func getData(for indexPath: IndexPath) -> String? { - let subDictionary = molecularModels[indexPath.section].molecules[indexPath.row] as! [String: Any] - - let bb = subDictionary.keys.first! - let val = subDictionary[bb] + guard let subDictionary = molecularModels[indexPath.section].molecules[indexPath.row] as? [String: Any], + let bb = subDictionary.keys.first, + let val = subDictionary[bb] + else { return nil } var json: String = "" do {