mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-04-21 10:14:55 +08:00
* refactor tap handling on attributed views * styled cell interaction working * share menu code * label events finished
30 lines
904 B
Swift
30 lines
904 B
Swift
//
|
|
// UIViewController+Routing.swift
|
|
// Freetime
|
|
//
|
|
// Created by Ryan Nystrom on 3/17/18.
|
|
// Copyright © 2018 Ryan Nystrom. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
extension UIViewController {
|
|
|
|
@discardableResult
|
|
func handle(attribute: DetectedMarkdownAttribute) -> Bool {
|
|
switch attribute {
|
|
case .url(let url): presentSafari(url: url)
|
|
case .email(let email):
|
|
if let url = URL(string: "mailTo:\(email)") {
|
|
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
|
}
|
|
case .username(let username): presentProfile(login: username)
|
|
case .label(let label): presentLabels(owner: label.owner, repo: label.repo, label: label.label)
|
|
case .commit(let commit): presentCommit(owner: commit.owner, repo: commit.repo, hash: commit.hash)
|
|
default: return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
}
|