Skip to content

Commit

Permalink
Merge pull request #36 from RakuyoKit/fix/ButtonRow
Browse files Browse the repository at this point in the history
fix: Rollback UIButton.Config usage in `ButtonRow`
  • Loading branch information
rakuyoMo authored May 28, 2024
2 parents 7b20f54 + b394755 commit 69ad107
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions Sources/Epoxy/Row/ButtonRow/ButtonRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extension ButtonRow: StyledView {
/// Please use `ButtonRow.Content` to set the text color for different states.
public let titleStyle: TextRow.Style?

///
/// The edge of button
public let edgeInsets: EdgeInsets

public init(
Expand All @@ -115,39 +115,19 @@ extension ButtonRow: StyledView {

size = style.size
tintColor = style.tintColor
contentEdgeInsets = style.edgeInsets.uiEdgeInsets

if let imageContentModel = style.imageContentModel {
imageView?.contentMode = imageContentModel
}

titleLabel?.font = style.titleStyle?.font

if #available(iOS 15, *) {
configuration = .plain()
configuration?.contentInsets = style.edgeInsets.directionalEdgeInsets

configuration?.titleAlignment =
switch style.titleStyle?.alignment {
case .center: .center
case .left: .leading
case .right: .trailing
default: .automatic
}

if let lineBreakMode = style.titleStyle?.lineBreakMode {
configuration?.titleLineBreakMode = lineBreakMode
configuration?.subtitleLineBreakMode = lineBreakMode
}

} else {
if let titleStyle = style.titleStyle {
titleLabel?.do {
$0.textAlignment = titleStyle.alignment
$0.numberOfLines = titleStyle.numberOfLines
$0.lineBreakMode = titleStyle.lineBreakMode
}
if let titleStyle = style.titleStyle {
titleLabel?.do {
$0.font = titleStyle.font
$0.textAlignment = titleStyle.alignment
$0.numberOfLines = titleStyle.numberOfLines
$0.lineBreakMode = titleStyle.lineBreakMode
}
contentEdgeInsets = style.edgeInsets.uiEdgeInsets
}

addTarget(self, action: #selector(buttonDidTouchDown(_:)), for: .touchDown)
Expand Down

0 comments on commit 69ad107

Please sign in to comment.