add about page

This commit is contained in:
Bob Sun 2017-02-09 01:41:17 +08:00
parent 158fa99938
commit 9c13a628b9
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
6 changed files with 285 additions and 200 deletions

View file

@ -0,0 +1,42 @@
//
// AboutTableViewController.swift
// pass
//
// Created by Mingshen Sun on 8/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
class AboutTableViewController: BasicStaticTableViewController {
override func viewDidLoad() {
tableData = [
// section 0
[[CellDataKey.type: CellDataType.link, CellDataKey.title: "Website", CellDataKey.link: "https://github.com/mssun/pass-ios.git"],
[CellDataKey.type: CellDataType.link, CellDataKey.title: "Contact Developer", CellDataKey.link: "https://mssun.me"],],
// section 1,
[[CellDataKey.type: CellDataType.segue, CellDataKey.title: "Open Source Components", CellDataKey.link: "showOpenSourceComponentsSegue"],
[CellDataKey.type: CellDataType.segue, CellDataKey.title: "Special Thanks", CellDataKey.link: "showSpecialThanksSegue"],],
]
navigationItemTitle = "About"
super.viewDidLoad()
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if section == tableData.count - 1 {
let view = UIView()
let footerLabel = UILabel(frame: CGRect(x: 8, y: 15, width: tableView.frame.width, height: 60))
footerLabel.numberOfLines = 0
footerLabel.text = "pass for iOS\nBob Sun"
footerLabel.font = UIFont.preferredFont(forTextStyle: .footnote)
footerLabel.textColor = UIColor.lightGray
footerLabel.textAlignment = .center
view.addSubview(footerLabel)
return view
}
return nil
}
}

View file

@ -0,0 +1,64 @@
//
// BasicTableViewController.swift
// pass
//
// Created by Mingshen Sun on 9/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
enum CellDataType {
case link, segue, empty
}
enum CellDataKey {
case type, title, link, footer
}
class BasicStaticTableViewController: UITableViewController {
var tableData = [[Dictionary<CellDataKey, Any>]]()
var navigationItemTitle: String?
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = navigationItemTitle
}
override func numberOfSections(in tableView: UITableView) -> Int {
return tableData.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableData[section].count
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
let cellData = tableData[indexPath.section][indexPath.row]
cell.textLabel?.text = cellData[CellDataKey.title] as? String
cell.accessoryType = .disclosureIndicator
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let cellData = tableData[indexPath.section][indexPath.row]
let cellDataType = cellData[CellDataKey.type] as? CellDataType
switch cellDataType! {
case .segue:
let link = cellData[CellDataKey.link] as? String
performSegue(withIdentifier: link!, sender: self)
case .link:
let link = cellData[CellDataKey.link] as? String
UIApplication.shared.open(URL(string: link!)!, options: [:], completionHandler: nil)
default:
break
}
}
}

View file

@ -0,0 +1,41 @@
//
// OpenSourceComponentsTableViewController.swift
// pass
//
// Created by Mingshen Sun on 9/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
class OpenSourceComponentsTableViewController: BasicStaticTableViewController {
let openSourceComponents = [
["PasscodeLock",
"https://github.com/zahlz/SwiftPasscodeLock",
"https://github.com/zahlz/SwiftPasscodeLock/blob/master/LICENSE.txt"],
["ObjectiveGit",
"https://github.com/libgit2/objective-git",
"https://github.com/libgit2/objective-git/blob/master/LICENSE"],
["SwiftyUserDefaults",
"https://github.com/radex/SwiftyUserDefaults",
"https://github.com/radex/SwiftyUserDefaults/blob/master/LICENSE"],
["SVProgressHUD",
"https://github.com/SVProgressHUD/SVProgressHUD",
"https://github.com/SVProgressHUD/SVProgressHUD/blob/master/LICENSE.txt"],
["Result",
"https://github.com/antitypical/Result",
"https://github.com/antitypical/Result/blob/master/LICENSE"],
]
override func viewDidLoad() {
tableData.append([])
for item in openSourceComponents {
tableData[0].append(
[CellDataKey.type: CellDataType.link, CellDataKey.title: item[0], CellDataKey.link: item[1]]
)
}
navigationItemTitle = "Open Source Components"
super.viewDidLoad()
}
}

View file

@ -0,0 +1,28 @@
//
// SpecialThanksTableViewController.swift
// pass
//
// Created by Mingshen Sun on 9/2/2017.
// Copyright © 2017 Bob Sun. All rights reserved.
//
import UIKit
class SpecialThanksTableViewController: BasicStaticTableViewController {
let openSourceComponents = [
["Password Store",
"http://passwordstore.org"],
["Icon8",
"http://icons8.com"],
]
override func viewDidLoad() {
tableData.append([])
for item in openSourceComponents {
tableData[0].append(
[CellDataKey.type: CellDataType.link, CellDataKey.title: item[0], CellDataKey.link: item[1]]
)
}
navigationItemTitle = "Special Thanks"
super.viewDidLoad()
}}