mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
943ed2d899
1. Set .swiftlint.yml for ChatExample 2. Fix Access Control for Explicit Top Level ACL Violation 3. Fix SwiftLint Warning: Colon Violation, Function Body Length 4. Fix Forced Unwrapping style
96 lines
4.1 KiB
Swift
96 lines
4.1 KiB
Swift
/*
|
|
MIT License
|
|
|
|
Copyright (c) 2017-2018 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
|
|
import MessageKit
|
|
import SafariServices
|
|
|
|
final internal class InboxViewController: UITableViewController {
|
|
|
|
let cells = ["Example", "Settings", "Source Code", "Contributors"]
|
|
|
|
// MARK: - View Life Cycle
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
title = "MessageKit"
|
|
navigationController?.navigationBar.tintColor = .white
|
|
navigationController?.navigationBar.barTintColor = UIColor(red: 69/255, green: 193/255, blue: 89/255, alpha: 1)
|
|
navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white, NSAttributedStringKey.font: UIFont.systemFont(ofSize: 20, weight: UIFont.Weight.bold) ]
|
|
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
|
|
tableView.tableFooterView = UIView()
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
if #available(iOS 11.0, *) {
|
|
navigationController?.navigationBar.prefersLargeTitles = true
|
|
navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
|
|
}
|
|
}
|
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
super.viewWillDisappear(animated)
|
|
if #available(iOS 11.0, *) {
|
|
navigationController?.navigationBar.prefersLargeTitles = false
|
|
}
|
|
}
|
|
|
|
// MARK: - UITableViewDataSource
|
|
|
|
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
return cells.count
|
|
}
|
|
|
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: "cell") ?? UITableViewCell()
|
|
cell.textLabel?.text = cells[indexPath.row]
|
|
cell.accessoryType = .disclosureIndicator
|
|
return cell
|
|
}
|
|
|
|
// MARK: - UITableViewDelegate
|
|
|
|
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
let cell = cells[indexPath.row]
|
|
switch cell {
|
|
case "Example":
|
|
navigationController?.pushViewController(ConversationViewController(), animated: true)
|
|
case "Settings":
|
|
navigationController?.pushViewController(SettingsViewController(), animated: true)
|
|
case "Source Code":
|
|
guard let url = URL(string: "https://github.com/MessageKit/MessageKit") else { return }
|
|
let webViewController = SFSafariViewController(url: url)
|
|
present(webViewController, animated: true, completion: nil)
|
|
case "Contributors":
|
|
guard let url = URL(string: "https://github.com/orgs/MessageKit/teams/contributors/members") else { return }
|
|
let webViewController = SFSafariViewController(url: url)
|
|
present(webViewController, animated: true, completion: nil)
|
|
default:
|
|
assertionFailure("You need to impliment the action for this cell: \(cell)")
|
|
return
|
|
}
|
|
}
|
|
}
|