Skip to content

Commit

Permalink
remove unnecessary self.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjochen committed Nov 7, 2017
1 parent 23b9f46 commit 5ce0e81
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
5 changes: 2 additions & 3 deletions Example/FloatingActionButton/FirstViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import JJFloatingActionButton

class FirstViewController: UIViewController {


override func viewDidLoad() {
super.viewDidLoad()

let actionButton = JJFloatingActionButton()

actionButton.addItem(title: "item 1", image: UIImage(named: "first")?.withRenderingMode(.alwaysTemplate)) { item in
Expand All @@ -25,7 +24,7 @@ class FirstViewController: UIViewController {
self.showMessage(for: item)
}

actionButton.addItem(title: "item 3", image: nil) { item in
actionButton.addItem(title: "item 3") { item in
self.showMessage(for: item)
}

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ actionButton.addItem(title: "item 1", image: UIImage(named: "first")?.withRender
}

actionButton.addItem(title: "item 2", image: UIImage(named: "second")?.withRenderingMode(.alwaysTemplate)) { item in
self.showMessage(for: item)
// do something
}

actionButton.addItem(title: "item 3", image: nil) { item in
self.showMessage(for: item)
// do something
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/JJActionItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ internal protocol JJActionItemDelegate {

fileprivate(set) lazy var titleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.text = self.title
titleLabel.text = title
titleLabel.numberOfLines = 1
return titleLabel
}()

fileprivate(set) lazy var circleView: JJCircleImageView = {
let view = JJCircleImageView()
view.image = self.image
view.image = image
return view
}()

Expand Down
2 changes: 1 addition & 1 deletion Sources/JJCircleImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal class JJCircleImageView: UIView {
}

open override func draw(_: CGRect) {
drawCircle(inRect: self.bounds)
drawCircle(inRect: bounds)
}

fileprivate lazy var imageView: UIImageView = {
Expand Down
23 changes: 10 additions & 13 deletions Sources/JJFloatingActionButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public extension JJFloatingActionButton {
}

public extension JJFloatingActionButton {
@objc @discardableResult public func addItem(title: String?, image: UIImage?, action: ((JJActionItem) -> Void)?) -> JJActionItem {
@objc @discardableResult public func addItem(title: String? = nil, image: UIImage? = nil, action: ((JJActionItem) -> Void)? = nil) -> JJActionItem {
let item = JJActionItem()
item.title = title
item.image = image
Expand All @@ -142,7 +142,7 @@ public extension JJFloatingActionButton {
guard state == .closed else {
return
}
guard let superview = self.superview else {
guard let superview = superview else {
return
}
state = .opening
Expand Down Expand Up @@ -308,14 +308,14 @@ fileprivate extension JJFloatingActionButton {
}

func configureItem(_ item: JJActionItem) {
item.circleView.circleColor = self.itemButtonColor
item.circleView.imageColor = self.itemImageColor
item.titleLabel.font = self.itemTitleFont
item.titleLabel.textColor = self.itemTitleColor
item.layer.shadowColor = self.itemShadowColor.cgColor
item.layer.shadowOpacity = self.itemShadowOpacity
item.layer.shadowOffset = self.itemShadowOffset
item.layer.shadowRadius = self.itemShadowRadius
item.circleView.circleColor = itemButtonColor
item.circleView.imageColor = itemImageColor
item.titleLabel.font = itemTitleFont
item.titleLabel.textColor = itemTitleColor
item.layer.shadowColor = itemShadowColor.cgColor
item.layer.shadowOpacity = itemShadowOpacity
item.layer.shadowOffset = itemShadowOffset
item.layer.shadowRadius = itemShadowRadius
item.delegate = self
}

Expand Down Expand Up @@ -442,9 +442,6 @@ extension JJFloatingActionButton {

if state == .open, let openItems = openItems {
for item in openItems {
if item.isHidden || !item.isUserInteractionEnabled {
continue
}
let pointInItem = item.convert(point, from: self)
if item.bounds.contains(pointInItem) {
return item.hitTest(pointInItem, with: event)
Expand Down

0 comments on commit 5ce0e81

Please sign in to comment.