Skip to content

Commit 53499c0

Browse files
fix alert's button layout calculations
1 parent dd759f3 commit 53499c0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Sources/ComponentsKit/Components/Alert/UKAlertController.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ public class UKAlertController: UKCenterModalController {
2323
body: { _ in UILabel() }
2424
)
2525

26-
self.header = self.titleLabel
27-
self.body = self.subtitleLabel
26+
if model.title.isNotNilAndEmpty && model.message.isNotNilAndEmpty {
27+
self.header = self.titleLabel
28+
self.body = self.subtitleLabel
29+
} else if model.title.isNotNilAndEmpty {
30+
self.body = self.titleLabel
31+
} else {
32+
self.body = self.subtitleLabel
33+
}
34+
2835
if model.primaryButton.isNotNil || model.secondaryButton.isNotNil {
2936
self.footer = self.buttonsStackView
3037
}
@@ -82,8 +89,10 @@ public class UKAlertController: UKCenterModalController {
8289
- AlertVM.buttonsSpacing
8390
- self.model.contentPaddings.leading
8491
- self.model.contentPaddings.trailing
92+
let availableButtonWidth = availableButtonsWidth / 2
8593

86-
if primaryButtonWidth + secondaryButtonWidth <= availableButtonsWidth {
94+
if primaryButtonWidth <= availableButtonWidth,
95+
secondaryButtonWidth <= availableButtonWidth {
8796
self.buttonsStackView.removeArrangedSubview(self.secondaryButton)
8897
self.buttonsStackView.insertArrangedSubview(self.secondaryButton, at: 0)
8998

0 commit comments

Comments
 (0)