Skip to content

Commit

Permalink
running lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhieddine-El-Kaissi committed Apr 25, 2024
1 parent c5a8aff commit aaec477
Show file tree
Hide file tree
Showing 43 changed files with 178 additions and 184 deletions.
2 changes: 1 addition & 1 deletion Sources/Thumbprint/Common/Control.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open class Control: UIControl {
public var minTapTargetSize: CGSize? = CGSize(width: 48, height: 48)

public override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
guard let minTapTargetSize = minTapTargetSize else {
guard let minTapTargetSize else {
return super.point(inside: point, with: event)
}

Expand Down
46 changes: 23 additions & 23 deletions Sources/Thumbprint/Common/InputState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,57 +23,57 @@ public enum InputState {
public var backgroundImage: UIImage {
switch self {
case .default:
return InputState.defaultInputStateBackgroundImage
InputState.defaultInputStateBackgroundImage
case .highlighted:
return InputState.highlightedInputStateBackground
InputState.highlightedInputStateBackground
case .disabled:
return InputState.disabledInputStateBackground
InputState.disabledInputStateBackground
case .error:
return InputState.errorInputStateBackground
InputState.errorInputStateBackground
}
}

public var borderColor: UIColor {
switch self {
case .default:
return Color.gray
Color.gray
case .highlighted:
return Color.blue
Color.blue
case .disabled:
return Color.gray300
Color.gray300
case .error:
return Color.red
Color.red
}
}

public var backgroundColor: UIColor {
switch self {
case .disabled:
return Color.gray200
Color.gray200
default:
return Color.white
Color.white
}
}

public var textColor: UIColor {
switch self {
case .disabled:
return Color.gray
Color.gray
case .error:
return Color.red
Color.red
default:
return Color.black
Color.black
}
}

public var placeholderTextColor: UIColor {
switch self {
case .error:
return Color.red300
Color.red300
case .disabled:
return Color.gray
Color.gray
default:
return Color.black300
Color.black300
}
}
}
Expand All @@ -83,11 +83,11 @@ public extension InputState {
var markableControlTextColor: UIColor {
switch self {
case .disabled:
return Color.gray
Color.gray
case .error:
return Color.red
Color.red
default:
return Color.black
Color.black
}
}
}
Expand All @@ -96,13 +96,13 @@ public extension UIControl {
// UIControl doesn't have an error state by default, though many of our component subclasses do
func inputState(hasError: Bool = false) -> InputState {
if isEnabled == false {
return .disabled
.disabled
} else if hasError {
return .error
.error
} else if isSelected || isHighlighted || isFirstResponder {
return .highlighted
.highlighted
} else {
return .default
.default
}
}
}
6 changes: 3 additions & 3 deletions Sources/Thumbprint/Components/AlertBanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ public final class AlertBanner: UIView {
}

func updateAttributedText() {
guard let message = message,
let action = action,
let actionLink = actionLink else { return }
guard let message,
let action,
let actionLink else { return }

let textDynamicFont = Font.TextStyle.text2.scaledFont(compatibleWith: traitCollection)
let linkDynamicFont = Font.TextStyle.title7.scaledFont(compatibleWith: traitCollection)
Expand Down
10 changes: 5 additions & 5 deletions Sources/Thumbprint/Components/Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public final class Button: Control, UIContentSizeCategoryAdjusting {
public var isLoading: Bool {
didSet {
guard isLoading != oldValue,
let loaderDots = loaderDots
let loaderDots
else { return }

loaderDots.isHidden = !isLoading
Expand Down Expand Up @@ -361,7 +361,7 @@ private extension Button {
activeBackgroundImage = Button.backgroundImage(withColor: theme.activeBackgroundColor, borderColor: theme.activeBorderColor)
disabledBackgroundImage = Button.backgroundImage(withColor: theme.disabledBackgroundColor, borderColor: theme.disabledBorderColor)

if let loaderDots = loaderDots {
if let loaderDots {
loaderDots.removeFromSuperview()
}
if let loaderTheme = theme.loaderTheme {
Expand Down Expand Up @@ -390,7 +390,7 @@ private extension Button {

// Rejigger icon image view if needed.
iconImageView?.removeFromSuperview()
if let icon = icon {
if let icon {
let imageView = iconImageView ?? {
let imageView = UIImageView()
imageView.setContentCompressionResistancePriority(.required, for: .horizontal)
Expand Down Expand Up @@ -475,7 +475,7 @@ private extension Button {
}

let result = Button.backgroundImageRenderer.image(actions: { context in
if let backgroundColor = backgroundColor {
if let backgroundColor {
backgroundColor.setFill()

let fillPath = borderColor == nil
Expand All @@ -485,7 +485,7 @@ private extension Button {
context.cgContext.drawPath(using: .fill)
}

if let borderColor = borderColor {
if let borderColor {
borderColor.setStroke()

context.cgContext.setLineWidth(borderWidth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ extension CalendarPickerView: TTCalendarPicker.CalendarPickerDelegate {
// Prevents infinite loops when delegate == self (e.g. testing subclass)
private var nonSelfDelegate: CalendarPickerViewDelegate? {
if delegate === self {
return nil
nil
} else {
return delegate
delegate
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ class DayOfWeekHeaderView: UIView {
private let stackView: UIStackView

init(calendar: Calendar) {
let weekdaySymbols: [String]
if calendar.locale?.languageCode == "en" {
weekdaySymbols = calendar.weekdaySymbols.map({ String($0.prefix(2)) })
let weekdaySymbols: [String] = if calendar.locale?.languageCode == "en" {
calendar.weekdaySymbols.map({ String($0.prefix(2)) })
} else {
weekdaySymbols = calendar.veryShortWeekdaySymbols
calendar.veryShortWeekdaySymbols
}

let labels = weekdaySymbols.map({ (weekday: String) -> Label in
Expand Down
18 changes: 9 additions & 9 deletions Sources/Thumbprint/Components/Chips/Chip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Chip: Control {

public var text: String? {
get {
return pill.text
pill.text
}

set {
Expand All @@ -56,7 +56,7 @@ public class Chip: Control {
}

static var unselectedTheme: Pill.Theme {
return .init(backgroundColor: Color.white, contentColor: Color.blue)
.init(backgroundColor: Color.white, contentColor: Color.blue)
}

class var selectedTheme: Pill.Theme {
Expand Down Expand Up @@ -100,12 +100,12 @@ public class Chip: Control {

public override func sizeThatFits(_ size: CGSize) -> CGSize {
// Redirect to the pill.
return pill.sizeThatFits(size)
pill.sizeThatFits(size)
}

public override var intrinsicContentSize: CGSize {
// Redirect to the pill.
return pill.intrinsicContentSize
pill.intrinsicContentSize
}

public override func layoutSubviews() {
Expand All @@ -127,7 +127,7 @@ public class Chip: Control {
}

private func setupView() {
let pill = self.pill
let pill = pill
pill.translatesAutoresizingMaskIntoConstraints = false
addSubview(pill)

Expand Down Expand Up @@ -172,7 +172,7 @@ extension Chip: UIContentSizeCategoryAdjusting {
public var adjustsFontForContentSizeCategory: Bool {
get {
// Redirect to pill.
return pill.adjustsFontForContentSizeCategory
pill.adjustsFontForContentSizeCategory
}

set {
Expand Down Expand Up @@ -210,11 +210,11 @@ open class ChipPill: Pill {

private var borderWidth: CGFloat {
if !drawsBorder {
return 0.0
0.0
} else if adjustsFontForContentSizeCategory {
return Font.scaledValue(ChipPill.baseBorderWidth, for: label.textStyle)
Font.scaledValue(ChipPill.baseBorderWidth, for: label.textStyle)
} else {
return ChipPill.baseBorderWidth
ChipPill.baseBorderWidth
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Thumbprint/Components/Chips/FilterChip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import UIKit

public final class FilterChip: Chip {
override class var selectedTheme: Pill.Theme {
return .init(backgroundColor: Color.blue100, contentColor: Color.blue)
.init(backgroundColor: Color.blue100, contentColor: Color.blue)
}

override func buildAccessibilityLabel() -> String {
var result = isSelected ? "remove filter" : "apply filter"
if let text = text {
if let text {
result += " for: \(text)"
}
return result
Expand Down
4 changes: 2 additions & 2 deletions Sources/Thumbprint/Components/Chips/ToggleChip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import UIKit

public final class ToggleChip: Chip {
override class var selectedTheme: Pill.Theme {
return .init(backgroundColor: Color.blue, contentColor: Color.white)
.init(backgroundColor: Color.blue, contentColor: Color.white)
}

override func buildAccessibilityLabel() -> String {
var result = isSelected ? "remove selection" : "select"
if let text = text {
if let text {
result += " for: \(text)"
}
return result
Expand Down
8 changes: 4 additions & 4 deletions Sources/Thumbprint/Components/Dropdown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public final class Dropdown: Control, UIContentSizeCategoryAdjusting {
}

private func updateState() {
let inputState = self.inputState(hasError: hasError)
let inputState = inputState(hasError: hasError)

backgroundColor = inputState.backgroundColor
layer.borderColor = inputState.borderColor.cgColor
Expand Down Expand Up @@ -232,11 +232,11 @@ private extension InputState {
var arrowColor: UIColor {
switch self {
case .disabled:
return Color.gray
Color.gray
case .error:
return Color.red
Color.red
default:
return Color.black
Color.black
}
}
}
2 changes: 1 addition & 1 deletion Sources/Thumbprint/Components/EntityAvatar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class EntityAvatar: UIView {
public var initials: String? {
didSet {
guard oldValue != initials else { return }
if let initials = initials {
if let initials {
avatar.label.text = String(initials.uppercased().prefix(1))
} else {
avatar.label.text = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class TextFloatingActionButton: Control {
public private(set) var leftView: UIView? {
didSet {
oldValue?.removeFromSuperview()
guard let leftView = leftView else {
guard let leftView else {
return
}
contentStackView.insertArrangedSubview(leftView, at: 0)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Thumbprint/Components/Label.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ open class Label: UILabel {
debugDescription += "; frame: \(frame)"
debugDescription += "; textStyle: \(textStyle)"
debugDescription += "; adjustsFontForContentSizeCategory: \(adjustsFontForContentSizeCategory)"
if let text = text {
if let text {
debugDescription += "; text: '\(text)'"
} else {
debugDescription += "; text: nil"
Expand Down

0 comments on commit aaec477

Please sign in to comment.