-
Notifications
You must be signed in to change notification settings - Fork 1
/
UIFloatMenuConfig.swift
195 lines (143 loc) · 4.19 KB
/
UIFloatMenuConfig.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//
// UIFloatMenuConfig.swift
// UIFloatMenu
//
import UIKit
//MARK: - presentationStyle
/**
UIFloatMenu: Present styles.
*/
public enum UIFloatMenuPresentStyle {
/**
UIFloatMenu: Located in center of window
*/
case center
/**
UIFloatMenu: Presented from buttom
*/
case `default`
/**
UIFloatMenu: Located in left up corner
overToolBar = **false**
*/
case leftUp(overNavBar: Bool = false)
/**
UIFloatMenu: Located in left down corner
overToolBar = **true**
*/
case leftDown(overToolBar: Bool = true)
/**
UIFloatMenu: Located in right up corner
overToolBar = **false**
*/
case rightUp(overNavBar: Bool = false)
/**
UIFloatMenu: Located in right down
overToolBar = **true**
*/
case rightDown(overToolBar: Bool = true)
}
// MARK: - UIFloatMenuConfig
public struct UIFloatMenuConfig {
/**
UIFloatMenu: Corner radius of menu
Default: **12**.
*/
public var cornerRadius: CGFloat!
/**
UIFloatMenu: Width of menu for iPad (for iPhone is always **window.width-30**)
Default: **400**.
*/
public var viewWidth_iPad: CGFloat!
/**
UIFloatMenu: Add blur to background
Default: **false**.
*/
public var blurBackground: Bool
/**
UIFloatMenu: Presentation styles
- Parameter center: Located in center of window
- Parameter default: Presented from bottom
- Parameter leftUp: Located in left up corner
- Parameter leftDown: Located in left down corner
- Parameter rightUp: Located in right up corner
- Parameter rightDown: Located in right down corner
Default: **.default**.
*/
public var presentation: UIFloatMenuPresentStyle!
public init(cornerRadius: CGFloat = 12,
blurBackground: Bool = false,
presentation: UIFloatMenuPresentStyle = .default,
viewWidth_iPad: CGFloat = 400) {
self.cornerRadius = cornerRadius
self.blurBackground = blurBackground
self.presentation = presentation
self.viewWidth_iPad = viewWidth_iPad
}
}
// MARK: - UIMenuHeaderConfig
public struct UIFloatMenuHeaderConfig {
/**
UIFloatMenu: Show header
Default: **true**.
*/
public var showHeader: Bool
public var image: UIImage?
/**
UIFloatMenu: Title of header
*/
public var title: String
/**
UIFloatMenu: Subtitle of header (optional)
*/
public var subTitle: String?
/**
UIFloatMenu: Show line under header
Default: **true**.
*/
public var showLine: Bool
/**
UIFloatMenu: **Left** and **Right** insets for line
Default: **15**.
*/
public var lineInset: CGFloat
public init(showHeader: Bool = true, image: UIImage? = nil, title: String = "", subTitle: String? = "",
showLine: Bool = true, lineInset: CGFloat = 15) {
self.showHeader = showHeader
self.image = image
self.title = title
self.subTitle = subTitle
self.showLine = showLine
self.lineInset = lineInset
}
}
// MARK: - UIFloatMenuQueue
public struct UIFloatMenuQueue {
public var uuid: Int!
public var viewHeight: CGFloat!
public var config: UIFloatMenuConfig!
public var actions: [UIFloatMenuAction]!
public init(uuid: Int, viewHeight: CGFloat = 0, config: UIFloatMenuConfig, actions: [UIFloatMenuAction]) {
self.uuid = uuid
self.viewHeight = viewHeight
self.config = config
self.actions = actions
}
}
// MARK: - UIFloatMenuID
class UIFloatMenuID {
let shared = UIFloatMenuID()
static let backViewID = 100010001
static func genUUID(_ count: Int) -> Int {
if count == 0 {
return backViewID
} else {
return backViewID+count
}
}
}
class UIFloatMenuColors {
let shared = UIFloatMenuColors()
static let mainColor = UIColor(named: "UIMenuMainColor")
static let revColor = UIColor(named: "UIMenuRevColor")
}