diff --git a/.gradle/6.1.1/executionHistory/executionHistory.lock b/.gradle/6.1.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000000000000000000000000000000000000..953495be948cfa66d148841288a5c1ab02567130 Binary files /dev/null and b/.gradle/6.1.1/executionHistory/executionHistory.lock differ diff --git a/lib/Component/bottom_navigation_bar.dart b/lib/Component/bottom_navigation_bar.dart index dcddcd1c6620c47fb491f99719a13833acee0ed1..30074a67a084abb8a69d78b67c8be133573074c4 100644 --- a/lib/Component/bottom_navigation_bar.dart +++ b/lib/Component/bottom_navigation_bar.dart @@ -132,10 +132,10 @@ class _BottomNavigationState extends State { ), title: Text('Home')), BottomNavigationBarItem( - icon: Icon(Icons.thumb_up), title: Text('Donasi saya')), + icon: Icon(Icons.archive), title: Text('Donasi saya')), BottomNavigationBarItem( icon: Icon( - Icons.shopping_cart, + Icons.receipt, ), title: Text('Belanja Saya')), BottomNavigationBarItem( diff --git a/lib/Component/custom_input_form.dart b/lib/Component/custom_input_form.dart index 1991b7c3795abf279564859fa06d77dfa6080952..3fd83f3caee9954d32c885683801bcdbc6929dc8 100644 --- a/lib/Component/custom_input_form.dart +++ b/lib/Component/custom_input_form.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -class CustomTextInputForm extends StatelessWidget { +class CustomTextInputForm extends StatefulWidget { 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 { + 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 ? [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, + ); + } } diff --git a/lib/Pages/Summary/summary_page.dart b/lib/Pages/Summary/summary_page.dart index 3fc9d082e0ade4fb3ef425ca6876b40007a2cdf3..8e0b21ddac610fcf8aafb1d49f570fb84b67ca79 100644 --- a/lib/Pages/Summary/summary_page.dart +++ b/lib/Pages/Summary/summary_page.dart @@ -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: customInputDecorationForm( + decoration: CustomInputDecoForm( 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: [ 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 diff --git a/local.properties b/local.properties index 50a99da160b87309e3cbba9681a63d2bc6ea5764..4309136addcceb22185d3c3852f75501a633559b 100644 --- a/local.properties +++ b/local.properties @@ -4,5 +4,5 @@ # Location of the SDK. This is only used by Gradle. # For customization when using a Version Control System, please read the # header note. -#Wed Dec 02 15:00:06 WIB 2020 -sdk.dir=/Users/sarahesperanti/Library/Android/sdk +#Mon Dec 21 18:21:08 WIB 2020 +sdk.dir=/Users/tsamaraesperanti/Library/Android/sdk diff --git a/test/bottom_navigation_bar_test.dart b/test/bottom_navigation_bar_test.dart index d2d4b838fbd2ae3824a12f7461075ab867779674..606d4cc45db17b5509aa6b79b7c91de4caba201e 100644 --- a/test/bottom_navigation_bar_test.dart +++ b/test/bottom_navigation_bar_test.dart @@ -140,7 +140,7 @@ void main() { testWidgets('Test initial to belanja saya loading', (WidgetTester tester) async { await tester.pumpWidget(testWidget); - await tester.tap(find.byIcon(Icons.shopping_cart).last); + await tester.tap(find.byIcon(Icons.receipt)); await tester.pumpAndSettle(); expect(find.text('Belanja Saya'), findsNWidgets(2)); });