added contentArea background color

This commit is contained in:
Krishna Kishore Bandaru 2024-02-20 20:58:43 +05:30
parent 1780c95684
commit d99bf783f4

View File

@ -147,7 +147,12 @@ class TileContainerViewController: BaseViewController<TileContainer> {
var colorPickerType: ColorPickerType = .backgroundColor var colorPickerType: ColorPickerType = .backgroundColor
var backgroundImage = UIImage(named: "backgroundTest")! var backgroundImage = UIImage(named: "backgroundTest")!
var selectedGradientColorView: UIView? var selectedGradientColorView: UIView?
var contentAreaBackgroundColorButton = Button().with { instance in
instance.size = .small
instance.use = .secondary
instance.text = "Select"
}
var heightTextField = NumericField().with { var heightTextField = NumericField().with {
$0.placeholder = "Minimum 100px else it will occupy full container" $0.placeholder = "Minimum 100px else it will occupy full container"
} }
@ -178,6 +183,10 @@ class TileContainerViewController: BaseViewController<TileContainer> {
addFormRow(label: "Show Drop Shadow", view: showDropShadowSwitch) addFormRow(label: "Show Drop Shadow", view: showDropShadowSwitch)
addFormRow(label: "Background Color", view: backgroundColorPickerSelectorView) addFormRow(label: "Background Color", view: backgroundColorPickerSelectorView)
addFormRow(label: "Padding", view: paddingPickerSelectorView) addFormRow(label: "Padding", view: paddingPickerSelectorView)
let rowView = addFormRow(label: "Content area BG color(only for testing padding)", view: contentAreaBackgroundColorButton)
if let rowView = rowView as? UIStackView {
rowView.alignment = .top
}
addFormRow(label: "Aspect Ratio", view: scalingTypePickerSelectorView) addFormRow(label: "Aspect Ratio", view: scalingTypePickerSelectorView)
addFormRow(label: "Background Image", view: showBackgroundImageSwitch) addFormRow(label: "Background Image", view: showBackgroundImageSwitch)
addFormRow(label: "Image Fallback Color", view: imageFallbackColorPickerSelectorView) addFormRow(label: "Image Fallback Color", view: imageFallbackColorPickerSelectorView)
@ -264,22 +273,31 @@ class TileContainerViewController: BaseViewController<TileContainer> {
self.gradientColor1View.backgroundColor = .clear self.gradientColor1View.backgroundColor = .clear
self.gradientColor2View.backgroundColor = .clear self.gradientColor2View.backgroundColor = .clear
} else { } else {
self.colorPickerType = .gradientColors(gradientColor1View) self.colorPickerType = .gradientColors
self.gradientColorsFormStackView.isHidden = false self.gradientColorsFormStackView.isHidden = false
} }
} }
scalingTypePickerSelectorView.onPickerDidSelect = { [weak self] item in scalingTypePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.aspectRatio = item self?.component.aspectRatio = item
self?.component.layoutIfNeeded()
self?.showDebug(show: self?.debugViewSwitch.isOn ?? false)
} }
paddingPickerSelectorView.onPickerDidSelect = { [weak self] item in paddingPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.padding = item self?.component.padding = item
} }
imageFallbackColorPickerSelectorView.onPickerDidSelect = { [weak self] item in imageFallbackColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.imageFallbackColor = item self?.component.imageFallbackColor = item
} }
contentAreaBackgroundColorButton.onClick = { [weak self] _ in
guard let self else { return }
self.colorPickerType = .contentViewBackgroundColor
self.colorPicker.selectedColor = self.component.containerView.backgroundColor ?? .white
self.present(self.colorPicker, animated: true)
}
} }
func gradientColorTapped(_ sender: Button, view: UIView?) { func gradientColorTapped(_ sender: Button, view: UIView?) {
@ -310,6 +328,8 @@ extension TileContainerViewController: UIColorPickerViewControllerDelegate {
func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) { func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
guard let hexString = viewController.selectedColor.hexString else { return } guard let hexString = viewController.selectedColor.hexString else { return }
switch colorPickerType { switch colorPickerType {
case .contentViewBackgroundColor:
component.containerView.backgroundColor = UIColor(hexString: hexString)
case .backgroundColor: case .backgroundColor:
component.color = .custom(hexString) component.color = .custom(hexString)
case .gradientColors: case .gradientColors:
@ -335,6 +355,15 @@ extension TileContainerViewController {
case gradient case gradient
case none case none
var rawValue: String {
switch self {
case .gradient:
"gradient (select gradient colors to apply)"
default:
String(describing: self)
}
}
var effect: TileContainer.BackgroundEffect? { var effect: TileContainer.BackgroundEffect? {
return switch self { return switch self {
case .transparency: case .transparency:
@ -370,6 +399,6 @@ extension TileContainerViewController {
//Internal helper enum to identiy the configuration //Internal helper enum to identiy the configuration
enum ColorPickerType { enum ColorPickerType {
case backgroundColor, gradientColors(UIView) case backgroundColor, gradientColors, contentViewBackgroundColor
} }
} }