This repository has been archived by the owner on Oct 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathViewController.swift
82 lines (76 loc) · 2.65 KB
/
ViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// ViewController.swift
// NativeBaseSample
//
// Created by toshi0383 on 8/26/16.
// Copyright © 2016 toshi0383. All rights reserved.
//
import UIKit
import TVMLKitchen
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.view.backgroundColor = .black
view.backgroundColor = .black
}
@IBAction func urlString(_ sender: AnyObject!) {
let appdelegateWindow = (UIApplication.shared.delegate as! AppDelegate).window!
Kitchen.serve(
urlString: Sample.tvmlUrl,
redirectWindow: appdelegateWindow,
// - Note: This is what Kitchen would do when animatedWindowTransition is true.
kitchenWindowWillBecomeVisible: {
Kitchen.window.alpha = 0.0
UIView.animate(
withDuration: 0.3,
animations: {
Kitchen.window.alpha = 1.0
},
completion: {
_ in
appdelegateWindow.alpha = 0.0
}
)
},
willRedirectToWindow: {
appdelegateWindow.alpha = 0.0
UIView.animate(
withDuration: 0.3,
animations: {
appdelegateWindow.alpha = 1.0
},
completion: {
_ in
Kitchen.window.alpha = 0.0
}
)
}
)
}
@IBAction func xmlString(_ sender: AnyObject!) {
let appdelegateWindow = (UIApplication.shared.delegate as! AppDelegate).window!
Kitchen.window.alpha = 1.0
Kitchen.serve(
xmlString: Sample.tvmlString,
redirectWindow: appdelegateWindow,
animatedWindowTransition: true
)
let seconds: Double = 2.0
let nanoSeconds = Int64(seconds * Double(NSEC_PER_SEC))
let time = DispatchTime.now() + Double(nanoSeconds) / Double(NSEC_PER_SEC)
DispatchQueue.main.asyncAfter(deadline: time) {
self.reset()
}
}
@IBAction func urlStringError() {
let appdelegateWindow = (UIApplication.shared.delegate as! AppDelegate).window!
Kitchen.serve(
urlString: "tvmlkitchen://helloworld.com/helloworld",
redirectWindow: appdelegateWindow
)
}
@IBAction func reset() {
Kitchen.navigationController.popToRootViewController(animated: false)
Kitchen.navigationController.setViewControllers([], animated: false)
}
}