From 09eabb91eb3869c72d3558a739d10afacf52279e Mon Sep 17 00:00:00 2001 From: Moe Date: Fri, 29 Apr 2022 02:20:36 +0700 Subject: [PATCH] Cleanup code --- lib/components/checkout_form.dart | 11 +-- lib/components/checkout_items.dart | 5 +- lib/components/payment_body.dart | 106 ++++++++++++++--------------- lib/screens/checkout.dart | 2 +- 4 files changed, 56 insertions(+), 68 deletions(-) diff --git a/lib/components/checkout_form.dart b/lib/components/checkout_form.dart index 81eeda7..dd21e85 100644 --- a/lib/components/checkout_form.dart +++ b/lib/components/checkout_form.dart @@ -5,7 +5,7 @@ import 'package:nekoya_flutter/api/api.dart'; import 'package:nekoya_flutter/data/cart.dart'; class CheckoutForm extends StatefulWidget { - CheckoutForm({Key? key}) : super(key: key); + const CheckoutForm({Key? key}) : super(key: key); @override State createState() => _CheckoutFormState(); @@ -233,13 +233,8 @@ class _CheckoutFormState extends State { .fields["Shipping Method"]!.value, "data": cartData, }; - var statusCode = await checkoutPost(data); - - if (statusCode == 201) { - print("StatusCode" + statusCode.toString()); - } else { - print("StatusCode" + statusCode.toString()); - } + + await checkoutPost(data); } }, color: const Color(0xff8B0000), diff --git a/lib/components/checkout_items.dart b/lib/components/checkout_items.dart index 4ced287..5afd6d2 100644 --- a/lib/components/checkout_items.dart +++ b/lib/components/checkout_items.dart @@ -4,14 +4,13 @@ import 'package:nekoya_flutter/data/cart.dart'; import 'package:nekoya_flutter/components/cart_box.dart'; class CheckoutItems extends StatefulWidget { - CheckoutItems({Key? key}) : super(key: key); + const CheckoutItems({Key? key}) : super(key: key); @override State createState() => _CheckoutItemsState(); } class _CheckoutItemsState extends State { - Future _viewCart = viewCart(); @override Widget build(BuildContext context) { return Container( @@ -36,7 +35,7 @@ class _CheckoutItemsState extends State { ), ), FutureBuilder( - future: _viewCart, + future: viewCart(), builder: (context, snapshot) { if (snapshot.hasData) { var data = snapshot.data; diff --git a/lib/components/payment_body.dart b/lib/components/payment_body.dart index a77be13..99e54d7 100644 --- a/lib/components/payment_body.dart +++ b/lib/components/payment_body.dart @@ -41,29 +41,27 @@ class _PaymentBodyState extends State { ), ), Container( - padding: EdgeInsets.only(bottom: 20), + padding: const EdgeInsets.only(bottom: 20), child: ClipRRect( borderRadius: BorderRadius.circular(18), - child: Container( - child: ExpansionTile( - backgroundColor: Colors.blue, - collapsedBackgroundColor: Colors.blue.shade800, - textColor: Colors.white, - collapsedTextColor: Colors.white, - title: const Text('BCA'), - children: const [ - ListTile( - textColor: Colors.white, - title: Text( - '1. Login pada alamat Internet Banking BCA (***) \n2. Pilih menu Pembayaran Tagihan > Pembayaran \n3. Pada Ke Rekening masukkan Rekening perusahaan \n4. Masukkan Jumlah Nominal yang akan ditransfer \n5. Kemudian tekan send. Cetak/simpan stuck Transfer sebagai bukti pembayaran'), - ) - ], - ), + child: ExpansionTile( + backgroundColor: Colors.blue, + collapsedBackgroundColor: Colors.blue.shade800, + textColor: Colors.white, + collapsedTextColor: Colors.white, + title: const Text('BCA'), + children: const [ + ListTile( + textColor: Colors.white, + title: Text( + '1. Login pada alamat Internet Banking BCA (***) \n2. Pilih menu Pembayaran Tagihan > Pembayaran \n3. Pada Ke Rekening masukkan Rekening perusahaan \n4. Masukkan Jumlah Nominal yang akan ditransfer \n5. Kemudian tekan send. Cetak/simpan stuck Transfer sebagai bukti pembayaran'), + ) + ], ), ), ), Container( - padding: EdgeInsets.only(bottom: 20), + padding: const EdgeInsets.only(bottom: 20), child: ClipRRect( borderRadius: BorderRadius.circular(18), child: ExpansionTile( @@ -82,31 +80,29 @@ class _PaymentBodyState extends State { ), ), ), - Container( - child: ClipRRect( - borderRadius: BorderRadius.circular(18), - child: ExpansionTile( - backgroundColor: Colors.blue, - collapsedBackgroundColor: Colors.blue.shade800, - textColor: Colors.white, - collapsedTextColor: Colors.white, - title: const Text('BRI'), - children: const [ - ListTile( - textColor: Colors.white, - title: Text( - '1. Login pada alamat Internet Banking BRI (***)\n2. Pilih menu Pembayaran Tagihan > Pembayaran > Antar Rekening\n3. Pada Ke Rekening masukkan Rekening perusahaan\n4. Masukkan Jumlah Nominal yang akan ditransfer\n5. Kemudian tekan send. Cetak/simpan stuck Transfer sebagai bukti pembayaran'), - ) - ], - ), + ClipRRect( + borderRadius: BorderRadius.circular(18), + child: ExpansionTile( + backgroundColor: Colors.blue, + collapsedBackgroundColor: Colors.blue.shade800, + textColor: Colors.white, + collapsedTextColor: Colors.white, + title: const Text('BRI'), + children: const [ + ListTile( + textColor: Colors.white, + title: Text( + '1. Login pada alamat Internet Banking BRI (***)\n2. Pilih menu Pembayaran Tagihan > Pembayaran > Antar Rekening\n3. Pada Ke Rekening masukkan Rekening perusahaan\n4. Masukkan Jumlah Nominal yang akan ditransfer\n5. Kemudian tekan send. Cetak/simpan stuck Transfer sebagai bukti pembayaran'), + ) + ], ), ), Container( - padding: EdgeInsets.only(top: 40), + padding: const EdgeInsets.only(top: 40), color: Colors.transparent, ), Container( - child: Text( + child: const Text( '13000000', style: TextStyle( fontSize: 30, @@ -120,28 +116,26 @@ class _PaymentBodyState extends State { ), ), Container( - padding: EdgeInsets.only(top: 40), + padding: const EdgeInsets.only(top: 40), color: Colors.transparent, ), - Container( - child: ElevatedButton( - style: ButtonStyle( - foregroundColor: - MaterialStateProperty.all(Colors.red.shade800), - backgroundColor: - MaterialStateProperty.all(Colors.red.shade800), - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18.0), - side: BorderSide(color: Colors.red)))), - onPressed: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => Transactions())); - }, - child: Text( - 'Transaction', - style: TextStyle(color: Colors.white, fontSize: 25), - ), + ElevatedButton( + style: ButtonStyle( + foregroundColor: + MaterialStateProperty.all(Colors.red.shade800), + backgroundColor: + MaterialStateProperty.all(Colors.red.shade800), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(18.0), + side: const BorderSide(color: Colors.red)))), + onPressed: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => const Transactions())); + }, + child: const Text( + 'Transaction', + style: TextStyle(color: Colors.white, fontSize: 25), ), ), ], diff --git a/lib/screens/checkout.dart b/lib/screens/checkout.dart index 5ff5c28..2df041f 100644 --- a/lib/screens/checkout.dart +++ b/lib/screens/checkout.dart @@ -22,7 +22,7 @@ class _CheckoutState extends State { body: SafeArea( child: SingleChildScrollView( child: Column( - children: [ + children: const [ CheckoutItems(), CheckoutForm(), ],