Skip to content

Commit

Permalink
fix(Bottom Sheet): Fix component to expand horizontally (#290)
Browse files Browse the repository at this point in the history
* fix(Bottom Sheet): Fix component to expand horizontally

* IOS-9113: Removed magic number
  • Loading branch information
WanaldinoTelefonica committed Jul 19, 2023
1 parent c321d88 commit 266c5d8
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import UIKit

// MARK: InformativeRow

private enum Constants: CGFloat {
case extraLeftMargin = 8
}

class InformativeRow: UIView {
struct Asset {
let url: String
Expand Down Expand Up @@ -53,7 +57,7 @@ class InformativeRow: UIView {

private let bottomContent: UIStackView = {
let stackView = UIStackView()
stackView.spacing = 8
stackView.isLayoutMarginsRelativeArrangement = true
return stackView
}()

Expand All @@ -65,8 +69,6 @@ class InformativeRow: UIView {
label.minHeight = 20
return label
}()

private lazy var dummyView = SpacerView(axis: .horizontal, amount: 1)
}

// MARK: Private
Expand All @@ -84,13 +86,12 @@ private extension InformativeRow {
bottomContent.isHidden = true
}

dummyView.amount = item.icon.size.width
bottomContent.layoutMargins.left = item.icon.size.width + Constants.extraLeftMargin.rawValue
}

func layoutViews() {
addSubview(withDefaultConstraints: centerSection)

bottomContent.addArrangedSubview(dummyView)
bottomContent.addArrangedSubview(detailLabel)

centerSection.addArrangedSubview(topContent)
Expand All @@ -109,7 +110,7 @@ private class TopContentView: UIView {
private var frontStackView: UIStackView = {
let stackView = UIStackView()
stackView.alignment = .center
stackView.spacing = 8
stackView.isLayoutMarginsRelativeArrangement = true
return stackView
}()

Expand Down Expand Up @@ -137,8 +138,6 @@ private class TopContentView: UIView {
return label
}()

private lazy var dummyView = SpacerView(axis: .horizontal, amount: 1)

var title: String? {
didSet {
dummyTitleLabel.text = title
Expand All @@ -150,7 +149,7 @@ private class TopContentView: UIView {
didSet {
iconImageView.intrinsicHeight = icon.size.height
iconImageView.intrinsicWidth = icon.size.width
dummyView.amount = icon.size.width
frontStackView.layoutMargins.left = icon.size.width + Constants.extraLeftMargin.rawValue

load(icon: icon, in: iconImageView)

Expand Down Expand Up @@ -179,7 +178,6 @@ private class TopContentView: UIView {
backStackView.addArrangedSubview(iconImageView)
backStackView.addArrangedSubview(dummyTitleLabel)

frontStackView.addArrangedSubview(dummyView)
frontStackView.addArrangedSubview(titleLabel)
}

Expand Down

0 comments on commit 266c5d8

Please sign in to comment.