From 3809e96b1605c10a5189e7d0419b46eaddee05f2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 12 Aug 2024 09:58:06 -0500 Subject: [PATCH 1/2] fixed bug within radiobox Signed-off-by: Matt Bruce --- VDS/Components/RadioBox/RadioBoxGroup.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/VDS/Components/RadioBox/RadioBoxGroup.swift b/VDS/Components/RadioBox/RadioBoxGroup.swift index b5531e33..8c955999 100644 --- a/VDS/Components/RadioBox/RadioBoxGroup.swift +++ b/VDS/Components/RadioBox/RadioBoxGroup.swift @@ -71,13 +71,13 @@ open class RadioBoxGroup: SelectorGroupBase, SelectorGroupSingleSe mainStackView.axis = .horizontal mainStackView.distribution = .fillEqually } else { - if UIDevice.current.orientation.isPortrait || UIDevice.current.orientation == .unknown { - mainStackView.axis = .vertical - mainStackView.distribution = .fill - - } else { + let orientation = UIDevice.current.orientation + if orientation == .landscapeLeft || orientation == .landscapeRight { mainStackView.axis = .horizontal mainStackView.distribution = .fillEqually + } else { + mainStackView.axis = .vertical + mainStackView.distribution = .fill } } } From 3ee592f63814ef4435c672638b1180119a1c36e2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 12 Aug 2024 12:27:49 -0500 Subject: [PATCH 2/2] fixed bug in radiobox Signed-off-by: Matt Bruce --- VDS/Components/RadioBox/RadioBoxGroup.swift | 25 ++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/VDS/Components/RadioBox/RadioBoxGroup.swift b/VDS/Components/RadioBox/RadioBoxGroup.swift index 8c955999..000e3433 100644 --- a/VDS/Components/RadioBox/RadioBoxGroup.swift +++ b/VDS/Components/RadioBox/RadioBoxGroup.swift @@ -67,17 +67,26 @@ open class RadioBoxGroup: SelectorGroupBase, SelectorGroupSingleSe // MARK: - Overrides //-------------------------------------------------- private func ensureDevice() { + var axis: NSLayoutConstraint.Axis = .vertical + var distribution: UIStackView.Distribution = .fill + + defer { + mainStackView.axis = axis + mainStackView.distribution = distribution + } + if UIDevice.isIPad { - mainStackView.axis = .horizontal - mainStackView.distribution = .fillEqually + axis = .horizontal + distribution = .fillEqually } else { + guard let supportedOrientations = UIApplication.shared.windows.first?.rootViewController?.supportedInterfaceOrientations else { + return + } + let orientation = UIDevice.current.orientation - if orientation == .landscapeLeft || orientation == .landscapeRight { - mainStackView.axis = .horizontal - mainStackView.distribution = .fillEqually - } else { - mainStackView.axis = .vertical - mainStackView.distribution = .fill + if supportedOrientations.contains(.landscape) && (orientation == .landscapeLeft || orientation == .landscapeRight) { + axis = .horizontal + distribution = .fillEqually } } }