Created
June 10, 2019 00:01
-
-
Save eviathan/417a66001f8a6545e1a06ce985f5d760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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