[CM-902] Add border color to colorView

This commit is contained in:
PanchamiShenoy 2022-10-06 18:08:03 +05:30 committed by Mark Pospesel
parent 4d8b7ec054
commit b89e530dfd
3 changed files with 19 additions and 4 deletions

View File

@ -34,7 +34,7 @@ Documentation is automatically generated from source code comments and rendered
Usage Usage
---------- ----------
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. 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.
The catalog display view model has four parameters: The catalog display view model has four parameters:

View File

@ -6,7 +6,7 @@
import Foundation import Foundation
/// Category for colours /// Category for colors
public struct ColorCategory: Classification { public struct ColorCategory: Classification {
/// The type of View category supports /// The type of View category supports
public typealias View = CatalogDisplayView<ColorView> public typealias View = CatalogDisplayView<ColorView>

View File

@ -25,16 +25,31 @@ final public class ColorView: UIView {
/// :nodoc: /// :nodoc:
public required init?(coder: NSCoder) { nil } public required init?(coder: NSCoder) { nil }
/// :nodoc:
public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
setBorderColor()
}
}
}
private extension ColorView {
private func setUpColorView() { private func setUpColorView() {
clipsToBounds = true clipsToBounds = true
layer.cornerRadius = Style.cornerRadius layer.cornerRadius = Style.cornerRadius
layer.borderWidth = Style.borderWidth
setBorderColor()
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
widthAnchor.constraint(equalToConstant: Style.size.width), widthAnchor.constraint(equalToConstant: Style.size.width),
heightAnchor.constraint(equalToConstant: Style.size.height) heightAnchor.constraint(equalToConstant: Style.size.height)
]) ])
} }
private func setBorderColor() {
layer.borderColor = UIColor.quaternaryLabel.cgColor
}
} }
// MARK: - Populatable // MARK: - Populatable