|
8 | 8 | "options": [ "One", "Two", "Three" ] // Required. Two supported formats: |
9 | 9 | // 1. With simple array of strings we have titles only. Tags are automatically "1", "2", "3"... (1-based index as String) |
10 | 10 | // 2. With array of dictionaries we have explicit control: [{"title": "Sure Thing", "tag": "yes"}, {"title": "Absolutely Not", "tag": "no"}] |
11 | | - "pickerStyle": "menu", // Optional: "menu" (iOS/macOS/visionOS), "segmented" (iOS/macOS/visionOS), "wheel" (iOS/visionOS only); no default |
| 11 | + "pickerStyle": "menu", // Optional: "menu" (iOS/macOS/visionOS), "segmented" (iOS/macOS/visionOS), "wheel" (iOS/visionOS only), "radioGroup" (macOS only); no default |
| 12 | + "horizontalRadioGroupLayout": false, // Optional: Bool, applies .horizontalRadioGroupLayout() when pickerStyle is "radioGroup" (macOS only); defaults to false |
12 | 13 | "actionID": "picker.selection", // Optional: String for action triggered on user-initiated selection change (inherited from View) |
13 | 14 | } |
14 | 15 | // Note: actionID is triggered via onChange for user-initiated changes. Baseline View properties (padding, hidden, foregroundColor, font, background, frame, opacity, cornerRadius, disabled, etc.) are inherited and applied via ActionUIRegistry.shared.applyModifiers. |
@@ -71,7 +72,7 @@ struct Picker: ActionUIViewConstruction { |
71 | 72 |
|
72 | 73 | // Validate pickerStyle |
73 | 74 | #if os(macOS) |
74 | | - let validStyles = ["menu", "segmented"] |
| 75 | + let validStyles = ["menu", "segmented", "radioGroup"] |
75 | 76 | #else |
76 | 77 | let validStyles = ["menu", "segmented", "wheel"] |
77 | 78 | #endif |
@@ -140,6 +141,15 @@ struct Picker: ActionUIViewConstruction { |
140 | 141 | modifiedView = modifiedView.pickerStyle(.menu) |
141 | 142 | case "segmented": |
142 | 143 | modifiedView = modifiedView.pickerStyle(.segmented) |
| 144 | + case "radioGroup": |
| 145 | +#if os(macOS) |
| 146 | + modifiedView = modifiedView.pickerStyle(.radioGroup) |
| 147 | + if properties["horizontalRadioGroupLayout"] as? Bool == true { |
| 148 | + modifiedView = modifiedView.horizontalRadioGroupLayout() |
| 149 | + } |
| 150 | +#else |
| 151 | + logger.log("radioGroup PickerStyle unavailable on this platform; ignoring", .warning) |
| 152 | +#endif |
143 | 153 | default: |
144 | 154 | break // Should not reach here due to validateProperties |
145 | 155 | } |
|
0 commit comments