|
3 | 3 | // OpenSwiftUI |
4 | 4 | // |
5 | 5 | // Audited fror 6.5.4 |
6 | | -// Status: WIP |
| 6 | +// Status: Complete |
7 | 7 |
|
| 8 | +@_spi(ForOpenSwiftUIOnly) |
8 | 9 | import OpenSwiftUICore |
9 | 10 |
|
10 | 11 | @available(OpenSwiftUI_v4_0, *) |
@@ -33,23 +34,126 @@ public struct AutomaticLabeledContentStyle: LabeledContentStyle { |
33 | 34 | _openSwiftUIEmptyStub() |
34 | 35 | } |
35 | 36 |
|
36 | | - // FIXME: Blocked by StyleContextAcceptsPredicate |
37 | 37 | public func makeBody(configuration: AutomaticLabeledContentStyle.Configuration) -> some View { |
38 | | - HStack { |
| 38 | + #if os(iOS) || os(visionOS) |
| 39 | + LabeledContent { |
| 40 | + configuration.content |
| 41 | + .labeledContentStyle(self) |
| 42 | + } label: { |
39 | 43 | configuration.label |
| 44 | + .staticIf(LabelVisibilityConfigured.self) { label in |
| 45 | + labelsVisibility == .hidden ? nil : configuration.label |
| 46 | + } |
| 47 | + } |
| 48 | + .modifier( |
| 49 | + _LabeledContentStyleModifier(style: LeadingTrailingLabeledContentStyle_Phone()) |
| 50 | + .requiring(AnyListStyleContext.self) |
| 51 | + .requiring(LabeledContentUsesLegacyLayout.Inverted.self) |
| 52 | + ) |
| 53 | + .modifier( |
| 54 | + _LabeledContentStyleModifier(style: LeadingTrailingLabeledContentStyle(spacing: nil)) |
| 55 | + .requiring(AnyListStyleContext.self) |
| 56 | + .requiring(LabeledContentUsesLegacyLayout.self) |
| 57 | + ) |
| 58 | + .modifier( |
| 59 | + _LabeledContentStyleModifier(style: LeadingTrailingLabeledContentStyle(spacing: nil)) |
| 60 | + .requiring(GroupedFormStyleContext.self) |
| 61 | + ) |
| 62 | + .modifier( |
| 63 | + _LabeledContentStyleModifier(style: ColumnarLabeledContentStyle()) |
| 64 | + .requiring(ColumnsFormStyleContext.self) |
| 65 | + ) |
| 66 | + .modifier( |
| 67 | + _LabeledContentStyleModifier(style: AccessibilityLabeledContentStyle()) |
| 68 | + .requiring(AccessibilityRepresentableStyleContext.self) |
| 69 | + ) |
| 70 | + .labeledContentStyle(LeadingTrailingLabeledContentStyle(spacing: nil)) |
| 71 | + #elseif os(macOS) |
| 72 | + LabeledContent { |
40 | 73 | configuration.content |
| 74 | + .labeledContentStyle(self) |
| 75 | + } label: { |
| 76 | + configuration.label |
| 77 | + .staticIf(LabelVisibilityConfigured.self) { label in |
| 78 | + labelsVisibility == .hidden ? nil : configuration.label |
| 79 | + } |
| 80 | + } |
| 81 | + .modifier( |
| 82 | + _LabeledContentStyleModifier(style: LeadingTrailingLabeledContentStyle(spacing: nil)) //TODO |
| 83 | + .requiring(AnyListStyleContext.self) |
| 84 | + ) |
| 85 | + .modifier( |
| 86 | + _LabeledContentStyleModifier(style: FormBoxLabeledContentStyle()) |
| 87 | + .requiring(FormBoxStyleContext.self) |
| 88 | + ) |
| 89 | + .modifier( |
| 90 | + _LabeledContentStyleModifier(style: FormBoxLabeledContentStyle()) |
| 91 | + .requiring(GroupedFormValueStyleContext.self) |
| 92 | + ) |
| 93 | + .modifier( |
| 94 | + _LabeledContentStyleModifier(style: GroupedFormLabeledContentStyle()) |
| 95 | + .requiring(GroupedFormStyleContext.self) |
| 96 | + ) |
| 97 | + .modifier( |
| 98 | + _LabeledContentStyleModifier(style: ColumnarLabeledContentStyle()) |
| 99 | + .requiring(ColumnsFormStyleContext.self) |
| 100 | + ) |
| 101 | + .modifier( |
| 102 | + _LabeledContentStyleModifier(style: GroupedFormTextFieldLabeledContentStyle()) |
| 103 | + .requiring(GroupedFormTextFieldStyleContext.self) |
| 104 | + ) |
| 105 | + .modifier( |
| 106 | + _LabeledContentStyleModifier(style: ColumnarLabeledContentStyle()) |
| 107 | + .requiring(RadioGroupStyleContext.self) |
| 108 | + ) |
| 109 | + .modifier( |
| 110 | + _LabeledContentStyleModifier(style: ToolbarLabeledContentStyle()) |
| 111 | + .requiring(ToolbarStyleContext.self) |
| 112 | + ) |
| 113 | + .modifier( |
| 114 | + _LabeledContentStyleModifier(style: AccessibilityLabeledContentStyle()) |
| 115 | + .requiring(AccessibilityRepresentableStyleContext.self) |
| 116 | + ) |
| 117 | + .modifier( |
| 118 | + _LabeledContentStyleModifier(style: HStackLabeledContentStyle()) |
| 119 | + .requiring(InterfaceIdiomPredicate<MacInterfaceIdiom>.self) |
| 120 | + ) |
| 121 | + .labeledContentStyle(LeadingTrailingLabeledContentStyle(spacing: 2.0)) |
| 122 | + #else |
| 123 | + LabeledContent { |
| 124 | + configuration.content |
| 125 | + .labeledContentStyle(self) |
| 126 | + } label: { |
| 127 | + configuration.label |
| 128 | + .staticIf(LabelVisibilityConfigured.self) { label in |
| 129 | + labelsVisibility == .hidden ? nil : configuration.label |
| 130 | + } |
41 | 131 | } |
42 | | -// LabeledContent { |
43 | | -// configuration.content |
44 | | -// .labeledContentStyle(self) |
45 | | -// } label: { |
46 | | -// configuration.label |
47 | | -// .staticIf(LabelVisibilityConfigured.self) { label in |
48 | | -// labelsVisibility == .hidden ? nil : configuration.label |
49 | | -// } |
50 | | -// } |
| 132 | + .labeledContentStyle(LeadingTrailingLabeledContentStyle(spacing: nil)) |
| 133 | + #endif |
51 | 134 | } |
52 | 135 | } |
53 | 136 |
|
54 | 137 | @available(*, unavailable) |
55 | 138 | extension AutomaticLabeledContentStyle: Sendable {} |
| 139 | + |
| 140 | +#if os(macOS) |
| 141 | +// TODO |
| 142 | +struct HStackLabeledContentStyle: LabeledContentStyle { |
| 143 | + func makeBody(configuration: Configuration) -> some View { |
| 144 | + HStack { |
| 145 | + configuration.label |
| 146 | + .staticIf(_SemanticFeature_v4.self) { label in |
| 147 | + VStack(alignment: .leading){ |
| 148 | + LabelGroup { label } |
| 149 | + } |
| 150 | + } |
| 151 | + Spacer() |
| 152 | + HStack { |
| 153 | + configuration.content |
| 154 | + }.layoutPriority(-1) |
| 155 | + } |
| 156 | + .spacing(Spacing()) |
| 157 | + } |
| 158 | +} |
| 159 | +#endif |
0 commit comments