forked from SwiftKickMobile/SwiftMessages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTacoDialogView.swift
48 lines (38 loc) · 1.16 KB
/
TacoDialogView.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
//
// TacoDialogView.swift
// Demo
//
// Created by Tim Moose on 8/12/16.
// Copyright © 2016 SwiftKick Mobile. All rights reserved.
//
import UIKit
import SwiftMessages
class TacoDialogView: MessageView {
fileprivate static var tacoTitles = [
1 : "Just one, Please",
2 : "Make it two!",
3 : "Three!!!",
4 : "Cuatro!!!!",
]
var getTacosAction: ((_ count: Int) -> Void)?
var cancelAction: (() -> Void)?
fileprivate var count = 1 {
didSet {
iconLabel?.text = String(repeating: "🌮", count: count)//String(count: count, repeatedValue: )
bodyLabel?.text = TacoDialogView.tacoTitles[count] ?? "\(count)" + String(repeating: "!", count: count)
}
}
@IBAction func getTacos() {
getTacosAction?(Int(tacoSlider.value))
}
@IBAction func cancel() {
cancelAction?()
}
@IBOutlet weak var tacoSlider: UISlider!
@IBAction func tacoSliderSlid(_ slider: UISlider) {
count = Int(slider.value)
}
@IBAction func tacoSliderFinished(_ slider: UISlider) {
slider.setValue(Float(count), animated: true)
}
}