Skip to content

Commit d14c54e

Browse files
committed
Updated
1 parent 8bf8d7f commit d14c54e

11 files changed

+55
-53
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
- Title_Icon (Title left, Icon right)
4949
```
5050

51+
Action item height
52+
```swift
53+
- standard
54+
- compact
55+
```
56+
5157
Spacer type
5258
```swift
5359
- empty
@@ -83,6 +89,7 @@ menu.header.title = "UIFloatMenu title"
8389
menu.header.subTitle = "UIFloatMenu subtitle"
8490
menu.header.showHeader = true
8591
menu.header.showLine = true
92+
menu.header.lineInset = 15
8693
menu.config.cornerRadius = 12
8794
menu.config.blurBackground = true
8895
menu.config.viewWidth_iPad = 350
@@ -96,15 +103,15 @@ menu.show(self)
96103
To `know when menu is closed`, set the delegate with protocol `UIFloatMenuCloseDelegate`:
97104

98105
```swift
99-
func didCloseMenu() {
106+
func UIFloatMenuDidCloseMenu() {
100107
print("didCloseMenu - MenuClosed")
101108
}
102109
```
103110

104111
To get `UITextField data`, set the delegate with protocol `UIFloatMenuTextFieldDelegate`:
105112

106113
```swift
107-
func getTextFieldData(_ data: [String]) {
114+
func UIFloatMenuGetTextFieldData(_ data: [String]) {
108115
print("TextField -", data)
109116
}
110117
```

Sources/UIFloatMenu.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class UIFloatMenu {
120120
}
121121

122122
switch sender.state {
123+
case .began:
124+
break
123125
case .changed:
124126
panChanged(sender)
125127
case .ended, .cancelled:
@@ -174,7 +176,7 @@ class UIFloatMenu {
174176
static private func panEnded(_ gesture: UIPanGestureRecognizer, dismissDragSize: CGFloat) {
175177
let velocity = gesture.velocity(in: gesture.view).y
176178
if ((gesture.view!.frame.origin.y+40) >= dismissDragSize) || (velocity > 180) {
177-
NotificationCenter.default.post(name: NSNotification.Name("UIMenuClose"), object: nil)
179+
NotificationCenter.default.post(name: NSNotification.Name("UIFloatMenuClose"), object: nil)
178180
} else {
179181
UIView.animate(withDuration: 0.2, animations: {
180182
if let UIFloatMenu = currentVC.view.viewWithTag(queue.last!.uuid!) {
@@ -184,6 +186,7 @@ class UIFloatMenu {
184186
}
185187
}
186188

189+
// MARK: - correctPosition()
187190
static public func correctPosition(_ position: UIFloatMenuPresentStyle) -> UIFloatMenuPresentStyle {
188191
let device = UIDevice.current.userInterfaceIdiom
189192

@@ -207,12 +210,6 @@ class UIFloatMenu {
207210
}
208211
}
209212

210-
private enum presentPosition {
211-
case prepare
212-
case show
213-
case close
214-
}
215-
216213
// MARK: - closeMenu()
217214
static private func closeMenu(_ menuView: UIView) {
218215
let correct = correctPosition(viewConfig.presentation)

Sources/UIFloatMenuAction.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
import UIKit
77

8+
//MARK: - heightStyle
9+
public enum heightStyle {
10+
case standard
11+
case compact
12+
}
13+
814
//MARK: - labelConfig
915
public enum labelConfig {
1016
case config(fontSize: CGFloat = 15, fontWeight: UIFont.Weight = .semibold)
@@ -41,9 +47,10 @@ public enum itemSetup {
4147
- Parameter icon: Optional
4248
- Parameter title: Title
4349
- Parameter subtitle: Optional
44-
- Parameter layout: Loyout of cell (**Title_Icon** or **Icon_Title**), Default: **.Title_Icon**.
50+
- Parameter layout: Loyout of cell (**.Title_Icon**, **.Icon_Title**), Default: **.Title_Icon**.
51+
- Parameter height: Height of cell (**.standard**, **.compact**), Default: **.standard**.
4552
*/
46-
case ActionCell(icon: UIImage? = nil, title: String, subtitle: String = "", layout: cellLayout = .Title_Icon)
53+
case ActionCell(icon: UIImage? = nil, title: String, subtitle: String = "", layout: cellLayout = .Title_Icon, height: heightStyle = .standard)
4754

4855
/**
4956
UIFloatMenu: Title
@@ -65,7 +72,6 @@ public enum itemSetup {
6572
- Parameter icon: Optional
6673
- Parameter title: Title
6774
- Parameter label: Configuration of label (**fontSize**, **fontWeight**)
68-
- Parameter type: Type of spacer (**.empty**, **.line**, **.divider**)
6975
*/
7076
case InfoCell(icon: UIImage? = nil, title: String,
7177
label: labelConfig = .config(fontSize: 15, fontWeight: .semibold))
@@ -88,7 +94,7 @@ public enum itemSetup {
8894

8995
- Parameter icon: Optional
9096
- Parameter title: Title
91-
- Parameter isOn: Is on at start
97+
- Parameter isOn: Is On at start
9298
- Parameter tintColor: Tint color
9399
- Parameter action: Action for Switch
94100
*/

Sources/UIFloatMenuController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class UIFloatMenuController: UIViewController, UIGestureRecognizerDelegate {
4242

4343
// MARK: - deinit
4444
deinit {
45-
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: "UIMenuClose"), object: nil)
45+
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: "UIFloatMenuClose"), object: nil)
4646
}
4747

4848
// MARK: - viewDidLoad
@@ -57,7 +57,7 @@ class UIFloatMenuController: UIViewController, UIGestureRecognizerDelegate {
5757
tap.cancelsTouchesInView = false
5858
backgroundView.addGestureRecognizer(tap)
5959

60-
NotificationCenter.default.addObserver(self, selector: #selector(tapClose), name: NSNotification.Name(rawValue: "UIMenuClose"), object: nil)
60+
NotificationCenter.default.addObserver(self, selector: #selector(tapClose), name: NSNotification.Name(rawValue: "UIFloatMenuClose"), object: nil)
6161
}
6262

6363
// MARK: - viewDidAppear
@@ -111,7 +111,7 @@ class UIFloatMenuController: UIViewController, UIGestureRecognizerDelegate {
111111
})
112112

113113
if closeDelegate != nil {
114-
closeDelegate?.didCloseMenu()
114+
closeDelegate?.UIFloatMenuDidCloseMenu()
115115
}
116116
}
117117

Sources/UIFloatMenuDelegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public protocol UIFloatMenuCloseDelegate: AnyObject {
1111
/**
1212
UIFloatMenu: Called when pressed close button (or overlay) or swiped.
1313
*/
14-
func didCloseMenu()
14+
func UIFloatMenuDidCloseMenu()
1515

1616
}
1717

@@ -23,6 +23,6 @@ public protocol UIFloatMenuTextFieldDelegate: AnyObject {
2323

2424
- Returns: Text from all textfields in menu
2525
*/
26-
func getTextFieldData(_ data: [String])
26+
func UIFloatMenuGetTextFieldData(_ data: [String])
2727

2828
}

Sources/UIFloatMenuHelper.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@ extension UIPanGestureRecognizer {
140140

141141
extension UIView {
142142

143-
//MARK: - UIControlViewShadow()
144-
func UIMenuShadow(offset: CGSize, color: UIColor, radius: CGFloat, opacity: Float) {
143+
//MARK: - UIFloatMenuShadow()
144+
func UIFloatMenuShadow(offset: CGSize, color: UIColor, radius: CGFloat, opacity: Float) {
145145
layer.masksToBounds = false
146146
layer.shadowOffset = offset
147147
layer.shadowColor = color.cgColor
148148
layer.shadowRadius = radius
149149
layer.shadowOpacity = opacity
150150
}
151151

152-
//MARK: - UIControlViewRoundCorners()
153-
func UIMenuRoundCorners(_ corners: UIRectCorner, radius: CGFloat) {
152+
//MARK: - UIFloatMenuRoundCorners()
153+
func UIFloatMenuRoundCorners(_ corners: UIRectCorner, radius: CGFloat) {
154154
if #available(iOS 11.0, *) {
155155
clipsToBounds = true
156156
layer.cornerRadius = radius
@@ -252,7 +252,7 @@ struct Layout {
252252
if screenSize == appSize {
253253
return .iPadFullscreen // Full screen
254254
}
255-
255+
256256
let persent = CGFloat(appWidth / screenWidth) * 100.0
257257

258258
if persent <= 55.0 && persent >= 45.0 {

Sources/UIFloatMenuView/Cell/UIFloatMenuActionCell.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class UIFloatMenuActionCell: UITableViewCell {
99

1010
var itemColor: itemColor!
1111
var itemLayout: cellLayout!
12+
var itemHeight: heightStyle!
1213

1314
var initBackColor: UIColor!
1415

@@ -119,16 +120,18 @@ class UIFloatMenuActionCell: UITableViewCell {
119120

120121
contentStackView.translatesAutoresizingMaskIntoConstraints = false
121122

123+
let top_bottom: CGFloat = (itemHeight == .standard ? 10 : 7)
124+
122125
switch itemLayout {
123-
case .Icon_Title:
126+
case .Icon_Title:
124127
if iconImageView.image != nil {
125128
iconImageView.frame.origin.x = 10
126129
}
127130

128131
NSLayoutConstraint.activate([
129-
contentStackView.topAnchor.constraint(equalTo: backView.topAnchor, constant: 10),
132+
contentStackView.topAnchor.constraint(equalTo: backView.topAnchor, constant: top_bottom),
130133
contentStackView.leadingAnchor.constraint(equalTo: backView.leadingAnchor, constant: iconImageView.image != nil ? 40 : 10),
131-
contentStackView.bottomAnchor.constraint(equalTo: backView.bottomAnchor, constant: -10),
134+
contentStackView.bottomAnchor.constraint(equalTo: backView.bottomAnchor, constant: -top_bottom),
132135
contentStackView.trailingAnchor.constraint(equalTo: backView.trailingAnchor, constant: -10)
133136
])
134137
break
@@ -138,9 +141,9 @@ class UIFloatMenuActionCell: UITableViewCell {
138141
}
139142

140143
NSLayoutConstraint.activate([
141-
contentStackView.topAnchor.constraint(equalTo: backView.topAnchor, constant: 10),
144+
contentStackView.topAnchor.constraint(equalTo: backView.topAnchor, constant: top_bottom),
142145
contentStackView.leadingAnchor.constraint(equalTo: backView.leadingAnchor, constant: 10),
143-
contentStackView.bottomAnchor.constraint(equalTo: backView.bottomAnchor, constant: -10),
146+
contentStackView.bottomAnchor.constraint(equalTo: backView.bottomAnchor, constant: -top_bottom),
144147
contentStackView.trailingAnchor.constraint(equalTo: backView.trailingAnchor, constant: iconImageView.image != nil ? -40 : -10)
145148
])
146149
break

Sources/UIFloatMenuView/Cell/UIFloatMenuSegmentCell.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ class UIFloatMenuSegmentCell: UITableViewCell {
1010
private var contentStackView: UIStackView = UIStackView()
1111

1212
var items = [Any]()
13-
var vc: UIViewController!
14-
var selectedItem: Int!
15-
var action: Selector!
1613

1714
lazy var titleLabel: UILabel = {
1815
let label = UILabel()
@@ -23,12 +20,7 @@ class UIFloatMenuSegmentCell: UITableViewCell {
2320
return label
2421
}()
2522

26-
lazy var segmentView: UISegmentedControl = {
27-
let segment = UISegmentedControl(items: items)
28-
segment.selectedSegmentIndex = selectedItem
29-
segment.addTarget(vc, action: action, for: .valueChanged)
30-
return segment
31-
}()
23+
lazy var segmentView = UISegmentedControl(items: items)
3224

3325
// MARK: init
3426
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {

Sources/UIFloatMenuView/Cell/UIFloatMenuSwitchCell.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ class UIFloatMenuSwitchCell: UITableViewCell {
2626
return imageView
2727
}()
2828

29-
lazy var switchView: UISwitch = {
30-
let sw = UISwitch()
31-
return sw
32-
}()
29+
lazy var switchView = UISwitch()
3330

3431
// MARK: init
3532
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {

Sources/UIFloatMenuView/UIFloatMenuHeaderView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ class UIFloatMenuHeaderView: UIView {
123123

124124
// MARK: tapClose
125125
@objc func tapClose(_ sender: UIPanGestureRecognizer) {
126-
NotificationCenter.default.post(name: NSNotification.Name("UIMenuClose"), object: nil)
126+
NotificationCenter.default.post(name: NSNotification.Name("UIFloatMenuClose"), object: nil)
127127
}
128128
}

0 commit comments

Comments
 (0)