Files
GitHawk/Classes/Utility/UIViewController+Routing.swift
Ryan Nystrom 66dc61ace0 Refactor labeled events to use StyledText (#1659)
* refactor tap handling on attributed views

* styled cell interaction working

* share menu code

* label events finished
2018-03-18 14:55:57 -04:00

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
}
}