Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ChallengeLogin.swift
- // MyFirstApp
- //
- // Created by Giuliano Accorsi on 07/03/23.
- //
- import SwiftUI
- struct Login {
- var username: String
- var password: String
- var isShowAlert = false
- var isShowSheet = false
- }
- struct ChallengeLogin: View {
- @State var login = Login(username: "", password: "", isShowAlert: false, isShowSheet: false)
- var body: some View {
- ZStack {
- Color
- .black
- .ignoresSafeArea(edges: .all)
- VStack {
- Image("irmandade")
- .resizable()
- .aspectRatio(contentMode: .fit)
- .frame(width: 200)
- .padding()
- HStack {
- VStack(alignment: .leading, spacing: -20) {
- Text("irmandade")
- .foregroundColor(.white)
- .font(.system(size: 20, weight: .thin, design: .rounded))
- Text("swift")
- .foregroundColor(.white)
- .font(.system(size: 100, weight: .bold, design: .rounded))
- Spacer()
- }
- Spacer()
- }
- .padding()
- Form {
- Section {
- TextField("Digite seu nome", text: $login.username)
- SecureField("Digite sua senha", text: $login.password)
- }
- }.preferredColorScheme(.dark)
- Button(action: {
- if login.username == "Giu" && login.password == "123" {
- login.isShowSheet.toggle()
- }else {
- login.isShowAlert.toggle()
- }
- }) {
- Text("Entrar")
- .font(.system(size: 15, weight: .light, design: .rounded))
- .foregroundColor(.black)
- .frame(width: 300, height: 40)
- .background(Color.white)
- .cornerRadius(10)
- }
- .offset(y: -30)
- .alert("Usuário e/ou Senha Inválido", isPresented: $login.isShowAlert) {
- Button("OK") {
- login.isShowAlert.toggle()
- }
- }
- .sheet(isPresented: $login.isShowSheet) {
- ZStack {
- Color
- .black
- .ignoresSafeArea(edges: .all)
- HStack(spacing: 50) {
- VStack {
- Text("BEM VINDO,\nGIU")
- .font(.system(size: 50, weight: .bold, design: .rounded))
- Capsule()
- .foregroundColor(.orange)
- .frame(minWidth: 0, maxWidth: 128, minHeight: 10, maxHeight: 10)
- }
- Text("👊🏻")
- .font(.system(size: 80, weight: .bold, design: .rounded))
- }
- .padding()
- }
- }
- }
- }
- }
- }
- struct ChallengeLogin_Previews: PreviewProvider {
- static var previews: some View {
- ChallengeLogin()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement