From cc52dcb0c6bd1d047c652e06a8b3622756072e9b Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Thu, 22 Feb 2024 22:46:44 +0530 Subject: [PATCH] Added minor fix for max width & height --- .../TileContainerViewController.swift | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/VDSSample/ViewControllers/TileContainerViewController.swift b/VDSSample/ViewControllers/TileContainerViewController.swift index d1a571b..7c1bb65 100644 --- a/VDSSample/ViewControllers/TileContainerViewController.swift +++ b/VDSSample/ViewControllers/TileContainerViewController.swift @@ -183,6 +183,9 @@ class TileContainerViewController: BaseViewController { $0.textStyle = .boldBodyLarge $0.text = "This object does NOT reflect normal \"surface\" changes, all properties are maually set" }) + formStackView.addArrangedSubview(Label().with { + $0.text = "For testing max width is limited to 85% of view's width & 65% view's height." + }) addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Clickable", view: clickableSwitch) addFormRow(label: "Width", view: widthTextField) @@ -242,15 +245,21 @@ class TileContainerViewController: BaseViewController { heightTextField .numberPublisher .sink { [weak self] number in - self?.component.height = number?.cgFloatValue - self?.component.layoutIfNeeded() + guard let self else { return } + if let value = number?.cgFloatValue, value >= 100 && value < self.view.frame.height * 0.65 { + self.component.height = value + self.component.layoutIfNeeded() + } }.store(in: &subscribers) widthTextField .numberPublisher .sink { [weak self] number in - self?.component.width = number?.cgFloatValue - self?.component.layoutIfNeeded() + guard let self else { return } + if let value = number?.cgFloatValue, value >= 100 && value < self.view.frame.width * 0.85 { + self.component.width = value + self.component.layoutIfNeeded() + } }.store(in: &subscribers) }