Skip to content

Instantly share code, notes, and snippets.

@eviathan
Last active June 10, 2019 01:30
Show Gist options
  • Save eviathan/42b0961b3978d2f2221e103bbcb896cb to your computer and use it in GitHub Desktop.
Save eviathan/42b0961b3978d2f2221e103bbcb896cb 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(spacing: 12) {
MyTextField(text: firstName, placeholder: "First Name")
MyTextField(text: lastName, placeholder: "Last Name")
}
.padding(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