-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathTaskViewController.swift
More file actions
62 lines (51 loc) · 1.86 KB
/
TaskViewController.swift
File metadata and controls
62 lines (51 loc) · 1.86 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
import Foundation
import UIKit
import Macaw
import FanMenu
class TaskViewController: UIViewController {
@IBOutlet weak var fanMenu: FanMenu!
@IBOutlet weak var colorLabel: UILabel!
let colors = [0x231FE4, 0x00BFB6, 0xFFC43D, 0xFF5F3D, 0xF34766]
override func viewDidLoad() {
super.viewDidLoad()
fanMenu.button = mainButton(colorHex: 0x7C93FE)
fanMenu.items = colors.enumerated().map { arg -> FanMenuButton in
let (index, item) = arg
return FanMenuButton(
id: String(index),
image: .none,
color: Color(val: item)
)
}
fanMenu.menuRadius = 70.0
fanMenu.duration = 0.2
fanMenu.interval = (Double.pi, 2 * Double.pi)
fanMenu.radius = 15.0
fanMenu.onItemWillClick = { button in
self.hideTitle()
if button.id != "main" {
let newColor = self.colors[Int(button.id)!]
let fanGroup = self.fanMenu.node as? Group
let circleGroup = fanGroup?.contents[2] as? Group
let shape = circleGroup?.contents[0] as? Shape
shape?.fill = Color(val: newColor)
}
}
fanMenu.transform = CGAffineTransform(rotationAngle: CGFloat(3 * Double.pi/2.0))
fanMenu.backgroundColor = .clear
}
func hideTitle() {
let newValue = !self.colorLabel.isHidden
UIView.transition(
with: colorLabel, duration: 0.5, options: .transitionCrossDissolve, animations: {
self.colorLabel.isHidden = newValue
}, completion: nil)
}
func mainButton(colorHex: Int) -> FanMenuButton {
return FanMenuButton(
id: "main",
image: .none,
color: Color(val: colorHex)
)
}
}