fix
This commit is contained in:
parent
55701d549c
commit
7a4584544b
@ -15,7 +15,7 @@ struct SelectTestView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
SelectView(title: "Пол", variants: variantds)
|
SelectView(title: "Пол", text: .constant(""), variants: variantds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,10 +10,12 @@ import SwiftUI
|
|||||||
public struct SelectView: View {
|
public struct SelectView: View {
|
||||||
|
|
||||||
@State var title: String
|
@State var title: String
|
||||||
|
@Binding var text: String
|
||||||
let variants: [String]
|
let variants: [String]
|
||||||
|
|
||||||
public init(title: String, variants: [String]) {
|
public init(title: String, text: Binding<String>, variants: [String]) {
|
||||||
self.title = title
|
self.title = title
|
||||||
|
self._text = text
|
||||||
self.variants = variants
|
self.variants = variants
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,6 +25,7 @@ public struct SelectView: View {
|
|||||||
ForEach(variants, id: \.self) { variant in
|
ForEach(variants, id: \.self) { variant in
|
||||||
Button(variant) {
|
Button(variant) {
|
||||||
title = variant
|
title = variant
|
||||||
|
text = variant
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,5 +58,5 @@ public struct SelectView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
SelectView(title: "Пол", variants: ["Male", "Female", "gay"])
|
SelectView(title: "Пол", text: .constant(""), variants: ["Male", "Female", "gay"])
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user