Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let package = Package(
.package(url: "https://github.com/skiptools/skip-bridge.git", "0.17.2"..<"2.0.0"),
.package(url: "https://github.com/skiptools/skip-android-bridge.git", "0.6.4"..<"2.0.0"),
.package(url: "https://github.com/skiptools/swift-jni.git", "0.5.0"..<"2.0.0"),
.package(url: "https://github.com/skiptools/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"]),
Expand Down
22 changes: 12 additions & 10 deletions Sources/SkipSwiftUI/Containers/DisclosureGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import SkipFuse
import SkipUI

public struct DisclosureGroup<Label, Content> where Label : View, Content : View {
private let isExpanded: Binding<Bool>
private let isExpanded: Binding<Bool>?
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<Bool>, @ViewBuilder content: @escaping () -> Content, @ViewBuilder label: () -> Label) {
Expand All @@ -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<Bool>, @ViewBuilder content: @escaping () -> Content) {
Expand All @@ -49,9 +52,8 @@ extension DisclosureGroup where Label == Text {
self.init(isExpanded: isExpanded, content: content, label: { Text(titleResource) })
}

@available(*, unavailable)
public init<S>(_ label: S, @ViewBuilder content: @escaping () -> Content) where S : StringProtocol {
fatalError()
self.init(content: content, label: { Text(label) })
}

@_disfavoredOverload public init<S>(_ label: S, isExpanded: Binding<Bool>, @ViewBuilder content: @escaping () -> Content) where S : StringProtocol {
Expand Down
Loading