-
Notifications
You must be signed in to change notification settings - Fork 1
/
UIFloatMenuAction.swift
152 lines (122 loc) · 3.92 KB
/
UIFloatMenuAction.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
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
152
//
// UIFloatMenuAction.swift
// UIFloatMenu
//
import UIKit
//MARK: - heightStyle
public enum heightStyle {
case compact
case standard
case big
}
//MARK: - labelConfig
public enum labelConfig {
case config(fontSize: CGFloat = 15, fontWeight: UIFont.Weight = .semibold)
}
//MARK: - itemColor
public enum itemColor {
case standard
case clear
case filled(_ color: UIColor)
case tinted(_ color: UIColor)
case custom(iconColor: UIColor = .clear, textColor: UIColor, backColor: UIColor)
}
//MARK: - cellLayout
public enum cellLayout {
case Icon_Title
case Title_Icon
}
//MARK: - spacerType
public enum spacerType {
case empty
case line(_ color: UIColor = UIColor.gray.withAlphaComponent(0.25), inset: CGFloat = 15)
case dashedLine(_ color: UIColor = UIColor.gray.withAlphaComponent(0.35))
case divider
}
//MARK: - itemSetup
public enum itemSetup {
/**
UIFloatMenu: ActionCell
- Parameter icon: Optional
- Parameter title: Title
- Parameter subtitle: Optional
- Parameter layout: Loyout of cell (**.Title_Icon**, **.Icon_Title**), Default: **.Title_Icon**.
- Parameter height: Height of cell (**.standard**, **.compact**), Default: **.standard**.
*/
case ActionCell(icon: UIImage? = nil, title: String, subtitle: String = "", layout: cellLayout = .Title_Icon, height: heightStyle = .standard)
/**
UIFloatMenu: Title
- Parameter title: Title
*/
case Title(_ title: String)
/**
UIFloatMenu: Spacer
- Parameter type: Type of spacer (**.empty**, **.line**, **.divider**)
*/
case Spacer(type: spacerType = .empty)
/**
UIFloatMenu: InfoCell
- Parameter icon: Optional
- Parameter title: Title
- Parameter label: Configuration of label (**fontSize**, **fontWeight**)
*/
case InfoCell(icon: UIImage? = nil, title: String,
label: labelConfig = .config(fontSize: 15, fontWeight: .semibold))
/**
UIFloatMenu: TextFieldCell
- Parameter title: Data in TextField at start
- Parameter placeholder: Placeholder
- Parameter isResponder: Is active at start
- Parameter isSecure: Show dots
- Parameter content: UITextContentType
- Parameter keyboard: UIKeyboardType
*/
case TextFieldCell(title: String = "", placeholder: String, isResponder: Bool = false,
isSecure: Bool = false, content: UITextContentType? = nil, keyboard: UIKeyboardType = .default)
/**
UIFloatMenu: SwitchCell
- Parameter icon: Optional
- Parameter title: Title
- Parameter isOn: Is On at start
- Parameter tintColor: Tint color
- Parameter action: Action for Switch
*/
case SwitchCell(icon: UIImage? = nil, title: String, isOn: Bool = false, tintColor: UIColor = .systemBlue, action: Selector)
/**
UIFloatMenu: SwitchCell
- Parameter title: Optional
- Parameter items: Items **[UIImage, String]**
- Parameter selected: Selected item
- Parameter action: Action for SegmentControl
*/
case SegmentCell(title: String = "", items: [Any], selected: Int = 0, action: Selector)
}
public typealias UIFloatMenuActionHandler = (UIFloatMenuAction) -> Void
//MARK: - UIFloatMenuAction
public class UIFloatMenuAction {
/**
UIFloatMenu: item
*/
public var item: itemSetup
/**
UIFloatMenu: itemColor
*/
public var itemColor: itemColor
/**
UIFloatMenu: closeOnTap
*/
public var closeOnTap: Bool
/**
UIFloatMenu: action
*/
public var action: UIFloatMenuActionHandler?
public init(item: itemSetup,
itemColor: itemColor = .standard,
closeOnTap: Bool = true,
action: UIFloatMenuActionHandler? = nil) {
self.item = item
self.itemColor = itemColor
self.closeOnTap = closeOnTap
self.action = action
}
}