Advertisement
GiulianoAccorsi

Untitled

Mar 7th, 2023
1,245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 3.50 KB | Source Code | 0 0
  1. //
  2. //  ChallengeLogin.swift
  3. //  MyFirstApp
  4. //
  5. //  Created by Giuliano Accorsi on 07/03/23.
  6. //
  7.  
  8. import SwiftUI
  9.  
  10. struct Login {
  11.     var username: String
  12.     var password: String
  13.     var isShowAlert = false
  14.     var isShowSheet = false
  15. }
  16.  
  17. struct ChallengeLogin: View {
  18.     @State var login = Login(username: "", password: "", isShowAlert: false, isShowSheet: false)
  19.  
  20.     var body: some View {
  21.         ZStack {
  22.             Color
  23.                 .black
  24.                 .ignoresSafeArea(edges: .all)
  25.             VStack {
  26.                 Image("irmandade")
  27.                     .resizable()
  28.                     .aspectRatio(contentMode: .fit)
  29.                     .frame(width: 200)
  30.                     .padding()
  31.                 HStack {
  32.                     VStack(alignment: .leading, spacing: -20) {
  33.                         Text("irmandade")
  34.                             .foregroundColor(.white)
  35.                             .font(.system(size: 20, weight: .thin, design: .rounded))
  36.                         Text("swift")
  37.                             .foregroundColor(.white)
  38.                             .font(.system(size: 100, weight: .bold, design: .rounded))
  39.                         Spacer()
  40.                     }
  41.                     Spacer()
  42.                 }
  43.                 .padding()
  44.                 Form {
  45.                     Section {
  46.                         TextField("Digite seu nome", text: $login.username)
  47.                         SecureField("Digite sua senha", text: $login.password)
  48.                     }
  49.                 }.preferredColorScheme(.dark)
  50.  
  51.                 Button(action: {
  52.                     if login.username == "Giu" && login.password == "123" {
  53.                         login.isShowSheet.toggle()
  54.                     }else {
  55.                         login.isShowAlert.toggle()
  56.                     }
  57.                 }) {
  58.                     Text("Entrar")
  59.                         .font(.system(size: 15, weight: .light, design: .rounded))
  60.                         .foregroundColor(.black)
  61.                         .frame(width: 300, height: 40)
  62.                         .background(Color.white)
  63.                         .cornerRadius(10)
  64.                 }
  65.                 .offset(y: -30)
  66.                 .alert("Usuário e/ou Senha Inválido", isPresented: $login.isShowAlert) {
  67.                     Button("OK") {
  68.                         login.isShowAlert.toggle()
  69.                     }
  70.                 }
  71.                 .sheet(isPresented: $login.isShowSheet) {
  72.                     ZStack {
  73.                         Color
  74.                             .black
  75.                             .ignoresSafeArea(edges: .all)
  76.                         HStack(spacing: 50) {
  77.                             VStack {
  78.                                 Text("BEM VINDO,\nGIU")
  79.                                     .font(.system(size: 50, weight: .bold, design: .rounded))
  80.                                 Capsule()
  81.                                     .foregroundColor(.orange)
  82.                                     .frame(minWidth: 0, maxWidth: 128, minHeight: 10, maxHeight: 10)
  83.                             }
  84.                             Text("👊🏻")
  85.                                 .font(.system(size: 80, weight: .bold, design: .rounded))
  86.                         }
  87.                         .padding()
  88.                     }
  89.                 }
  90.             }
  91.         }
  92.     }
  93. }
  94.  
  95.  
  96. struct ChallengeLogin_Previews: PreviewProvider {
  97.     static var previews: some View {
  98.         ChallengeLogin()
  99.     }
  100. }
  101.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement