From b00b7430340d8636b701d834a0c18185d710b07e Mon Sep 17 00:00:00 2001 From: david-swift Date: Sun, 18 Feb 2024 21:38:49 +0100 Subject: [PATCH] Improve view builder function for optionals --- .../Model/User Interface/View/ViewBuilder.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Sources/Adwaita/Model/User Interface/View/ViewBuilder.swift b/Sources/Adwaita/Model/User Interface/View/ViewBuilder.swift index ed8270f..b1f570d 100644 --- a/Sources/Adwaita/Model/User Interface/View/ViewBuilder.swift +++ b/Sources/Adwaita/Model/User Interface/View/ViewBuilder.swift @@ -58,14 +58,15 @@ public enum ViewBuilder { /// - Returns: A nonoptional component. public static func buildOptional(_ component: Component?) -> Component { .element( - VStack { - if let component { - buildFinalResult(component) - } else { - [] + Bin() + .child { + if let component { + buildFinalResult(component) + } else { + [] + } } - } - .visible(component != nil) + .visible(component != nil) ) }