Fetch license content via URL
This commit is contained in:
parent
a486cb4265
commit
8270c20179
|
@ -58,10 +58,17 @@ class CreditsViewController: UITableViewController, TableModelHost {
|
||||||
guard let vc = segue.destination as? LabelViewController else {
|
guard let vc = segue.destination as? LabelViewController else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let cell = sender as? SettingTableViewCell else {
|
guard let cell = sender as? SettingTableViewCell, let indexPath = tableView.indexPath(for: cell) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
vc.title = cell.leftText
|
vc.title = cell.leftText
|
||||||
|
switch model.row(at: indexPath) {
|
||||||
|
case .license:
|
||||||
|
vc.url = licenses[indexPath.row].url
|
||||||
|
|
||||||
|
case .notice:
|
||||||
|
vc.text = notices[indexPath.row].statement
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ class LabelViewController: UIViewController {
|
||||||
|
|
||||||
var text: String?
|
var text: String?
|
||||||
|
|
||||||
|
var url: URL?
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
super.awakeFromNib()
|
super.awakeFromNib()
|
||||||
|
|
||||||
|
@ -41,7 +43,17 @@ class LabelViewController: UIViewController {
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
if let url = url {
|
||||||
|
label?.text = nil
|
||||||
|
DispatchQueue(label: LabelViewController.description(), qos: .background).async { [weak self] in
|
||||||
|
let urlText = try? String(contentsOf: url)
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self?.label?.text = urlText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
label?.text = text
|
label?.text = text
|
||||||
|
}
|
||||||
|
|
||||||
scrollView?.applyPrimaryBackground(Theme.current)
|
scrollView?.applyPrimaryBackground(Theme.current)
|
||||||
label?.applyLight(Theme.current)
|
label?.applyLight(Theme.current)
|
||||||
|
|
Loading…
Reference in New Issue