diff --git a/Sources/UIKitComponents/Example/SelectTestView.swift b/Sources/UIKitComponents/Example/SelectTestView.swift index 3dbc7f7..4a9997c 100644 --- a/Sources/UIKitComponents/Example/SelectTestView.swift +++ b/Sources/UIKitComponents/Example/SelectTestView.swift @@ -15,7 +15,7 @@ struct SelectTestView: View { } var body: some View { - SelectView(title: "Пол", variants: variantds) + SelectView(title: "Пол", text: .constant(""), variants: variantds) } } diff --git a/Sources/UIKitComponents/Select/SelectView.swift b/Sources/UIKitComponents/Select/SelectView.swift index 1110f01..ce80d56 100644 --- a/Sources/UIKitComponents/Select/SelectView.swift +++ b/Sources/UIKitComponents/Select/SelectView.swift @@ -10,10 +10,12 @@ import SwiftUI public struct SelectView: View { @State var title: String + @Binding var text: String let variants: [String] - public init(title: String, variants: [String]) { + public init(title: String, text: Binding, variants: [String]) { self.title = title + self._text = text self.variants = variants } @@ -23,6 +25,7 @@ public struct SelectView: View { ForEach(variants, id: \.self) { variant in Button(variant) { title = variant + text = variant } } @@ -55,5 +58,5 @@ public struct SelectView: View { } #Preview { - SelectView(title: "Пол", variants: ["Male", "Female", "gay"]) + SelectView(title: "Пол", text: .constant(""), variants: ["Male", "Female", "gay"]) }