Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
PPL Sosial
pilar
pilar-mobile
Commits
2bce63d6
Commit
2bce63d6
authored
Dec 22, 2020
by
Tsamara Esperanti Erwin
Browse files
[REFACTOR] View password
parent
cbdf1d53
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/Component/custom_input_form.dart
View file @
2bce63d6
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
class
CustomTextInputForm
extends
State
less
Widget
{
class
CustomTextInputForm
extends
State
ful
Widget
{
final
String
label
;
final
bool
isPassword
;
final
Function
onSave
;
...
...
@@ -15,58 +15,79 @@ class CustomTextInputForm extends StatelessWidget {
const
CustomTextInputForm
(
{
Key
key
,
@required
this
.
label
,
this
.
isPassword
=
false
,
@required
this
.
onSave
,
this
.
isNumberOnly
=
false
,
this
.
prefixText
,
this
.
maxLength
,
@required
this
.
prefixIcon
,
this
.
initialValue
,
this
.
onSubmit
,
this
.
textInputAction
})
@required
this
.
label
,
this
.
isPassword
=
false
,
@required
this
.
onSave
,
this
.
isNumberOnly
=
false
,
this
.
prefixText
,
this
.
maxLength
,
@required
this
.
prefixIcon
,
this
.
initialValue
,
this
.
onSubmit
,
this
.
textInputAction
})
:
assert
(
label
!=
null
),
assert
(
onSave
!=
null
),
assert
(
prefixIcon
!=
null
),
super
(
key:
key
);
@override
_CustomTextInputFormState
createState
()
=
>
_CustomTextInputFormState
();
}
class
_CustomTextInputFormState
extends
State
<
CustomTextInputForm
>
{
bool
_obscureText
=
true
;
void
togglePassword
()
{
setState
(()
{
_obscureText
=
!
_obscureText
;
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
TextFormField
(
initialValue:
initialValue
,
initialValue:
widget
.
initialValue
,
decoration:
customInputDecorationForm
(
context
,
label
,
prefixText
,
prefixIcon
),
obscureText:
isPassword
,
onFieldSubmitted:
onSubmit
,
onSaved:
onSave
,
maxLength:
maxLength
,
textInputAction:
textInputAction
,
keyboardType:
isNumberOnly
?
TextInputType
.
number
:
null
,
inputFormatters:
isNumberOnly
customInputDecorationForm
(
context
,
widget
.
label
,
widget
.
prefixText
,
widget
.
prefixIcon
),
obscureText:
widget
.
isPassword
==
true
?
_obscureText
:
false
,
onFieldSubmitted:
widget
.
onSubmit
,
onSaved:
widget
.
onSave
,
maxLength:
widget
.
maxLength
,
textInputAction:
widget
.
textInputAction
,
keyboardType:
widget
.
isNumberOnly
?
TextInputType
.
number
:
null
,
inputFormatters:
widget
.
isNumberOnly
?
<
TextInputFormatter
>[
WhitelistingTextInputFormatter
.
digitsOnly
]
:
null
,
validator:
(
value
)
{
if
(
value
.
isEmpty
)
{
return
'Masukkan
${label.toLowerCase()}
'
;
}
else
if
(
isPassword
&&
value
.
length
<
8
)
{
return
'Masukkan
${
widget.
label.toLowerCase()}
'
;
}
else
if
(
widget
.
isPassword
&&
value
.
length
<
8
)
{
return
'Panjang password minimal 8'
;
}
else
if
(
prefixText
==
'+62'
&&
value
.
length
<
=
8
)
{
}
else
if
(
widget
.
prefixText
==
'+62'
&&
value
.
length
<
=
8
)
{
return
'Masukkan nomor telepon yang benar'
;
}
return
null
;
},
);
}
}
InputDecoration
customInputDecorationForm
(
BuildContext
context
,
String
label
,
String
prefix
,
IconData
prefixIcon
)
{
return
InputDecoration
(
prefixText:
prefix
,
labelText:
label
,
prefixIcon:
Icon
(
prefixIcon
,
color:
Theme
.
of
(
context
)
.
primaryColor
,
),
);
InputDecoration
customInputDecorationForm
(
BuildContext
context
,
String
label
,
String
prefix
,
IconData
prefixIcon
)
{
return
InputDecoration
(
prefixText:
prefix
,
labelText:
label
,
prefixIcon:
Icon
(
prefixIcon
,
color:
Theme
.
of
(
context
)
.
primaryColor
,
),
suffixIcon:
label
==
'Password'
?
GestureDetector
(
onTap:
togglePassword
,
child:
Icon
(
Icons
.
remove_red_eye
,
color:
Theme
.
of
(
context
)
.
primaryColor
,
),
)
:
null
,
);
}
}
lib/Pages/Summary/summary_page.dart
View file @
2bce63d6
...
...
@@ -4,7 +4,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import
'package:flutter_easyloading/flutter_easyloading.dart'
;
import
'package:home_industry/Component/blue_button.dart'
;
import
'package:home_industry/Component/custom_circular.dart'
;
import
'package:home_industry/Component/custom_input_form.dart'
;
import
'package:home_industry/Component/price_text_formatter.dart'
;
import
'package:home_industry/Component/router.dart'
;
import
'package:home_industry/Pages/Cart/model/cart_entity.dart'
;
...
...
@@ -461,7 +460,7 @@ class _Donation extends StatelessWidget {
padding:
const
EdgeInsets
.
only
(
top:
10
,
left:
10
),
child:
TextField
(
controller:
textEditingController
,
decoration:
c
ustomInputDeco
ration
Form
(
decoration:
C
ustomInputDecoForm
(
context
,
'Donasi'
,
null
,
Icons
.
people_outline
),
scrollPadding:
const
EdgeInsets
.
only
(
bottom:
80
),
scrollPhysics:
const
BouncingScrollPhysics
(),
...
...
@@ -616,13 +615,22 @@ class _ItemCart extends StatelessWidget {
overflow:
TextOverflow
.
ellipsis
,
text:
TextSpan
(
text:
cartItem
.
product
.
name
,
style:
Theme
.
of
(
context
)
.
textTheme
.
headline6
.
copyWith
(
fontSize:
18
,
color:
Theme
.
of
(
context
)
.
primaryColor
),
style:
Theme
.
of
(
context
)
.
textTheme
.
headline6
.
copyWith
(
fontSize:
18
,
color:
Theme
.
of
(
context
)
.
primaryColor
),
children:
<
TextSpan
>[
if
(
cartItem
.
product
.
preOrder
)
TextSpan
(
text:
' - preorder'
,
style:
Theme
.
of
(
context
)
.
textTheme
.
subtitle1
)
style:
Theme
.
of
(
context
)
.
textTheme
.
subtitle1
)
])),
trailing:
PriceTextFormatter
(
price:
'
${cartItem.quantity * double.parse(cartItem.product.price)}
'
,
...
...
@@ -649,3 +657,17 @@ class _ItemCart extends StatelessWidget {
);
}
}
InputDecoration
CustomInputDecoForm
(
BuildContext
context
,
String
label
,
String
prefix
,
IconData
prefixIcon
)
{
return
InputDecoration
(
prefixText:
prefix
,
labelText:
label
,
prefixIcon:
Icon
(
prefixIcon
,
color:
Theme
.
of
(
context
)
.
primaryColor
,
),
);
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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