Skip to content

Commit 9fdd5b6

Browse files
update
1 parent 66b558c commit 9fdd5b6

8 files changed

Lines changed: 50 additions & 189 deletions

File tree

ButtonClickStyle.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@
204204
4AC8BC3327FC65A900F85008 /* ButtonClickStyle */ = {
205205
isa = PBXGroup;
206206
children = (
207-
4AC8BC3627FC65A900F85008 /* ButtonClick+Styles.swift */,
208-
4AC8BC3727FC65A900F85008 /* ButtonClickStyle+AddViewsAnimation.swift */,
209-
4AC8BC3927FC65A900F85008 /* ButtonClickStyle+GestureRecognizer.swift */,
210207
4AC8BC3A27FC65A900F85008 /* Animations */,
211208
4AC8BC4527FC65A900F85008 /* ButtonClickStyleView.swift */,
212209
4AC8BC4627FC65A900F85008 /* ButtonClick.swift */,
210+
4AC8BC3627FC65A900F85008 /* ButtonClick+Styles.swift */,
211+
4AC8BC3727FC65A900F85008 /* ButtonClickStyle+AddViewsAnimation.swift */,
212+
4AC8BC3927FC65A900F85008 /* ButtonClickStyle+GestureRecognizer.swift */,
213213
);
214214
path = ButtonClickStyle;
215215
sourceTree = "<group>";
@@ -471,8 +471,8 @@
471471
4AC8BC8D27FC65AA00F85008 /* TestDemo */ = {
472472
isa = PBXGroup;
473473
children = (
474-
4AC8BC8E27FC65AA00F85008 /* TestDemoViewController.storyboard */,
475474
4AC8BC8F27FC65AA00F85008 /* TestDemoViewController.swift */,
475+
4AC8BC8E27FC65AA00F85008 /* TestDemoViewController.storyboard */,
476476
);
477477
path = TestDemo;
478478
sourceTree = "<group>";

ButtonClickStyle/ButtonClickStyle/ButtonClickStyleView.swift

Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ import UIKit
1313
class ButtonClickStyleView: UIView {
1414

1515
@IBInspectable var animationType: Int = 0
16-
17-
@IBInspectable var allSubviews: Bool = true
1816
@IBInspectable var animationValue: CGFloat = 0.0
1917
@IBInspectable var animationDuration: CGFloat = 0.0
20-
@IBInspectable var buttonColor: Bool = false
21-
@IBInspectable var startClick: Bool = false
18+
@IBInspectable var allSubviews: Bool = true
2219

2320
var addViews: [UIView]?
2421

@@ -30,8 +27,6 @@ class ButtonClickStyleView: UIView {
3027

3128

3229
var cornerRadius: CGFloat = 0.0
33-
// var animationTypeValue: CGFloat?
34-
var animationClickDuration: CGFloat?
3530

3631

3732
// var frontView: UIView?
@@ -50,14 +45,13 @@ class ButtonClickStyleView: UIView {
5045
}
5146

5247
let animVal: CGFloat? = animationValue != 0.0 ? animationValue : nil
53-
// let animDur: CGFloat? = animationDuration != 0.0 ? animationDuration : nil
48+
let animDur: CGFloat? = animationDuration != 0.0 ? animationDuration : nil
5449

5550
self.state = .init(
5651
allSubviews: allSubviews,
5752
animationType: animationType,
5853
animationTypeValue: animVal,
59-
startClick: startClick,
60-
buttonColor: buttonColor
54+
animationDuration: animDur
6155
)
6256
}
6357
updateSubviews()
@@ -92,43 +86,14 @@ class ButtonClickStyleView: UIView {
9286
self.layer.cornerRadius = radius
9387
self.allSubviews = state.allSubviews
9488
self.animationType = state.animationType ?? 0
95-
// self.animationTypeValue = state.animationTypeValue
96-
self.buttonColor = state.buttonColor
9789
self.addViews = addViews
98-
self.startClick = state.startClick
9990

10091

10192
if debugPrint { print(" ------------------------------------------") }
10293
if debugPrint { print(" ButtonClickStyleView 🥶 init (STATE frame radius addViews) 🥶 \(self) ") }
10394

10495
}
10596

106-
// public init(
107-
// frame: CGRect,
108-
// radius: CGFloat = 0.0,
109-
// animation: Int = 0,
110-
// allSubviews: Bool = true,
111-
// value: CGFloat? = nil,
112-
// duration: CGFloat? = nil,
113-
// addViews: [UIView]? = nil,
114-
// startClick: Bool = false
115-
// ) {
116-
// super.init(frame: frame)
117-
// self.cornerRadius = radius
118-
// self.allSubviews = allSubviews
119-
// self.layer.cornerRadius = radius
120-
// self.animationType = animation
121-
// self.animationTypeValue = value
122-
// self.animationClickDuration = duration
123-
// self.addViews = addViews
124-
// self.startClick = startClick
125-
//
126-
// if debugPrint { print(" ------------------------------------------") }
127-
// if debugPrint { print(" ButtonClickStyleView 🥶 init (frame radius animation value duration addViews startClick) 🥶 \(self) ") }
128-
//// updateSubviews()
129-
// }
130-
131-
13297
// MARK: - Layout subViews Update
13398

13499

@@ -152,7 +117,7 @@ class ButtonClickStyleView: UIView {
152117
if setupDone { return }
153118
guard let state = state else { return }
154119

155-
let style = ButtonClick.Style.getClick(state: state)
120+
self.style = ButtonClick.Style.getClick(state: state)
156121

157122
var onlyButtonReturn = true
158123
switch style.typeEasy() {
@@ -180,12 +145,12 @@ class ButtonClickStyleView: UIView {
180145
}
181146

182147
func updateStartClick() {
183-
if startClick {
184-
startClick = false
185-
148+
// if startClick {
149+
// startClick = false
150+
//
186151
let nviews = getViews()
187-
button?.onClick(views: nviews, radius: cornerRadius, style: style, duration: animationClickDuration)
188-
}
152+
button?.onClick(views: nviews, radius: cornerRadius, style: style, duration: state?.animationDuration)
153+
// }
189154
}
190155

191156
public func update(animationType: Int, allSubviews: Bool = true) {
@@ -211,7 +176,6 @@ class ButtonClickStyleView: UIView {
211176
// MARK: - Set Animation Style
212177

213178
public func setAnimation(style: ButtonClick.Style, views: [UIView]? = nil) {
214-
self.style = style
215179
// updateSubviews()
216180

217181
layer.cornerRadius = cornerRadius
@@ -239,20 +203,10 @@ class ButtonClickStyleView: UIView {
239203
// MARK: - Create Button
240204

241205

242-
243-
// public func createFrontView() {
244-
//
245-
// let v = UIView(frame: bounds)
246-
// v.backgroundColor = .clear
247-
// v.clipsToBounds = false
248-
// addSubview(v)
249-
// self.frontView = v
250-
// }
251-
252206
public func createButton() {
253207
let btn = UIButton(type: .system)
254208
btn.frame = bounds
255-
btn.backgroundColor = buttonColor ? UIColor.systemRed.withAlphaComponent(0.4) : .clear
209+
btn.backgroundColor = .clear
256210
btn.setTitle(nil, for: .normal)
257211
btn.layer.cornerRadius = cornerRadius
258212
btn.clipsToBounds = true

ButtonClickStyle/UI/Button/BtnCellState.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ struct BtnCellState: Equatable {
1212
var allSubviews: Bool = true
1313
var animationType: Int?
1414
var animationTypeValue: CGFloat?
15-
var startClick: Bool = true
15+
var animationDuration: CGFloat?
1616
var new: Bool = false
1717
var color: UIColor?
1818
var addBackgrondColor: Bool = true
19-
var buttonColor: Bool = false
19+
// var startClick: Bool = false
20+
// var buttonColor: Bool = false
2021
}

ButtonClickStyle/UI/Screen/ButtonList/ButtonListViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ButtonListViewController: StoryboardController {
3939
}()
4040

4141
override func viewDidAppear(_ animated: Bool) {
42-
_ = doSomethingOnce
42+
// _ = doSomethingOnce
4343

4444
main(delay: 0.35) {
4545
self.updateButtons()

0 commit comments

Comments
 (0)