From db630401e0a748a7a463db5589db3673f0a39b96 Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Thu, 1 Jan 2026 19:52:07 +0400 Subject: [PATCH] feat(ui): add fluent subview management methods - Add `addSubview` and `addSubviews` with method chaining support. - Implement variadic and array-based `addSubviews` variants. --- .../Classes/Extensions/FlexUI+UIView.swift | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Sources/FlexUI/Classes/Extensions/FlexUI+UIView.swift b/Sources/FlexUI/Classes/Extensions/FlexUI+UIView.swift index d5ef33e..d585d90 100644 --- a/Sources/FlexUI/Classes/Extensions/FlexUI+UIView.swift +++ b/Sources/FlexUI/Classes/Extensions/FlexUI+UIView.swift @@ -176,4 +176,37 @@ public extension FlexUI where Component: UIView { component.setContentCompressionResistancePriority(priority, for: axis) return self } + + /// Adds a view to the end of the receiver’s list of subviews. + /// + /// - Parameter view: The view to be added. After being added, this view appears on top of any other subviews. + /// - Returns: The current instance, allowing method chaining. + @discardableResult + @MainActor + func addSubview(_ view: UIView) -> Self { + component.addSubview(view) + return self + } + + /// Adds an array of views to the end of the receiver’s list of subviews. + /// + /// - Parameter views: An array of views to be added. + /// - Returns: The current instance, allowing method chaining. + @discardableResult + @MainActor + func addSubviews(_ views: [UIView]) -> Self { + views.forEach { component.addSubview($0) } + return self + } + + /// Adds multiple views as variadic parameters to the end of the receiver’s list of subviews. + /// + /// - Parameter views: A variable number of views to be added. + /// - Returns: The current instance, allowing method chaining. + @discardableResult + @MainActor + func addSubviews(_ views: UIView...) -> Self { + views.forEach { component.addSubview($0) } + return self + } }