-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewController.swift
More file actions
152 lines (126 loc) · 5.25 KB
/
ViewController.swift
File metadata and controls
152 lines (126 loc) · 5.25 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//
// ViewController.swift
// UIDynamicView
//
// Created by osfunapps on 08/18/2020.
// Copyright (c) 2020 osfunapps. All rights reserved.
//
import UIKit
import UIDynamicView
import OsTools
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// Tools.asyncMainTimedFunc(popFactsDialog, 2)
Tools.asyncMainTimedFunc(popHelpDialog, 2)
}
private func popHelpDialog() {
// prepare the dialog
let dialogWrapper = UIDialogWrapper(parentView: view, margin: 20, maxWidthPercentFromParent: 0.85)
// set title and description
dialogWrapper.setTitle(text: "Turn on your TV", size: 18)
dialogWrapper.setTopDesription(text: """
In the future, allow this TV to be turned on by the phone
""", size: 16)
dialogWrapper.setFooter(leftBtnText: "Later",
rightBtnText: "Allow",
leftBtnTapSelector: #selector(onNiceTap),
rightBtnTapSelector: #selector(onNextFactTap))
// attach the view to it's parent
dialogWrapper.attachView(parentView: view)
// // build the dynamic view with all of the props
// dv = UIDynamicView()
// dv.prepareView(parentView: view,
// padding: 14,
// margin: 14,
// maxWidthPercentFromParent: 0.65)
// dv.dropShadow(shadowRadius: 5.0)
//
// // add the title
// let topTitleProps = InitialLabelProps(text: "Help",
// textAlignment: .center,
// font: UIFont.systemFont(ofSize: 20, weight: .bold))
// dv.addView(initialProps: topTitleProps)
//
// // add the description
// let descriptionProps = InitialLabelProps(text:
// """
// Please watch the below video to understand how to use the app
// """,
// textAlignment: .left,
// font: UIFont.systemFont(ofSize: 19)
// )
// dv.addView(initialProps: descriptionProps)
//
// // add the youtube video
// let videoProps = InitialYoutubeVideoProps(videoId: "BywDOO99Ia0",
// widthPercentFromParent: 0.75,
// alignment: .center)
// dv.addView(initialProps: videoProps)
//
// // add the footer button
// let okBtnProps = InitialButtonProps(labelText: "OK",
// alignment: .right,
// tapSelector: #selector(onOkBtnTap))
//
// dv.addView(initialProps: okBtnProps)
// dv.attachView(parentView: view)
}
private var dv: UIDynamicView!
private func popFactsDialog() {
// build the dynamic view with all of the props
dv = UIDynamicView()
dv.prepareView(parentView: view,
padding: 14,
margin: 14,
maxWidthPercentFromParent: 0.65)
dv.dropShadow(shadowRadius: 5.0)
// add the title
let topTitleProps = InitialLabelProps(text: "New Features",
textAlignment: .center,
font: UIFont.systemFont(ofSize: 20, weight: .bold))
dv.addView(initialProps: topTitleProps)
// add the image
let imgProps = InitialUIImageViewProps(imageName: "tt",
widthPercentFromParent: 0.3,
tag: 99,
alignment: .center)
dv.addView(initialProps: imgProps)
// add the description
let descriptionProps = InitialLabelProps(text:
"""
Teletubbies is a British children's television series
created by Ragdoll Productions' Anne Wood and Andrew
Davenport for BBC.
""",
textAlignment: .left,
font: UIFont.systemFont(ofSize: 17)
)
dv.addView(initialProps: descriptionProps)
// add the footer buttons
let nextFactButton = InitialButtonProps(labelText: "Previous Fact",
alignment: .left,
tapSelector: #selector(onNextFactTap))
let niceBtn = InitialButtonProps(labelText: "Next Fact!",
alignment: .right,
tapSelector: #selector(onNiceTap))
let footerStackViewProps = InitialStackViewProps(subviewsInitialPropsList: [nextFactButton, niceBtn])
dv.addView(initialProps: footerStackViewProps)
dv.attachView(parentView: view)
}
@objc func onNiceTap() {
print("nice!")
}
@objc func onNextFactTap() {
print("next!")
}
@objc func onOkBtnTap() {
dv.fadeOut {
self.dv.removeFromSuperview()
}
}
}