-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1518b9a
commit d2e6e69
Showing
7 changed files
with
124 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// SectionHeaderView.swift | ||
// Interface | ||
// | ||
// Created by erick.lozano.borges on 11/02/21. | ||
// | ||
|
||
import UIKit | ||
|
||
class SectionHeaderView: UIView { | ||
|
||
// MARK: - Views | ||
private let label: UILabel = { | ||
let label = UILabel(frame: .zero) | ||
label.numberOfLines = 1 | ||
label.font = Font.header | ||
label.textColor = Color.Text.secondary | ||
return label | ||
}() | ||
|
||
// MARK: - Properties | ||
public var text: String? { | ||
didSet { | ||
label.text = text | ||
} | ||
} | ||
|
||
// MARK: - Life Cycle | ||
init() { | ||
super.init(frame: .zero) | ||
setupViews() | ||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} | ||
|
||
// MARK: - Auto Layout | ||
|
||
extension SectionHeaderView: ViewCodable { | ||
func setupViewHierarchy() { | ||
addSubview(label) | ||
} | ||
|
||
func setupConstraints() { | ||
label.layout.applyConstraint { make in | ||
make.topAnchor(equalTo: topAnchor, constant: 8) | ||
make.bottomAnchor(equalTo: bottomAnchor, constant: -8) | ||
make.leadingAnchor(equalTo: leadingAnchor, constant: 16) | ||
make.trailingAnchor(equalTo: trailingAnchor, constant: -16) | ||
} | ||
} | ||
|
||
public func setupAditionalConfiguration() { | ||
backgroundColor = Color.Background.sectionHeader | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
Interface/Component/SectionHeaderView/SectionHeaderView.swift
This file was deleted.
Oops, something went wrong.
File renamed without changes.
35 changes: 35 additions & 0 deletions
35
InterfaceTests/Component/SectionHeader/SectionHeaderViewSpec.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// SectionHeaderViewSpec.swift | ||
// Interface | ||
// | ||
// Created by erick.lozano.borges on 11/02/21. | ||
// | ||
|
||
import Quick | ||
import Nimble | ||
import Nimble_Snapshots | ||
|
||
@testable import Interface | ||
|
||
class SectionHeaderSpec: QuickSpec { | ||
override func spec() { | ||
|
||
describe("SectionHeader") { | ||
|
||
var sut: SectionHeaderView! | ||
|
||
context("when initialized") { | ||
beforeEach { | ||
sut = SectionHeaderView() | ||
sut.text = "Section Title" | ||
sut.setDynamicSize(forHeight: 38.0) | ||
} | ||
|
||
it("shuold layout itself properly") { | ||
expect(sut) == snapshot("SectionHeader_Layout") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
File renamed without changes.
Binary file added
BIN
+3.75 KB
InterfaceTests/ReferenceImages/SectionHeaderViewSpec/SectionHeader_Layout@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters