From 21ab7ac8f12d14dcb469b8e0b0bdfe1b21a81b1a Mon Sep 17 00:00:00 2001 From: fhasse95 <49185957+fhasse95@users.noreply.github.com> Date: Fri, 7 Aug 2026 16:44:22 +0200 Subject: [PATCH] Added unbound DisclosureGroup constructors --- Package.swift | 2 +- .../Containers/DisclosureGroup.swift | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Package.swift b/Package.swift index e02bd3b..d34246a 100644 --- a/Package.swift +++ b/Package.swift @@ -17,7 +17,7 @@ let package = Package( .package(url: "https://source.skip.tools/skip-bridge.git", "0.17.2"..<"2.0.0"), .package(url: "https://source.skip.tools/skip-android-bridge.git", "0.6.4"..<"2.0.0"), .package(url: "https://source.skip.tools/swift-jni.git", "0.5.0"..<"2.0.0"), - .package(url: "https://source.skip.tools/skip-ui.git", from: "1.59.0"), + .package(url: "https://github.com/fhasse95/skip-ui.git", branch: "DisclosureGroup-Bugfixes"), ], targets: [ .target(name: "SkipFuseUI", dependencies: ["SkipSwiftUI"]), diff --git a/Sources/SkipSwiftUI/Containers/DisclosureGroup.swift b/Sources/SkipSwiftUI/Containers/DisclosureGroup.swift index c4edfdd..9575056 100644 --- a/Sources/SkipSwiftUI/Containers/DisclosureGroup.swift +++ b/Sources/SkipSwiftUI/Containers/DisclosureGroup.swift @@ -4,13 +4,14 @@ import SkipFuse import SkipUI public struct DisclosureGroup where Label : View, Content : View { - private let isExpanded: Binding + private let isExpanded: Binding? private let label: Label private let content: Content - @available(*, unavailable) public init(@ViewBuilder content: @escaping () -> Content, @ViewBuilder label: () -> Label) { - fatalError() + self.isExpanded = nil + self.content = content() + self.label = label() } public init(isExpanded: Binding, @ViewBuilder content: @escaping () -> Content, @ViewBuilder label: () -> Label) { @@ -26,19 +27,21 @@ extension DisclosureGroup : View { extension DisclosureGroup : SkipUIBridging { public var Java_view: any SkipUI.View { - return SkipUI.DisclosureGroup(getExpanded: { isExpanded.wrappedValue }, setExpanded: { isExpanded.wrappedValue = $0 }, bridgedContent: content.Java_viewOrEmpty, bridgedLabel: label.Java_viewOrEmpty) + if let isExpanded { + return SkipUI.DisclosureGroup(getExpanded: { isExpanded.wrappedValue }, setExpanded: { isExpanded.wrappedValue = $0 }, bridgedContent: content.Java_viewOrEmpty, bridgedLabel: label.Java_viewOrEmpty) + } else { + return SkipUI.DisclosureGroup(bridgedContent: content.Java_viewOrEmpty, bridgedLabel: label.Java_viewOrEmpty) + } } } extension DisclosureGroup where Label == Text { - @available(*, unavailable) public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: @escaping () -> Content) { - fatalError() + self.init(content: content, label: { Text(titleKey) }) } - @available(*, unavailable) @_disfavoredOverload public init(_ titleResource: AndroidLocalizedStringResource, @ViewBuilder content: @escaping () -> Content) { - fatalError() + self.init(content: content, label: { Text(titleResource) }) } public init(_ titleKey: LocalizedStringKey, isExpanded: Binding, @ViewBuilder content: @escaping () -> Content) { @@ -49,9 +52,8 @@ extension DisclosureGroup where Label == Text { self.init(isExpanded: isExpanded, content: content, label: { Text(titleResource) }) } - @available(*, unavailable) public init(_ label: S, @ViewBuilder content: @escaping () -> Content) where S : StringProtocol { - fatalError() + self.init(content: content, label: { Text(label) }) } @_disfavoredOverload public init(_ label: S, isExpanded: Binding, @ViewBuilder content: @escaping () -> Content) where S : StringProtocol {