Skip to content

Instantly share code, notes, and snippets.

@eviathan
Created June 10, 2019 00:01
Show Gist options
  • Save eviathan/417a66001f8a6545e1a06ce985f5d760 to your computer and use it in GitHub Desktop.
Save eviathan/417a66001f8a6545e1a06ce985f5d760 to your computer and use it in GitHub Desktop.
//
// ContentView.swift
// LearningSwiftUI
//
// Created by Brian on 08/06/2019.
// Copyright © 2019 Eviathan. All rights reserved.
//
import SwiftUI
struct MyTextField : View {
@State var text = ""
var placeholder = ""
var body: some View {
return TextField($text, placeholder: Text(placeholder))
.padding(12)
.background(Color.white)
.cornerRadius(4)
}
}
struct ContentView : View {
@State var firstName = ""
@State var lastName = ""
var body: some View {
VStack {
MyTextField(text: firstName, placeholder: "First Name")
MyTextField(text: lastName, placeholder: "Last Name")
}
.padding(12)
.lineSpacing(12)
.background(Color.gray)
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment