Skip to content

Commit b89e530

Browse files
PanchamiShenoympospese
PanchamiShenoy
authored andcommitted
[CM-902] Add border color to colorView
1 parent 4d8b7ec commit b89e530

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Documentation is automatically generated from source code comments and rendered
3434

3535
Usage
3636
----------
37-
A category is a collection of components that share common traits. A category may contain subcategories. By default, components are laid out in nested table views, with each component being represented by a single row. A `CatalogDisplayView` is used to display a component in a single row. It displays small components together with a title and optional detail description. This is used for icons, fonts, and colors, but also works well for smaller components such as buttons. By using generics, `CaralogDisplayView` can display any view (populated with an associated model). The framework includes pre-defined categories for displaying common components: colors, fonts, and icons.
37+
A category is a collection of components that share common traits. A category may contain subcategories. By default, components are laid out in nested table views, with each component being represented by a single row. A `CatalogDisplayView` is used to display a component in a single row. It displays small components together with a title and optional detail description. This is used for icons, fonts, and colors, but also works well for smaller components such as buttons. By using generics, `CatalogDisplayView` can display any view (populated with an associated model). The framework includes pre-defined categories for displaying common components: colors, fonts, and icons.
3838

3939
The catalog display view model has four parameters:
4040

Sources/YComponentBrowser/Models/Categories/ColorCategory.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import Foundation
88

9-
/// Category for colours
9+
/// Category for colors
1010
public struct ColorCategory: Classification {
1111
/// The type of View category supports
1212
public typealias View = CatalogDisplayView<ColorView>

Sources/YComponentBrowser/UI Components/Generic Views/ColorView.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,31 @@ final public class ColorView: UIView {
2525

2626
/// :nodoc:
2727
public required init?(coder: NSCoder) { nil }
28-
28+
29+
/// :nodoc:
30+
public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
31+
super.traitCollectionDidChange(previousTraitCollection)
32+
if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
33+
setBorderColor()
34+
}
35+
}
36+
}
37+
38+
private extension ColorView {
2939
private func setUpColorView() {
3040
clipsToBounds = true
3141
layer.cornerRadius = Style.cornerRadius
32-
42+
layer.borderWidth = Style.borderWidth
43+
setBorderColor()
3344
NSLayoutConstraint.activate([
3445
widthAnchor.constraint(equalToConstant: Style.size.width),
3546
heightAnchor.constraint(equalToConstant: Style.size.height)
3647
])
3748
}
49+
50+
private func setBorderColor() {
51+
layer.borderColor = UIColor.quaternaryLabel.cgColor
52+
}
3853
}
3954

4055
// MARK: - Populatable

0 commit comments

Comments
 (0)