Created
March 16, 2023 17:43
-
-
Save tgnivekucn/20aaf0658be90c0ca22d521a3f7e61d0 to your computer and use it in GitHub Desktop.
SwiftUI login page generated by bing chatGPT
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
import SwiftUI | |
struct LoginView: View { | |
@State private var username = "" | |
@State private var password = "" | |
var body: some View { | |
VStack { | |
Image("logo") | |
.resizable() | |
.frame(width: 300, height: 300) | |
.padding(.top, 20) | |
TextField("Username", text: $username) | |
.padding() | |
.border(Color.gray, width: 1) | |
.padding(.horizontal, 20) | |
SecureField("Password", text: $password) | |
.padding() | |
.border(Color.gray, width: 1) | |
.padding(.horizontal, 20) | |
Button(action: login) { | |
Text("Login") | |
.foregroundColor(.white) | |
.padding() | |
.background(Color.blue) | |
.cornerRadius(10) | |
} | |
.padding(.horizontal, 20) | |
} | |
Spacer() | |
} | |
// Adjust the bottom padding according to the device | |
// For example, if the device has a safe area inset of 34 points at the bottom, | |
// then the bottom padding should be 100 - 34 = 66 | |
// You can use GeometryReader to get the safe area insets of the device | |
// https://developer.apple.com/documentation/swiftui/geometryreader | |
// Alternatively, you can use a library like https://github.com/nalexn/ViewInspector | |
// to get the exact frame of each view and calculate the padding accordingly | |
// For simplicity, I will just use a fixed value of 100 here | |
.padding(.bottom, 100) | |
} | |
func login() { | |
// Your login logic here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment