From 901cdc571fa760b2e0c4b0993d67fb364659e261 Mon Sep 17 00:00:00 2001 From: Nikita Semenov Date: Thu, 11 Aug 2022 00:41:18 +0300 Subject: [PATCH] fix: renames + additional configuration --- .../Models/BaseFilterCellAppearance.swift | 32 ++++++++++++------- .../Views/DefaultFilterCollectionCell.swift | 25 ++++----------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/TIEcommerce/Sources/Filters/FiltersCollectionCell/Models/BaseFilterCellAppearance.swift b/TIEcommerce/Sources/Filters/FiltersCollectionCell/Models/BaseFilterCellAppearance.swift index 53229444..91229bb0 100644 --- a/TIEcommerce/Sources/Filters/FiltersCollectionCell/Models/BaseFilterCellAppearance.swift +++ b/TIEcommerce/Sources/Filters/FiltersCollectionCell/Models/BaseFilterCellAppearance.swift @@ -25,32 +25,42 @@ import UIKit open class BaseFilterCellAppearance { /// The color of the border in selected state - public var selectedColor: UIColor - /// The color of the background in the selected state + public var selectedBorderColor: UIColor + /// The color of the border in normal state + public var normalBorderColor: UIColor + /// The color of the background in the selected state public var selectedBgColor: UIColor - /// The color of the background in the deselected state - public var deselectedBgColor: UIColor + /// The color of the background in the normal state + public var normalBgColor: UIColor public var selectedFontColor: UIColor - public var deselectedFontColor: UIColor + public var normalFontColor: UIColor + + public var selectedBorderWidth: CGFloat + public var normalBorderWidth: CGFloat public var contentInsets: UIEdgeInsets public var cornerRadius: CGFloat - public init(selectedColor: UIColor = .systemGreen, + public init(selectedBorderColor: UIColor = .systemGreen, + normalBorderColor: UIColor = .lightGray, selectedBgColor: UIColor = .white, - deselectedBgColor: UIColor = .lightGray, + normalBgColor: UIColor = .lightGray, selectedFontColor: UIColor = .systemGreen, - deselectedFontColor: UIColor = .black, + normalFontColor: UIColor = .black, + selectedBorderWidth: CGFloat = 1, + normalBorderWidth: CGFloat = 0, contentInsets: UIEdgeInsets = .init(top: 4, left: 8, bottom: 4, right: 8), cornerRadius: CGFloat = 6) { - self.selectedColor = selectedColor + self.selectedBorderColor = selectedBorderColor self.selectedBgColor = selectedBgColor - self.deselectedBgColor = deselectedBgColor + self.normalBgColor = normalBgColor self.selectedFontColor = selectedFontColor - self.deselectedFontColor = deselectedFontColor + self.normalFontColor = normalFontColor + self.selectedBorderWidth = selectedBorderWidth + self.normalBorderWidth = normalBorderWidth self.contentInsets = contentInsets self.cornerRadius = cornerRadius } diff --git a/TIEcommerce/Sources/Filters/FiltersCollectionCell/Views/DefaultFilterCollectionCell.swift b/TIEcommerce/Sources/Filters/FiltersCollectionCell/Views/DefaultFilterCollectionCell.swift index 556f03e7..51342a6d 100644 --- a/TIEcommerce/Sources/Filters/FiltersCollectionCell/Views/DefaultFilterCollectionCell.swift +++ b/TIEcommerce/Sources/Filters/FiltersCollectionCell/Views/DefaultFilterCollectionCell.swift @@ -62,30 +62,19 @@ open class DefaultFilterCollectionCell: ContainerCollectionViewCell, } // MARK: - Open methdos + open func setAppearance() { switch currentSelectionState { case .normal: - wrappedView.textColor = cellAppearance.deselectedFontColor - layer.borderWidth = 0 - backgroundColor = cellAppearance.deselectedBgColor + wrappedView.textColor = cellAppearance.normalFontColor + backgroundColor = cellAppearance.normalBgColor + layer.borderColor = cellAppearance.normalBorderColor.cgColor + layer.borderWidth = cellAppearance.normalBorderWidth case .selected: wrappedView.textColor = cellAppearance.selectedFontColor backgroundColor = cellAppearance.selectedBgColor - layer.borderColor = cellAppearance.selectedColor.cgColor - layer.borderWidth = 1 + layer.borderColor = cellAppearance.selectedBorderColor.cgColor + layer.borderWidth = cellAppearance.selectedBorderWidth } } - - open func setSelectedAppearance() { - wrappedView.textColor = cellAppearance.selectedFontColor - backgroundColor = cellAppearance.selectedBgColor - layer.borderColor = cellAppearance.selectedColor.cgColor - layer.borderWidth = 1 - } - - open func setDeselectAppearance() { - wrappedView.textColor = cellAppearance.deselectedFontColor - layer.borderWidth = 0 - backgroundColor = cellAppearance.deselectedBgColor - } }