diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift index f5181511..53585b74 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift @@ -53,12 +53,16 @@ import Foundation open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? CollapsableNotificationModel else { return } - - topView.label.set(with: model.topLabel, delegateObject, additionalData) - topView.button.set(with: model.topAction, delegateObject: delegateObject, additionalData: additionalData) - topView.updateAccessibility() - + topView.set(with: model, delegateObject, additionalData) bottomView.set(with: model, delegateObject, additionalData) + + // Update top view default noop to expand. + if model.topAction?.actionType == ActionNoopModel.identifier { + topView.button.addActionBlock(event: .touchUpInside) { [weak self] (button) in + Button.performButtonAction(with: model.topAction!, button: button, delegateObject: delegateObject, additionalData: additionalData) + self?.expand(topViewShowing: model.alwaysShowTopLabel) + } + } // Set initial collapse/expand state. topView.isHidden = !model.alwaysShowTopLabel && !model.initiallyCollapsed diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift index 36ddc8a6..c23edeae 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift @@ -43,6 +43,13 @@ import Foundation label.updateView(size) } + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + guard let model = model as? CollapsableNotificationModel else { return } + label.set(with: model.topLabel, delegateObject, additionalData) + button.set(with: model.topAction, delegateObject: delegateObject, additionalData: additionalData) + updateAccessibility() + } + open override func reset() { super.reset() label.setFontStyle(.BoldBodySmall) diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/Notification.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/Notification.swift index 44ce254b..09edbbcc 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/Notification.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/Notification.swift @@ -31,6 +31,16 @@ import Foundation super.setupView() reset() + // Buttons should have highest priority, then headline, then body + headline.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 500), for: .horizontal) + headline.setContentHuggingPriority(.required, for: .vertical) + body.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 500), for: .horizontal) + body.setContentHuggingPriority(.required, for: .vertical) + headline.setContentCompressionResistancePriority(UILayoutPriority(rawValue: body.contentCompressionResistancePriority(for: .vertical).rawValue + 40), for: .vertical) + headline.lineBreakMode = .byTruncatingTail + body.lineBreakMode = .byTruncatingTail + button.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal) + labelStack = Stack.createStack(with: [headline, body], spacing: 0) horizontalStack = Stack.createStack(with: [(view: labelStack, model: StackItemModel()),(view: button, model: StackItemModel(horizontalAlignment: .fill)),(view: closeButton, model: StackItemModel(horizontalAlignment: .fill))], axis: .horizontal) addSubview(horizontalStack) diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift index 84b1abbf..65c6e18c 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift @@ -25,6 +25,7 @@ import Foundation tintColor = .white adjustsImageWhenHighlighted = false accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: "AccCloseButton") + setContentCompressionResistancePriority(.defaultHigh, for: .horizontal) } open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {