From d2a34894a5008e85cca1cab5367fa04f19bcc39d Mon Sep 17 00:00:00 2001 From: Ashley Ng Date: Thu, 7 May 2020 18:29:23 -0500 Subject: [PATCH] Address code review - change varibale names with VC to ViewController - add MIT License Header to new files - add documentation about using a height constant --- Example/Sources/AppDelegate.swift | 12 +++---- .../LaunchViewController.swift | 36 +++++++++---------- ...essageSubviewContainerViewController.swift | 30 ++++++++++++---- .../MessageSubviewViewController.swift | 33 ++++++++++++----- 4 files changed, 72 insertions(+), 39 deletions(-) diff --git a/Example/Sources/AppDelegate.swift b/Example/Sources/AppDelegate.swift index f98806e1..5895d4ca 100644 --- a/Example/Sources/AppDelegate.swift +++ b/Example/Sources/AppDelegate.swift @@ -31,14 +31,14 @@ final internal class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - let masterVC = NavigationController(rootViewController: LaunchViewController()) - let detailVC = NavigationController() - let splitVC = UISplitViewController() - splitVC.viewControllers = [masterVC, detailVC] - splitVC.preferredDisplayMode = .allVisible + let masterViewController = NavigationController(rootViewController: LaunchViewController()) + let detailViewController = NavigationController() + let splitViewController = UISplitViewController() + splitViewController.viewControllers = [masterViewController, detailViewController] + splitViewController.preferredDisplayMode = .allVisible window = UIWindow(frame: UIScreen.main.bounds) - window?.rootViewController = splitVC + window?.rootViewController = splitViewController window?.makeKeyAndVisible() if UserDefaults.isFirstLaunch() { diff --git a/Example/Sources/View Controllers/LaunchViewController.swift b/Example/Sources/View Controllers/LaunchViewController.swift index a04706cf..fa0f46a0 100644 --- a/Example/Sources/View Controllers/LaunchViewController.swift +++ b/Example/Sources/View Controllers/LaunchViewController.swift @@ -74,29 +74,29 @@ final internal class LaunchViewController: UITableViewController { let cell = cells[indexPath.row] switch cell { case "Basic Example": - let vc = BasicExampleViewController() - let detailVC = NavigationController(rootViewController: vc) - splitViewController?.showDetailViewController(detailVC, sender: self) + let viewController = BasicExampleViewController() + let detailViewController = NavigationController(rootViewController: viewController) + splitViewController?.showDetailViewController(detailViewController, sender: self) case "Advanced Example": - let vc = AdvancedExampleViewController() - let detailVC = NavigationController(rootViewController: vc) - splitViewController?.showDetailViewController(detailVC, sender: self) + let viewController = AdvancedExampleViewController() + let detailViewController = NavigationController(rootViewController: viewController) + splitViewController?.showDetailViewController(detailViewController, sender: self) case "Autocomplete Example": - let vc = AutocompleteExampleViewController() - let detailVC = NavigationController(rootViewController: vc) - splitViewController?.showDetailViewController(detailVC, sender: self) + let viewController = AutocompleteExampleViewController() + let detailViewController = NavigationController(rootViewController: viewController) + splitViewController?.showDetailViewController(detailViewController, sender: self) case "Embedded Example": - let vc = MessageContainerController() - let detailVC = NavigationController(rootViewController: vc) - splitViewController?.showDetailViewController(detailVC, sender: self) + let viewController = MessageContainerController() + let detailViewController = NavigationController(rootViewController: viewController) + splitViewController?.showDetailViewController(detailViewController, sender: self) case "Settings": - let vc = SettingsViewController() - let detailVC = NavigationController(rootViewController: vc) - splitViewController?.showDetailViewController(detailVC, sender: self) + let viewController = SettingsViewController() + let detailViewController = NavigationController(rootViewController: viewController) + splitViewController?.showDetailViewController(detailViewController, sender: self) case "Subview Example": - let vc = MessageSubviewContainerViewController() - let detailVC = NavigationController(rootViewController: vc) - splitViewController?.showDetailViewController(detailVC, sender: self) + let viewController = MessageSubviewContainerViewController() + let detailViewController = NavigationController(rootViewController: viewController) + splitViewController?.showDetailViewController(detailViewController, sender: self) case "Source Code": guard let url = URL(string: "https://github.com/MessageKit/MessageKit") else { return } openURL(url) diff --git a/Example/Sources/View Controllers/MessageSubviewContainerViewController.swift b/Example/Sources/View Controllers/MessageSubviewContainerViewController.swift index c1c2bb1d..4ddbb373 100644 --- a/Example/Sources/View Controllers/MessageSubviewContainerViewController.swift +++ b/Example/Sources/View Controllers/MessageSubviewContainerViewController.swift @@ -1,10 +1,26 @@ -// -// MessageSubviewContainerViewController.swift -// ChatExample -// -// Created by Ng, Ashley on 3/10/20. -// Copyright © 2020 MessageKit. All rights reserved. -// +/* +MIT License + +Copyright (c) 2017-2019 MessageKit + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import Foundation import UIKit diff --git a/Example/Sources/View Controllers/MessageSubviewViewController.swift b/Example/Sources/View Controllers/MessageSubviewViewController.swift index ae220dd1..47a75e0e 100644 --- a/Example/Sources/View Controllers/MessageSubviewViewController.swift +++ b/Example/Sources/View Controllers/MessageSubviewViewController.swift @@ -1,15 +1,31 @@ -// -// MessageSubviewViewController.swift -// ChatExample -// -// Created by Ng, Ashley on 3/10/20. -// Copyright © 2020 MessageKit. All rights reserved. -// +/* +MIT License + +Copyright (c) 2017-2019 MessageKit + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ import Foundation import InputBarAccessoryView -class MessageSubviewViewController: BasicExampleViewController { +final class MessageSubviewViewController: BasicExampleViewController { private var keyboardManager = KeyboardManager() @@ -18,6 +34,7 @@ class MessageSubviewViewController: BasicExampleViewController { override func viewDidLoad() { super.viewDidLoad() subviewInputBar.delegate = self + // Take into account the height of the bottom input bar additionalBottomInset = 88 }