From 2920559d84275997d3daa95ee109ff352f0136e7 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Sat, 18 Mar 2023 00:25:29 +0530 Subject: [PATCH] Minor change to the notification view --- .../Notification/Notification.swift | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index 483d7f9c..527ff307 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -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) }