Last active
July 27, 2020 23:18
-
-
Save p-larson/4fb2cf3cbba5936b544ed93864e586a2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// Aiden-1 | |
// | |
// Created by Peter Larson on 7/23/20. | |
// Copyright © 2020 Peter Larson. All rights reserved. | |
// | |
import SwiftUI | |
struct ContentView: View { | |
@State var nameInput = String() | |
@State var phoneInput = String() | |
@State var helpInput = String() | |
@State var hasSentForm = false | |
var body: some View { | |
ScrollView { | |
VStack(alignment: .leading) { | |
Text("What's wrong with my steak? HELP!!") | |
.font(.system(size: 24, weight: .heavy, design: .rounded)) | |
Image("image") | |
.resizable() | |
.scaledToFit() | |
.cornerRadius(4) | |
.colorInvert() | |
.brightness(0.25) | |
.hueRotation(.degrees(30)) | |
Text("Name".uppercased()) | |
.font(.headline) | |
TextField("Enter Text", text: $nameInput) | |
.padding() | |
.background(Color(#colorLiteral(red: 0.9424285889, green: 0.9424285889, blue: 0.9424285889, alpha: 1))) | |
.cornerRadius(4) | |
Text("Phone Number".uppercased()) | |
.font(.headline) | |
.keyboardType(.numberPad) | |
TextField("###-###-####", text: $phoneInput) | |
.padding() | |
.background(Color(#colorLiteral(red: 0.9424285889, green: 0.9424285889, blue: 0.9424285889, alpha: 1))) | |
.cornerRadius(4) | |
Text("What's wrong?".uppercased()) | |
.font(.headline) | |
TextField("Help ME!!!", text: $helpInput) | |
.padding() | |
.background(Color(#colorLiteral(red: 0.9424285889, green: 0.9424285889, blue: 0.9424285889, alpha: 1))) | |
.cornerRadius(4) | |
if !hasSentForm { | |
HStack { | |
Button(action: { | |
// Send the form somewhere. | |
// foo. | |
self.nameInput = "" | |
self.phoneInput = "" | |
self.helpInput = "" | |
}) { | |
Text("Clear") | |
.padding() | |
.foregroundColor(.white) | |
.background( | |
Color.red | |
.cornerRadius(4) | |
.brightness(0.25) | |
) | |
.animation(nil) | |
.frame(maxWidth: .infinity, alignment: .center) | |
.frame(height: 50) | |
} | |
Button(action: { | |
// Send the form somewhere. | |
// foo. | |
self.hasSentForm = true | |
}) { | |
Text("Send") | |
.padding() | |
.foregroundColor(.white) | |
.background( | |
Color.green | |
.cornerRadius(4) | |
.brightness(0.25) | |
) | |
.animation(nil) | |
.frame(maxWidth: .infinity, alignment: .center) | |
.frame(height: 50) | |
} | |
} | |
} else { | |
VStack { | |
Text("Sent!") | |
.italic() | |
.foregroundColor(.accentColor) | |
.frame(maxWidth: .infinity, alignment: .center) | |
.frame(height: 50) | |
Text([self.nameInput, self.phoneInput, self.helpInput].description) | |
} | |
.transition( | |
AnyTransition | |
.opacity | |
.animation(.easeInOut(duration: 0.3)) | |
) | |
} | |
} | |
.padding() | |
} | |
.statusBar(hidden: true) | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment