diff --git a/node_modules/@expo/ui/ios/Picker/PickerView.swift b/node_modules/@expo/ui/ios/Picker/PickerView.swift index c78f278..80808ad 100644 --- a/node_modules/@expo/ui/ios/Picker/PickerView.swift +++ b/node_modules/@expo/ui/ios/Picker/PickerView.swift @@ -19,6 +19,16 @@ internal struct PickerView: ExpoSwiftUI.View { self.props = props } + private var selectionBinding: Binding { + if #available(iOS 26.0, *) { + return Binding( + get: { Self.getHashableFromEither(props.selection) }, + set: { newValue in emitSelection(newValue) } + ) + } + return $selection + } + @ViewBuilder private func makePicker() -> some View { let content = props.children?.slot("content") @@ -26,11 +36,11 @@ internal struct PickerView: ExpoSwiftUI.View { let labelContent = props.children?.slot("label") if let systemImage = props.systemImage, let label = props.label { - Picker(label, systemImage: systemImage, selection: $selection) { content } + Picker(label, systemImage: systemImage, selection: selectionBinding) { content } } else if let labelContent { - Picker(selection: $selection) { content } label: { labelContent } + Picker(selection: selectionBinding) { content } label: { labelContent } } else if let label = props.label { - Picker(label, selection: $selection, content: { content }) + Picker(label, selection: selectionBinding, content: { content }) } } @@ -41,15 +51,7 @@ internal struct PickerView: ExpoSwiftUI.View { .onChange(of: selection) { newValue in guard let newValue, newValue != previousSelection else { return } previousSelection = newValue - let payload: [String: Any] - if let stringValue = newValue as? String { - payload = ["selection": stringValue] - } else if let doubleValue = newValue as? Double { - payload = ["selection": doubleValue] - } else { - return - } - props.onSelectionChange(payload) + emitSelection(newValue) } .onChange(of: props.selection) { newValue in let newSelection = Self.getHashableFromEither(newValue) @@ -63,6 +65,18 @@ internal struct PickerView: ExpoSwiftUI.View { } } + private func emitSelection(_ newValue: AnyHashable?) { + let payload: [String: Any] + if let stringValue = newValue as? String { + payload = ["selection": stringValue] + } else if let doubleValue = newValue as? Double { + payload = ["selection": doubleValue] + } else { + return + } + props.onSelectionChange(payload) + } + private static func getHashableFromEither(_ either: Either?) -> AnyHashable? { guard let either else { return nil } if let stringValue: String = either.get() {