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 backgroundImage = UIImage(named: "backgroundTest")!
var selectedGradientColorView: UIView?
var contentAreaBackgroundColorButton = Button().with { instance in
instance.size = .small
instance.use = .secondary
instance.text = "Select"
}
var heightTextField = NumericField().with {
$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: "Background Color", view: backgroundColorPickerSelectorView)
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: "Background Image", view: showBackgroundImageSwitch)
addFormRow(label: "Image Fallback Color", view: imageFallbackColorPickerSelectorView)
@ -264,22 +273,31 @@ class TileContainerViewController: BaseViewController<TileContainer> {
self.gradientColor1View.backgroundColor = .clear
self.gradientColor2View.backgroundColor = .clear
} else {
self.colorPickerType = .gradientColors(gradientColor1View)
self.colorPickerType = .gradientColors
self.gradientColorsFormStackView.isHidden = false
}
}
scalingTypePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.aspectRatio = item
self?.component.layoutIfNeeded()
self?.showDebug(show: self?.debugViewSwitch.isOn ?? false)
}
paddingPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.padding = item
}
imageFallbackColorPickerSelectorView.onPickerDidSelect = { [weak self] item in
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?) {
@ -310,6 +328,8 @@ extension TileContainerViewController: UIColorPickerViewControllerDelegate {
func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
guard let hexString = viewController.selectedColor.hexString else { return }
switch colorPickerType {
case .contentViewBackgroundColor:
component.containerView.backgroundColor = UIColor(hexString: hexString)
case .backgroundColor:
component.color = .custom(hexString)
case .gradientColors:
@ -335,6 +355,15 @@ extension TileContainerViewController {
case gradient
case none
var rawValue: String {
switch self {
case .gradient:
"gradient (select gradient colors to apply)"
default:
String(describing: self)
}
}
var effect: TileContainer.BackgroundEffect? {
return switch self {
case .transparency:
@ -370,6 +399,6 @@ extension TileContainerViewController {
//Internal helper enum to identiy the configuration
enum ColorPickerType {
case backgroundColor, gradientColors(UIView)
case backgroundColor, gradientColors, contentViewBackgroundColor
}
}