Skip to content

Commit 509ec8a

Browse files
fix: use superview's width in fullwidth components only when it's greater than 0
1 parent b30e434 commit 509ec8a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Sources/ComponentsKit/Components/ProgressBar/UKProgressBar.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,13 @@ open class UKProgressBar: UIView, UKComponent {
182182
// MARK: - UIView methods
183183

184184
open override func sizeThatFits(_ size: CGSize) -> CGSize {
185-
let width = self.superview?.bounds.width ?? size.width
185+
let width: CGFloat
186+
if let parentWidth = self.superview?.bounds.width,
187+
parentWidth > 0 {
188+
width = parentWidth
189+
} else {
190+
width = 10_000
191+
}
186192
return CGSize(
187193
width: min(size.width, width),
188194
height: min(size.height, self.model.backgroundHeight)

Sources/ComponentsKit/Components/Slider/UKSlider.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,13 @@ open class UKSlider: UIView, UKComponent {
193193
// MARK: - UIView Methods
194194

195195
open override func sizeThatFits(_ size: CGSize) -> CGSize {
196-
let width = self.superview?.bounds.width ?? size.width
196+
let width: CGFloat
197+
if let parentWidth = self.superview?.bounds.width,
198+
parentWidth > 0 {
199+
width = parentWidth
200+
} else {
201+
width = 10_000
202+
}
197203
return CGSize(
198204
width: min(size.width, width),
199205
height: min(size.height, self.model.handleSize.height)

0 commit comments

Comments
 (0)