-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIdentificationView.qml
168 lines (138 loc) · 4.03 KB
/
IdentificationView.qml
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import QtQuick 2.9
import QtQuick.Window 2.12
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.3
import QtGraphicalEffects 1.0
import QtQuick.Layouts 1.3
import Qt.labs.settings 1.0
import Models 1.0
Item {
property var nameWindow: 'Identification'
id:root
anchors.fill: parent
property var stack
property var toolbar
//signal identificationSuccess(string user, string email);
function formValidation(){
let hasErros = false;
if(userField.text.trim().length == 0){
//error msg
userFieldError.text = 'Usuario vazio'
hasErros = true;
}else{
//Limpa erro
userFieldError.text = '';
}
if(emailField.text.trim().length == 0){
//error msg
emailFieldError.text = 'Email vazio'
hasErros = true;
}else{
//Limpa erro
emailFieldError.text = '';
}
return !hasErros;
}
Settings {
id: settings
property alias user: userField.text
property alias email: emailField.text
property alias lembrar: lembrarCheck.checked
}
Component.onCompleted: {
if(settings.lembrar){
userField.text = settings.user;
emailField.text = settings.email;
lembrarCheck.checked = settings.lembrar
}else{
userField.text = '';
emailField.text = '';
}
}
ColumnLayout{
//anchors.fill: parent
function calcWidth(){
if(parent.width <= 350){
return 250;
}else {
return 300;
}
}
anchors.centerIn: parent
width: calcWidth()
ColumnLayout{
//anchors.centerIn: parent
spacing: 10
ColumnLayout{
Layout.fillWidth: true
Layout.alignment: Layout.Center
Image{
id:img
Layout.fillWidth: true
sourceSize.width: 60
sourceSize.height: 60
source: 'icons/icon-app.png'
fillMode: Image.PreserveAspectFit
smooth: true
visible: false
}
DropShadow{
anchors.fill:img
Layout.alignment: Layout.Center
horizontalOffset: 3
verticalOffset: 3
radius: 8.0
samples: 17
color: "#40000000"
source:img
}
}
TextField{
id:userField
Layout.fillWidth: true
placeholderText: 'Usuario'
onTextEdited: {
userFieldError.text = ''
}
}
Label{
id:userFieldError
color:'red'
visible: userFieldError.text.trim().length > 0
text: ''
}
TextField{
id:emailField
Layout.fillWidth: true
placeholderText: 'Email'
onTextEdited: {
emailFieldError.text = ''
}
}
Label{
id:emailFieldError
color:'red'
visible: emailFieldError.text.trim().length > 0
text: ''
}
CheckBox{
id:lembrarCheck
checked: false
font.pixelSize: 12
text: 'Lembrar'
}
}
Button{
Layout.fillWidth: true
text: 'Entrar'
onPressed: {
console.log(settings.email)
if(formValidation()){
userModel.setNome(1, userField.text);
userModel.setEmail(1, emailField.text);
stack.push('HomeView.qml')
}
}
}
}
}