From 509ec8a766aea9ade106203ff492622b0d2d7386 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Tue, 11 Feb 2025 17:15:11 +0100 Subject: [PATCH] fix: use superview's width in fullwidth components only when it's greater than 0 --- .../Components/ProgressBar/UKProgressBar.swift | 8 +++++++- Sources/ComponentsKit/Components/Slider/UKSlider.swift | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Sources/ComponentsKit/Components/ProgressBar/UKProgressBar.swift b/Sources/ComponentsKit/Components/ProgressBar/UKProgressBar.swift index 3a14cc31..7fcbf095 100644 --- a/Sources/ComponentsKit/Components/ProgressBar/UKProgressBar.swift +++ b/Sources/ComponentsKit/Components/ProgressBar/UKProgressBar.swift @@ -182,7 +182,13 @@ open class UKProgressBar: UIView, UKComponent { // MARK: - UIView methods open override func sizeThatFits(_ size: CGSize) -> CGSize { - let width = self.superview?.bounds.width ?? size.width + let width: CGFloat + if let parentWidth = self.superview?.bounds.width, + parentWidth > 0 { + width = parentWidth + } else { + width = 10_000 + } return CGSize( width: min(size.width, width), height: min(size.height, self.model.backgroundHeight) diff --git a/Sources/ComponentsKit/Components/Slider/UKSlider.swift b/Sources/ComponentsKit/Components/Slider/UKSlider.swift index 07ce9b96..81980197 100644 --- a/Sources/ComponentsKit/Components/Slider/UKSlider.swift +++ b/Sources/ComponentsKit/Components/Slider/UKSlider.swift @@ -193,7 +193,13 @@ open class UKSlider: UIView, UKComponent { // MARK: - UIView Methods open override func sizeThatFits(_ size: CGSize) -> CGSize { - let width = self.superview?.bounds.width ?? size.width + let width: CGFloat + if let parentWidth = self.superview?.bounds.width, + parentWidth > 0 { + width = parentWidth + } else { + width = 10_000 + } return CGSize( width: min(size.width, width), height: min(size.height, self.model.handleSize.height)