Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2020
PPL-C
DTB-Layanan Fasilitas Publik Penyandang Disabilitas
PoiPoLeGan-PPLapanganTembak-DTB Layanan Fasilitas Publik Penyandang Disabilitas-FE
Commits
b99c741d
Commit
b99c741d
authored
Mar 03, 2020
by
Usman Sidiq
Browse files
[GREEN] Passed validation test
parent
bc4f21c0
Pipeline
#33972
passed with stages
in 1 minute and 42 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/page/login/login.dart
View file @
b99c741d
...
...
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import
'package:ppl_disabilitas/config/styles.dart'
;
import
'package:ppl_disabilitas/utils/customButton.dart'
;
import
'package:ppl_disabilitas/utils/customTextField.dart'
;
import
'package:ppl_disabilitas/utils/validator.dart'
;
class
Login
extends
StatefulWidget
{
...
...
@@ -17,70 +18,79 @@ class LoginState extends State<Login> {
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'bisaGO'
),
centerTitle:
true
,
backgroundColor:
Color
(
0xff3A903A
),
),
body:
SingleChildScrollView
(
child:
Form
(
key:
_formKey
,
child:
Center
(
child:
Container
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
20.0
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
SizedBox
(
height:
25
),
Text
(
'Masuk ke Akun'
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
fontWeight:
FontWeight
.
bold
,
fontSize:
25
,
),
appBar:
AppBar
(
title:
Text
(
'bisaGO'
),
centerTitle:
true
,
backgroundColor:
Color
(
0xff3A903A
),
),
body:
SingleChildScrollView
(
child:
Form
(
key:
_formKey
,
child:
Center
(
child:
Container
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
20.0
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
SizedBox
(
height:
25
),
Text
(
'Masuk ke Akun'
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
fontWeight:
FontWeight
.
bold
,
fontSize:
25
,
),
),
SizedBox
(
height:
20
),
CustomTextField
(
title:
'Nomor Telepon atau Email'
,
key:
Key
(
'Text Field Akun'
),
onSaved:
(
input
)
{
_accountCredential
=
input
;
},
validator:
FieldValidator
.
validateEmail
,
),
CustomTextField
(
title:
'Password'
,
key:
Key
(
'Text Field Password'
),
obsecure:
true
,
onSaved:
(
input
)
{
_password
=
input
;
},
validator:
FieldValidator
.
validatePassword
,
),
Container
(
margin:
EdgeInsets
.
fromLTRB
(
0
,
30
,
0
,
10
),
alignment:
Alignment
.
center
,
child:
ButtonTheme
(
minWidth:
double
.
infinity
,
height:
40
,
child:
submitButton
(
'Masuk'
,
Color
(
0xff3A903A
),
Colors
.
white
,
Color
(
0xff3A903A
),
Colors
.
white
,
_validateLoginInput
),
)
),
Container
(
child:
separator
(
'Atau masuk dengan'
),
),
Container
(
margin:
EdgeInsets
.
fromLTRB
(
0
,
10
,
0
,
30
),
alignment:
Alignment
.
center
,
child:
googleButton
(),
),
],
),
SizedBox
(
height:
20
),
CustomTextField
(
title:
'Nomor Telepon atau Email'
,
key:
Key
(
'Text Field Akun'
),
onSaved:
(
input
)
{
_accountCredential
=
input
;
},
),
CustomTextField
(
title:
'Password'
,
key:
Key
(
'Text Field Password'
),
obsecure:
true
,
onSaved:
(
input
)
{
_password
=
input
;
},
),
Container
(
margin:
EdgeInsets
.
fromLTRB
(
0
,
30
,
0
,
10
),
alignment:
Alignment
.
center
,
child:
ButtonTheme
(
minWidth:
double
.
infinity
,
height:
40
,
child:
submitButton
(
'Masuk'
,
Color
(
0xff3A903A
),
Colors
.
white
,
Color
(
0xff3A903A
),
Colors
.
white
),
)
),
Container
(
child:
separator
(
'Atau masuk dengan'
),
),
Container
(
margin:
EdgeInsets
.
fromLTRB
(
0
,
10
,
0
,
30
),
alignment:
Alignment
.
center
,
child:
googleButton
(),
),
],
),
),
),
)
)
)
)
);
}
void
_validateLoginInput
()
async
{
final
FormState
form
=
_formKey
.
currentState
;
if
(
_formKey
.
currentState
.
validate
())
{
form
.
save
();
}
}
}
\ No newline at end of file
lib/page/registrasi/registrasi.dart
View file @
b99c741d
...
...
@@ -64,7 +64,7 @@ class RegistrasiState extends State<Registrasi> {
minWidth:
double
.
infinity
,
height:
40
,
child:
submitButton
(
'Daftar'
,
Color
(
0xff3A903A
),
Colors
.
white
,
Color
(
0xff3A903A
),
Colors
.
white
),
Color
(
0xff3A903A
),
Colors
.
white
,
_validateLoginInput
),
)
),
Container
(
...
...
@@ -83,4 +83,10 @@ class RegistrasiState extends State<Registrasi> {
),
);
}
void
_validateLoginInput
()
async
{
final
FormState
form
=
_formKey
.
currentState
;
if
(
_formKey
.
currentState
.
validate
())
{
form
.
save
();
}
}
}
\ No newline at end of file
lib/utils/customButton.dart
View file @
b99c741d
...
...
@@ -2,7 +2,7 @@ import 'package:flutter/cupertino.dart';
import
'package:flutter/material.dart'
;
Widget
submitButton
(
String
text
,
Color
splashColor
,
Color
highlightColor
,
Color
fillColor
,
Color
textColor
)
{
Color
fillColor
,
Color
textColor
,
void
function
()
)
{
return
RaisedButton
(
padding:
EdgeInsets
.
symmetric
(
vertical:
15
),
highlightElevation:
0.0
,
...
...
@@ -18,7 +18,7 @@ Color fillColor, Color textColor) {
style:
TextStyle
(
fontSize:
20
,
color:
textColor
,
fontWeight:
FontWeight
.
bold
),
),
onPressed:
()
{
function
();
},
);
}
...
...
lib/utils/validator.dart
View file @
b99c741d
class
FieldValidator
{
static
String
validateEmail
(
String
value
)
{
// TODO
Pattern
pattern
=
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'
;
RegExp
regex
=
new
RegExp
(
pattern
);
if
(
value
.
isEmpty
)
return
'*Wajib diisi'
;
if
(!
regex
.
hasMatch
(
value
))
return
'*Masukkan email yang valid'
;
else
return
null
;
}
static
String
validatePassword
(
String
value
)
{
// TODO
if
(
value
.
isEmpty
)
return
'*Wajib diisi'
;
if
(
value
.
length
<
7
)
return
'*Password harus lebih dari 6 karakter'
;
else
return
null
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment