mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
refactor: InpuBar as subview instead of accessoryView
Simplify example launch VC # Conflicts: # Example/Sources/View Controllers/LaunchViewController.swift # Example/Sources/View Controllers/NavigationController.swift
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
385C2942211FF38F0010B4BA /* AdvancedExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 385C293B211FF38E0010B4BA /* AdvancedExampleViewController.swift */; };
|
||||
385C2943211FF38F0010B4BA /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 385C293C211FF38E0010B4BA /* SettingsViewController.swift */; };
|
||||
385C2944211FF38F0010B4BA /* MessageContainerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 385C293D211FF38F0010B4BA /* MessageContainerController.swift */; };
|
||||
385C2945211FF38F0010B4BA /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 385C293E211FF38F0010B4BA /* NavigationController.swift */; };
|
||||
385C2946211FF38F0010B4BA /* LaunchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 385C293F211FF38F0010B4BA /* LaunchViewController.swift */; };
|
||||
385C2947211FF38F0010B4BA /* BasicExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 385C2940211FF38F0010B4BA /* BasicExampleViewController.swift */; };
|
||||
385C2948211FF38F0010B4BA /* ChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 385C2941211FF38F0010B4BA /* ChatViewController.swift */; };
|
||||
@@ -90,7 +89,6 @@
|
||||
385C293B211FF38E0010B4BA /* AdvancedExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdvancedExampleViewController.swift; sourceTree = "<group>"; };
|
||||
385C293C211FF38E0010B4BA /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
|
||||
385C293D211FF38F0010B4BA /* MessageContainerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageContainerController.swift; sourceTree = "<group>"; };
|
||||
385C293E211FF38F0010B4BA /* NavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = "<group>"; };
|
||||
385C293F211FF38F0010B4BA /* LaunchViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LaunchViewController.swift; sourceTree = "<group>"; };
|
||||
385C2940211FF38F0010B4BA /* BasicExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicExampleViewController.swift; sourceTree = "<group>"; };
|
||||
385C2941211FF38F0010B4BA /* ChatViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatViewController.swift; sourceTree = "<group>"; };
|
||||
@@ -226,7 +224,6 @@
|
||||
385C2941211FF38F0010B4BA /* ChatViewController.swift */,
|
||||
385C293F211FF38F0010B4BA /* LaunchViewController.swift */,
|
||||
385C293D211FF38F0010B4BA /* MessageContainerController.swift */,
|
||||
385C293E211FF38F0010B4BA /* NavigationController.swift */,
|
||||
385C293C211FF38E0010B4BA /* SettingsViewController.swift */,
|
||||
63ECDABD24182A470016C349 /* MessageSubviewViewController.swift */,
|
||||
63ECDAC1241889630016C349 /* MessageSubviewContainerViewController.swift */,
|
||||
@@ -504,7 +501,6 @@
|
||||
385C2931211FF3630010B4BA /* UIColor+Extensions.swift in Sources */,
|
||||
385C2932211FF3630010B4BA /* UIViewController+Extensions.swift in Sources */,
|
||||
385C292B211FF3450010B4BA /* Settings+UserDefaults.swift in Sources */,
|
||||
385C2945211FF38F0010B4BA /* NavigationController.swift in Sources */,
|
||||
9B49D547263DAA29008804B5 /* CustomTextMessageContentCell.swift in Sources */,
|
||||
9B49D528263C31FC008804B5 /* CustomLayoutExampleViewController.swift in Sources */,
|
||||
032A15DD25965D9A00E00FE3 /* AlertService.swift in Sources */,
|
||||
@@ -623,7 +619,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
@@ -676,7 +672,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_VERSION = 5.0;
|
||||
|
||||
@@ -31,8 +31,8 @@ final internal class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
|
||||
let masterViewController = NavigationController(rootViewController: LaunchViewController())
|
||||
let detailViewController = NavigationController()
|
||||
let masterViewController = UINavigationController(rootViewController: LaunchViewController())
|
||||
let detailViewController = UINavigationController()
|
||||
let splitViewController = UISplitViewController()
|
||||
splitViewController.viewControllers = [masterViewController, detailViewController]
|
||||
splitViewController.preferredDisplayMode = .allVisible
|
||||
|
||||
@@ -28,33 +28,27 @@ import SafariServices
|
||||
import SwiftUI
|
||||
|
||||
final internal class LaunchViewController: UITableViewController {
|
||||
|
||||
override var preferredStatusBarStyle: UIStatusBarStyle {
|
||||
return .lightContent
|
||||
}
|
||||
|
||||
let cells = ["Basic Example", "Advanced Example", "Autocomplete Example", "Embedded Example", "Custom Layout Example", "Subview Example", "SwiftUI Example", "Settings", "Source Code", "Contributors"]
|
||||
private let cells = ["Basic Example", "Advanced Example", "Autocomplete Example", "Embedded Example", "Custom Layout Example", "Subview Example", "SwiftUI Example", "Settings", "Source Code", "Contributors"]
|
||||
|
||||
// MARK: - View Life Cycle
|
||||
|
||||
|
||||
init() {
|
||||
super.init(style: .insetGrouped)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) { nil }
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
title = "MessageKit"
|
||||
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
|
||||
navigationController?.navigationBar.prefersLargeTitles = false
|
||||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
|
||||
tableView.tableFooterView = UIView()
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
navigationController?.navigationBar.prefersLargeTitles = true
|
||||
}
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
navigationController?.navigationBar.prefersLargeTitles = false
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
@@ -76,15 +70,15 @@ final internal class LaunchViewController: UITableViewController {
|
||||
switch cell {
|
||||
case "Basic Example":
|
||||
let viewController = BasicExampleViewController()
|
||||
let detailViewController = NavigationController(rootViewController: viewController)
|
||||
let detailViewController = UINavigationController(rootViewController: viewController)
|
||||
splitViewController?.showDetailViewController(detailViewController, sender: self)
|
||||
case "Advanced Example":
|
||||
let viewController = AdvancedExampleViewController()
|
||||
let detailViewController = NavigationController(rootViewController: viewController)
|
||||
let detailViewController = UINavigationController(rootViewController: viewController)
|
||||
splitViewController?.showDetailViewController(detailViewController, sender: self)
|
||||
case "Autocomplete Example":
|
||||
let viewController = AutocompleteExampleViewController()
|
||||
let detailViewController = NavigationController(rootViewController: viewController)
|
||||
let detailViewController = UINavigationController(rootViewController: viewController)
|
||||
splitViewController?.showDetailViewController(detailViewController, sender: self)
|
||||
case "Embedded Example":
|
||||
navigationController?.pushViewController(MessageContainerController(), animated: true)
|
||||
@@ -96,11 +90,11 @@ final internal class LaunchViewController: UITableViewController {
|
||||
}
|
||||
case "Settings":
|
||||
let viewController = SettingsViewController()
|
||||
let detailViewController = NavigationController(rootViewController: viewController)
|
||||
let detailViewController = UINavigationController(rootViewController: viewController)
|
||||
splitViewController?.showDetailViewController(detailViewController, sender: self)
|
||||
case "Subview Example":
|
||||
let viewController = MessageSubviewContainerViewController()
|
||||
let detailViewController = NavigationController(rootViewController: viewController)
|
||||
let detailViewController = UINavigationController(rootViewController: viewController)
|
||||
splitViewController?.showDetailViewController(detailViewController, sender: self)
|
||||
case "Source Code":
|
||||
guard let url = URL(string: "https://github.com/MessageKit/MessageKit") else { return }
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
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 UIKit
|
||||
|
||||
final class NavigationController: UINavigationController {
|
||||
|
||||
override var preferredStatusBarStyle: UIStatusBarStyle {
|
||||
return viewControllers.last?.preferredStatusBarStyle ?? .lightContent
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
navigationBar.isTranslucent = false
|
||||
navigationBar.tintColor = .white
|
||||
navigationBar.barTintColor = .primaryColor
|
||||
navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white]
|
||||
navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
|
||||
navigationBar.shadowImage = UIImage()
|
||||
navigationBar.setBackgroundImage(UIImage(), for: .default)
|
||||
view.backgroundColor = .primaryColor
|
||||
}
|
||||
|
||||
func setAppearanceStyle(to style: UIStatusBarStyle) {
|
||||
if style == .default {
|
||||
navigationBar.shadowImage = UIImage()
|
||||
navigationBar.barTintColor = .primaryColor
|
||||
navigationBar.tintColor = .white
|
||||
navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white]
|
||||
navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
|
||||
} else if style == .lightContent {
|
||||
navigationBar.shadowImage = nil
|
||||
navigationBar.barTintColor = .white
|
||||
navigationBar.tintColor = UIColor(red: 0, green: 0.5, blue: 1, alpha: 1)
|
||||
navigationBar.titleTextAttributes = [.foregroundColor: UIColor.black]
|
||||
navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.black]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user