Minor change to the notification view

This commit is contained in:
Sumanth Nadigadda 2023-03-18 00:25:29 +05:30
parent c3ba748728
commit 2920559d84

View File

@ -55,6 +55,14 @@ public class Notification: View {
return UIDevice.isIPad ? VDSLayout.Spacing.space5X.value : VDSLayout.Spacing.space4X.value
}
private var minViewHeight: CGFloat {
return UIDevice.isIPad ? VDSLayout.Spacing.space16X.value : VDSLayout.Spacing.space12X.value
}
private var minContentHeight: CGFloat {
return UIDevice.isIPad ? VDSLayout.Spacing.space5X.value : VDSLayout.Spacing.space4X.value
}
//--------------------------------------------------
// MARK: - View Properties
//--------------------------------------------------
@ -75,7 +83,9 @@ public class Notification: View {
$0.textStyle = .bodySmall
}
open var buttonsView = ButtonGroup()
open var buttonsView = ButtonGroup().with {
$0.buttonPosition = .left
}
//--------------------------------------------------
// MARK: - Modal Properties
@ -130,15 +140,41 @@ public class Notification: View {
addSubview(mainStackView)
mainStackView.pinToSuperView(.init(top: edgeSpacing, left: edgeSpacing, bottom: edgeSpacing, right: edgeSpacing))
NSLayoutConstraint.activate([
heightAnchor.constraint(greaterThanOrEqualToConstant: minViewHeight),
mainStackView.heightAnchor.constraint(greaterThanOrEqualToConstant: minContentHeight)
])
mainStackView.addArrangedSubview(typeIcon)
mainStackView.addArrangedSubview(labelsView)
mainStackView.addArrangedSubview(closeButton)
labelsView.addArrangedSubview(titleLabel)
labelsView.addArrangedSubview(subTitleLabel)
labelsView.setCustomSpacing(VDSLayout.Spacing.space3X.value, after: subTitleLabel)
let firstButton = Button().with {
$0.text = "Button 1"
$0.use = .secondary
$0.size = .small
}
firstButton.publisher(for: .touchUpInside).sink { button in
print("\(button.text) has been pressed")
}.store(in: &subscribers)
#warning("Upon adding the button into the stack view, button is visible. Where as ButtonGroup with a single button is not rendered")
///This below doesn't work
buttonsView.buttons = [firstButton]
labelsView.addArrangedSubview(buttonsView)
publisher(for: UITapGestureRecognizer()).sink { [weak self] _ in
///This below works
//labelsView.addArrangedSubview(firstButton)
closeButton.publisher(for: UITapGestureRecognizer()).sink { [weak self] _ in
self?.didClickOnCloseButton()
}.store(in: &subscribers)
}