43 lines
822 B
Swift
43 lines
822 B
Swift
import SwiftUI
|
|
|
|
|
|
struct LabelledTextField: View {
|
|
|
|
private let label: LocalizedStringKey
|
|
|
|
private var value: Binding<String>
|
|
|
|
private let placeholder: LocalizedStringKey
|
|
|
|
|
|
init(_ label: LocalizedStringKey, _ value: Binding<String>, _ placeholder: LocalizedStringKey = "") {
|
|
self.label = label
|
|
|
|
self.value = value
|
|
|
|
self.placeholder = placeholder
|
|
}
|
|
|
|
|
|
var body: some View {
|
|
HStack {
|
|
Text(label)
|
|
|
|
Spacer()
|
|
|
|
TextField(placeholder, text: value)
|
|
.multilineTextAlignment(.trailing)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
struct LabelledTextField_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
LabelledTextField("Label", .constant("Value"))
|
|
}
|
|
|
|
}
|