-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLoginPageView.swift
102 lines (90 loc) · 3.44 KB
/
LoginPageView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// WelcomePageView.swift
// MobileAcebook
//
// Created by Josué Estévez Fernández on 30/09/2023.
//
import SwiftUI
struct LoginPageView: View {
@State private var username = ""
@State private var password = ""
@State var isShowingPassword: Bool = false
var body: some View {
NavigationView {
VStack {
Spacer()
Text("Log in")
.font(.largeTitle)
.bold()
Spacer()
VStack {
Text("Username") .frame(maxWidth: 250, alignment: .topLeading)
TextField("", text: $username)
.frame(width: 250, height: 40)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray)
)
.multilineTextAlignment(.center)
.autocapitalization(. none)
.accessibilityIdentifier("loginUsername")
}.padding()
VStack {
Text("Password")
.frame(maxWidth: 250, alignment: .topLeading)
Group {
if isShowingPassword {
TextField("", text: $password)
.frame(width: 250, height: 40)
.multilineTextAlignment(.center)
.overlay(RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray))
}else {
SecureField("", text: $password)
.frame(width: 250, height: 40)
.multilineTextAlignment(.center)
.overlay(RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray))
}
}
.disableAutocorrection(true)
.autocapitalization(.none)
Button {
isShowingPassword.toggle()
} label: {
if isShowingPassword {
Text("Hide password")
} else {
Text("Show password")
}
}.padding()
}
Button("Submit") {
guard !username.isEmpty && !password.isEmpty else { return }
}
.frame(width: 250, height: 40)
.background(Color(red: 0x50/255, green: 0xB7/255, blue: 0xB7/255))
.foregroundColor(.white)
.cornerRadius(10)
.padding()
Spacer()
Spacer()
Spacer()
HStack(spacing:3){
Text("Don't have an account?")
NavigationLink(destination: SignUpPageView()){
Text("Sign up here")
.fontWeight(.bold)
}
//add navigation to login
}
.padding()
}
}
}
}
struct LoginPageView_Previews: PreviewProvider {
static var previews: some View {
LoginPageView()
}
}