diff --git a/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj b/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj index 2271ef1..d96f4e0 100644 --- a/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj +++ b/JSONCreator_iOS/JSONCreator.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 0AE3D04E2303009C00B844C7 /* QueryServerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE3D04D2303009C00B844C7 /* QueryServerCell.swift */; }; D2B1E3F322F4A68F0065F95C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3F222F4A68F0065F95C /* AppDelegate.swift */; }; D2B1E3F522F4A68F0065F95C /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3F422F4A68F0065F95C /* MasterViewController.swift */; }; D2B1E3F722F4A68F0065F95C /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B1E3F622F4A68F0065F95C /* DetailViewController.swift */; }; @@ -53,6 +54,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 0AE3D04D2303009C00B844C7 /* QueryServerCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueryServerCell.swift; sourceTree = ""; }; D2B1E3EF22F4A68F0065F95C /* JSONCreator.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JSONCreator.app; sourceTree = BUILT_PRODUCTS_DIR; }; D2B1E3F222F4A68F0065F95C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; D2B1E3F422F4A68F0065F95C /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = ""; }; @@ -109,6 +111,7 @@ D2B1E3FB22F4A6930065F95C /* Assets.xcassets */, D2B1E3FD22F4A6930065F95C /* LaunchScreen.storyboard */, D2B1E40022F4A6930065F95C /* Info.plist */, + 0AE3D04D2303009C00B844C7 /* QueryServerCell.swift */, ); path = JSONCreator; sourceTree = ""; @@ -223,6 +226,7 @@ buildActionMask = 2147483647; files = ( D2B1E3F722F4A68F0065F95C /* DetailViewController.swift in Sources */, + 0AE3D04E2303009C00B844C7 /* QueryServerCell.swift in Sources */, D2B1E3F522F4A68F0065F95C /* MasterViewController.swift in Sources */, D2B1E3F322F4A68F0065F95C /* AppDelegate.swift in Sources */, ); @@ -301,7 +305,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.4; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -356,7 +360,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.4; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; diff --git a/JSONCreator_iOS/JSONCreator/AppDelegate.swift b/JSONCreator_iOS/JSONCreator/AppDelegate.swift index ee7469b..8c3217b 100644 --- a/JSONCreator_iOS/JSONCreator/AppDelegate.swift +++ b/JSONCreator_iOS/JSONCreator/AppDelegate.swift @@ -72,4 +72,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele } } - diff --git a/JSONCreator_iOS/JSONCreator/DetailViewController.swift b/JSONCreator_iOS/JSONCreator/DetailViewController.swift index da7b9a3..81222f8 100644 --- a/JSONCreator_iOS/JSONCreator/DetailViewController.swift +++ b/JSONCreator_iOS/JSONCreator/DetailViewController.swift @@ -9,6 +9,7 @@ import UIKit import MVMCoreUI + class DetailViewController: UIViewController { let textView = UITextView(frame: .zero) diff --git a/JSONCreator_iOS/JSONCreator/MasterViewController.swift b/JSONCreator_iOS/JSONCreator/MasterViewController.swift index b3350e7..7de0206 100644 --- a/JSONCreator_iOS/JSONCreator/MasterViewController.swift +++ b/JSONCreator_iOS/JSONCreator/MasterViewController.swift @@ -7,47 +7,86 @@ // import UIKit +import MVMCore + class MasterViewController: UITableViewController { - + let folderPath = Bundle.main.resourcePath! + "/JSON" - + override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. + + tableView.estimatedRowHeight = 80 + tableView.rowHeight = UITableView.automaticDimension } - + // MARK: - Table View override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { - return try! FileManager.default.contentsOfDirectory(atPath: folderPath)[section] + return try? FileManager.default.contentsOfDirectory(atPath: folderPath)[section] } - + override func numberOfSections(in tableView: UITableView) -> Int { return try! FileManager.default.contentsOfDirectory(atPath: folderPath).count } - + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + + if section == 0 { + return try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[section]).count + 1 + } + return try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[section]).count } - + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) - - let name = try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[indexPath.section])[indexPath.row] - cell.textLabel?.text = name - if cell.interactions.first == nil { - let dragInteraction = UIDragInteraction(delegate: self) - cell.addInteraction(dragInteraction) + + if indexPath.section == 0 { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? QueryServerCell else { return UITableViewCell() } + cell.requestServer = requestJSON + return cell + + } else { + let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) + + let name = try! FileManager.default.contentsOfDirectory(atPath: folderPath + "/" + FileManager.default.contentsOfDirectory(atPath: folderPath)[indexPath.section])[indexPath.row] + cell.textLabel?.text = name + + if cell.interactions.first == nil { + let dragInteraction = UIDragInteraction(delegate: self) + cell.addInteraction(dragInteraction) + } + return cell } - return cell } - + override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { // Return false if you do not want the specified item to be editable. return true } + + @objc func requestJSON() { + + let requestParameters = MVMCoreRequestParameters(actionMap: [:]) + let errorLocation = (MVMCoreLoadHandler.sharedGlobal()?.errorLocation(forRequest: MVMCoreSessionTimeHandler.sharedSession(), + pageType: "test", + modules: ""))! + + MVMCoreDispatchUtility.performBlock(inBackground: { + + MVMCoreLoadHandler.sharedGlobal()?.sendRequest(requestParameters!, locationForError: errorLocation, requestFinished: { json, error in + + if error != nil { + // BAD + } else { + // GOOD + } + }) + }) + } } extension MasterViewController: UIDragInteractionDelegate { diff --git a/JSONCreator_iOS/JSONCreator/QueryServerCell.swift b/JSONCreator_iOS/JSONCreator/QueryServerCell.swift new file mode 100644 index 0000000..544349c --- /dev/null +++ b/JSONCreator_iOS/JSONCreator/QueryServerCell.swift @@ -0,0 +1,35 @@ +// +// QueryServerCell.swift +// JSONCreator +// +// Created by Kevin Christiano on 8/13/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import UIKit + + +class QueryServerCell: UITableViewCell { + + var requestServer: (()->())? + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + + let button = UIButton(frame: .zero) + button.setTitle("RequestView", for: .normal) + button.backgroundColor = .yellow + button.addTarget(self, action: #selector(requestJSON), for: .touchUpInside) + contentView.addSubview(button) + NSLayoutConstraint.pinView(toSuperview: button, useMargins: true) + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + @objc func requestJSON() { + + requestServer?() + } +}