Fakultas Ilmu Komputer UI

Commit 838b6cc4 authored by Tsamara Esperanti Erwin's avatar Tsamara Esperanti Erwin 🦄
Browse files

Bugfixing

parent c1386020
...@@ -48,8 +48,9 @@ class _CustomTextInputFormState extends State<CustomTextInputForm> { ...@@ -48,8 +48,9 @@ class _CustomTextInputFormState extends State<CustomTextInputForm> {
return TextFormField( return TextFormField(
initialValue: widget.initialValue, initialValue: widget.initialValue,
decoration: decoration:
customInputDecorationForm(context, widget.label, widget.prefixText, widget.prefixIcon), customInputDecorationForm(context,
obscureText: widget.isPassword == true ? _obscureText : false, widget.label, widget.prefixText, widget.prefixIcon),
obscureText: widget.isPassword && _obscureText,
onFieldSubmitted: widget.onSubmit, onFieldSubmitted: widget.onSubmit,
onSaved: widget.onSave, onSaved: widget.onSave,
maxLength: widget.maxLength, maxLength: widget.maxLength,
......
...@@ -103,7 +103,6 @@ class _ListItemBank extends StatelessWidget { ...@@ -103,7 +103,6 @@ class _ListItemBank extends StatelessWidget {
margin: const EdgeInsets.symmetric(vertical: 5), margin: const EdgeInsets.symmetric(vertical: 5),
child: Material( child: Material(
type: MaterialType.card, type: MaterialType.card,
shadowColor: Colors.black,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0))), borderRadius: BorderRadius.all(Radius.circular(4.0))),
elevation: 1, elevation: 1,
......
...@@ -36,7 +36,6 @@ class CartView extends StatelessWidget { ...@@ -36,7 +36,6 @@ class CartView extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
flex: 3, flex: 3,
...@@ -135,7 +134,6 @@ class _KeranjangBody extends StatelessWidget { ...@@ -135,7 +134,6 @@ class _KeranjangBody extends StatelessWidget {
class _ItemBody extends StatelessWidget { class _ItemBody extends StatelessWidget {
final CartItem item; final CartItem item;
static const int int64MaxValue = 9223372036854775807;
const _ItemBody({Key key, @required this.item}) : super(key: key); const _ItemBody({Key key, @required this.item}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -156,9 +154,7 @@ class _ItemBody extends StatelessWidget { ...@@ -156,9 +154,7 @@ class _ItemBody extends StatelessWidget {
(create: (_) => CounterItem( (create: (_) => CounterItem(
total: item.quantity, total: item.quantity,
minimum: 0, minimum: 0,
maksimum: item.product.preOrder maksimum: item.product.stock),
? int64MaxValue
: item.product.stock),
child: _CartDescription(cartItem: item)), child: _CartDescription(cartItem: item)),
), ),
), ),
...@@ -187,7 +183,6 @@ class _CartDescription extends StatelessWidget { ...@@ -187,7 +183,6 @@ class _CartDescription extends StatelessWidget {
children: [ children: [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
'${cartItem.product.name}', '${cartItem.product.name}',
...@@ -201,7 +196,6 @@ class _CartDescription extends StatelessWidget { ...@@ -201,7 +196,6 @@ class _CartDescription extends StatelessWidget {
PriceTextFormatter( PriceTextFormatter(
price: '${cartItem.product.price}', price: '${cartItem.product.price}',
), ),
if (cartItem.product.preOrder) const Text('Preorder')
], ],
), ),
Column( Column(
...@@ -222,7 +216,7 @@ class _CartDescription extends StatelessWidget { ...@@ -222,7 +216,7 @@ class _CartDescription extends StatelessWidget {
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
shape: BoxShape.circle, shape: BoxShape.circle,
), ),
margin: EdgeInsets.symmetric(vertical: 3.0), margin: const EdgeInsets.symmetric(vertical: 3.0),
child: const Icon(Icons.delete_forever, child: const Icon(Icons.delete_forever,
color: Colors.white,), color: Colors.white,),
), ),
...@@ -249,7 +243,9 @@ class _CartDescription extends StatelessWidget { ...@@ -249,7 +243,9 @@ class _CartDescription extends StatelessWidget {
key: ValueKey<int>(cartItem.quantity), key: ValueKey<int>(cartItem.quantity),
text: TextSpan( text: TextSpan(
text: 'Jumlah: ', text: 'Jumlah: ',
style: const TextStyle(color: Colors.black, fontSize: 15), style:
const TextStyle(color: Colors.black,
fontSize: 15),
children: <TextSpan>[ children: <TextSpan>[
TextSpan( TextSpan(
text: '${cartItem.quantity}', text: '${cartItem.quantity}',
...@@ -265,7 +261,8 @@ class _CartDescription extends StatelessWidget { ...@@ -265,7 +261,8 @@ class _CartDescription extends StatelessWidget {
child: PriceTextFormatter( child: PriceTextFormatter(
key: ValueKey<int>(cartItem.quantity), key: ValueKey<int>(cartItem.quantity),
price: price:
'${double.parse(cartItem.product.price) * cartItem.quantity}', '${double.parse(cartItem.product.price)
* cartItem.quantity}',
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
...@@ -320,7 +317,6 @@ class _CartDescription extends StatelessWidget { ...@@ -320,7 +317,6 @@ class _CartDescription extends StatelessWidget {
class _ModalCartItem extends StatelessWidget { class _ModalCartItem extends StatelessWidget {
final CartItem cartItem; final CartItem cartItem;
static const int int64MaxValue = 9223372036854775807;
const _ModalCartItem({Key key, @required this.cartItem}) const _ModalCartItem({Key key, @required this.cartItem})
: assert(cartItem != null), : assert(cartItem != null),
...@@ -331,9 +327,7 @@ class _ModalCartItem extends StatelessWidget { ...@@ -331,9 +327,7 @@ class _ModalCartItem extends StatelessWidget {
create: (_) => CounterItem( create: (_) => CounterItem(
total: cartItem.quantity, total: cartItem.quantity,
minimum: 0, minimum: 0,
maksimum: cartItem.product.preOrder maksimum: cartItem.product.stock),
? int64MaxValue
: cartItem.product.stock),
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return Padding( return Padding(
...@@ -385,9 +379,7 @@ class _ModalCartItem extends StatelessWidget { ...@@ -385,9 +379,7 @@ class _ModalCartItem extends StatelessWidget {
fontSize: 20), fontSize: 20),
), ),
Text( Text(
cartItem.product.preOrder 'Stok: '
? 'Preorder'
: 'Stok: '
'${cartItem.product.stock}', '${cartItem.product.stock}',
style: const TextStyle(fontSize: 17), style: const TextStyle(fontSize: 17),
) )
...@@ -406,7 +398,7 @@ class _ModalCartItem extends StatelessWidget { ...@@ -406,7 +398,7 @@ class _ModalCartItem extends StatelessWidget {
decoration: ShapeDecoration( decoration: ShapeDecoration(
color: Theme.of(context) color: Theme.of(context)
.primaryColor, .primaryColor,
shape: CircleBorder(), shape: const CircleBorder(),
), ),
child: IconButton( child: IconButton(
icon: const Icon(Icons.remove), icon: const Icon(Icons.remove),
...@@ -430,7 +422,7 @@ class _ModalCartItem extends StatelessWidget { ...@@ -430,7 +422,7 @@ class _ModalCartItem extends StatelessWidget {
decoration: ShapeDecoration( decoration: ShapeDecoration(
color: Theme.of(context) color: Theme.of(context)
.primaryColor, .primaryColor,
shape: CircleBorder(), shape: const CircleBorder(),
), ),
child: IconButton( child: IconButton(
icon: const Icon(Icons.add), icon: const Icon(Icons.add),
......
...@@ -10,7 +10,9 @@ import 'goods_donation_state.dart'; ...@@ -10,7 +10,9 @@ import 'goods_donation_state.dart';
class GoodsDonationBloc extends Bloc<GoodsDonationEvent, GoodsDonationState> { class GoodsDonationBloc extends Bloc<GoodsDonationEvent, GoodsDonationState> {
final DonationRepository _donationRepository; final DonationRepository _donationRepository;
GoodsDonationBloc(this._donationRepository, this._changeBottomNavigationBarBloc); GoodsDonationBloc(
this._donationRepository,
this._changeBottomNavigationBarBloc);
final ChangeBottomNavigationBarBloc _changeBottomNavigationBarBloc; final ChangeBottomNavigationBarBloc _changeBottomNavigationBarBloc;
@override @override
......
...@@ -9,7 +9,9 @@ import 'money_donation_state.dart'; ...@@ -9,7 +9,9 @@ import 'money_donation_state.dart';
class MoneyDonationBloc extends Bloc<DonationEvent, MoneyDonationState> { class MoneyDonationBloc extends Bloc<DonationEvent, MoneyDonationState> {
final DonationRepository _donationRepository; final DonationRepository _donationRepository;
MoneyDonationBloc(this._donationRepository, this._changeBottomNavigationBarBloc); MoneyDonationBloc(
this._donationRepository,
this._changeBottomNavigationBarBloc);
final ChangeBottomNavigationBarBloc _changeBottomNavigationBarBloc; final ChangeBottomNavigationBarBloc _changeBottomNavigationBarBloc;
@override @override
......
...@@ -112,8 +112,10 @@ class __ChooseDonationState extends State<_ChooseDonation> { ...@@ -112,8 +112,10 @@ class __ChooseDonationState extends State<_ChooseDonation> {
child: Center( child: Center(
child: Text( child: Text(
'OK', 'OK',
style: Theme.of(context).textTheme.bodyText1.copyWith( style: Theme.of(context).
fontSize: 18, color: const Color.fromRGBO(60, 141, 188, 1)), textTheme.bodyText1.copyWith(
fontSize: 18, color:
const Color.fromRGBO(60, 141, 188, 1)),
), ),
)), )),
], ],
......
...@@ -97,15 +97,20 @@ class _DonasiBarangState extends State<DonasiBarang> { ...@@ -97,15 +97,20 @@ class _DonasiBarangState extends State<DonasiBarang> {
.copyWith(fontSize: 18), .copyWith(fontSize: 18),
), ),
Container( Container(
margin: const EdgeInsets.only(top: 10), margin: const EdgeInsets.only(top: 10, bottom: 20),
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: Text( child: Text(
'Silakan isi detil barang yang ingin didonasikan', 'Silakan isi detil barang yang ingin didonasikan.',
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.bodyText2 .bodyText2
.copyWith(fontSize: 18), .copyWith(fontSize: 18),
)), )),
Text('Tekan lambang + untuk menambah barang.',
style: Theme.of(context)
.textTheme
.bodyText2
.copyWith(fontSize: 10, color: Colors.black54),)
], ],
), ),
), ),
...@@ -114,7 +119,6 @@ class _DonasiBarangState extends State<DonasiBarang> { ...@@ -114,7 +119,6 @@ class _DonasiBarangState extends State<DonasiBarang> {
child: Form( child: Form(
key: _formKey, key: _formKey,
child: Column( child: Column(
mainAxisSize: MainAxisSize.max,
children: [ children: [
..._getGoodsForm(), ..._getGoodsForm(),
Row( Row(
...@@ -151,11 +155,13 @@ class _DonasiBarangState extends State<DonasiBarang> { ...@@ -151,11 +155,13 @@ class _DonasiBarangState extends State<DonasiBarang> {
), ),
const SizedBox(width: 70), const SizedBox(width: 70),
Container( Container(
width: MediaQuery.of(context).size.width / 1.8, width: MediaQuery.
of(context).size.width / 2,
height: 80, height: 80,
color: Colors.white, color: Colors.white,
child: Padding( child: Padding(
padding: const EdgeInsets.only(top: 8.0), padding: const
EdgeInsets.only(top: 8.0),
child: TextFormField( child: TextFormField(
controller: addressController, controller: addressController,
keyboardType: keyboardType:
...@@ -179,7 +185,7 @@ class _DonasiBarangState extends State<DonasiBarang> { ...@@ -179,7 +185,7 @@ class _DonasiBarangState extends State<DonasiBarang> {
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.bodyText2 .bodyText2
.copyWith(fontSize: 18), .copyWith(fontSize: 16),
), ),
Radio( Radio(
key: const Key('DLV-button'), key: const Key('DLV-button'),
...@@ -198,7 +204,7 @@ class _DonasiBarangState extends State<DonasiBarang> { ...@@ -198,7 +204,7 @@ class _DonasiBarangState extends State<DonasiBarang> {
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.bodyText2 .bodyText2
.copyWith(fontSize: 18), .copyWith(fontSize: 16),
), ),
], ],
), ),
...@@ -229,8 +235,6 @@ class _DonasiBarangState extends State<DonasiBarang> { ...@@ -229,8 +235,6 @@ class _DonasiBarangState extends State<DonasiBarang> {
} }
if (_formKey.currentState.validate()) { if (_formKey.currentState.validate()) {
_formKey.currentState.save(); _formKey.currentState.save();
print(goodsDescList);
print(goodsQtyList);
for (var i = 0; i < goodsDescList.length; i++) { for (var i = 0; i < goodsDescList.length; i++) {
if (i == goodsDescList.length-1) { if (i == goodsDescList.length-1) {
isFinal = true; isFinal = true;
...@@ -328,14 +332,18 @@ class GoodsForm extends StatefulWidget { ...@@ -328,14 +332,18 @@ class GoodsForm extends StatefulWidget {
} }
class _GoodsFormState extends State<GoodsForm> { class _GoodsFormState extends State<GoodsForm> {
final TextEditingController _goodsDescriptionController = TextEditingController(); final TextEditingController
final TextEditingController _goodsQuantityController = TextEditingController(); _goodsDescriptionController = TextEditingController();
final TextEditingController
_goodsQuantityController = TextEditingController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
_goodsDescriptionController.text = _DonasiBarangState.goodsDescList[widget.index] ?? ''; _goodsDescriptionController.text =
_goodsQuantityController.text = _DonasiBarangState.goodsQtyList[widget.index] ?? ''; _DonasiBarangState.goodsDescList[widget.index] ?? '';
_goodsQuantityController.text =
_DonasiBarangState.goodsQtyList[widget.index] ?? '';
}); });
return Column( return Column(
...@@ -362,11 +370,12 @@ class _GoodsFormState extends State<GoodsForm> { ...@@ -362,11 +370,12 @@ class _GoodsFormState extends State<GoodsForm> {
), ),
const SizedBox(width: 20), const SizedBox(width: 20),
Container( Container(
width: MediaQuery.of(context).size.width / 1.8, width: MediaQuery.of(context).size.width / 2,
height: 50, height: 50,
child: TextFormField( child: TextFormField(
key: const Key('goods-desc'), key: const Key('goods-desc'),
onChanged: (v) => _DonasiBarangState.goodsDescList[widget.index] = v, onChanged: (v) =>
_DonasiBarangState.goodsDescList[widget.index] = v,
controller: _goodsDescriptionController, controller: _goodsDescriptionController,
validator: (value) { validator: (value) {
return value.isEmpty return value.isEmpty
...@@ -402,12 +411,13 @@ class _GoodsFormState extends State<GoodsForm> { ...@@ -402,12 +411,13 @@ class _GoodsFormState extends State<GoodsForm> {
), ),
const SizedBox(width: 70), const SizedBox(width: 70),
Container( Container(
width: MediaQuery.of(context).size.width / 1.8, width: MediaQuery.of(context).size.width / 2,
height: 50, height: 50,
color: Colors.white, color: Colors.white,
child: TextFormField( child: TextFormField(
key: const Key('goods-qty'), key: const Key('goods-qty'),
onChanged: (v) => _DonasiBarangState.goodsQtyList[widget.index] = v, onChanged: (v) =>
_DonasiBarangState.goodsQtyList[widget.index] = v,
controller: _goodsQuantityController, controller: _goodsQuantityController,
validator: (value) { validator: (value) {
return value.isEmpty return value.isEmpty
......
...@@ -24,9 +24,15 @@ class DonationRepository { ...@@ -24,9 +24,15 @@ class DonationRepository {
await _dio.post(url, data: formData); await _dio.post(url, data: formData);
} }
Future<void> createGoodsDonation(String program, String quantity, String description, String address, String methodOfDelivery) async { Future<void> createGoodsDonation(
String program, String quantity,
String description, String address,
String methodOfDelivery) async {
String deliveryAddress; String deliveryAddress;
methodOfDelivery == 'DLV' ? deliveryAddress = null : deliveryAddress = address;
methodOfDelivery == 'DLV' ?
deliveryAddress = null : deliveryAddress = address;
final formData = FormData.fromMap({ final formData = FormData.fromMap({
'program': program, 'program': program,
'donation_type': 'GDS', 'donation_type': 'GDS',
......
...@@ -178,7 +178,10 @@ class _DonationDetaiDialog extends StatelessWidget { ...@@ -178,7 +178,10 @@ class _DonationDetaiDialog extends StatelessWidget {
child: Wrap(children: [ child: Wrap(children: [
const Icon(Icons.clear, size: 22.0, key: Key('clear-icon'),), const Icon(Icons.clear, size: 22.0, key: Key('clear-icon'),),
Text('Detail Donasi - ${donation.donationNumber}', Text('Detail Donasi - ${donation.donationNumber}',
style: TextStyle(fontSize: 16.0, height: 1.3, fontWeight: FontWeight.bold),) style: const
TextStyle(fontSize: 16.0,
height: 1.3,
fontWeight: FontWeight.bold),)
],), ],),
), ),
const SizedBox(height: 10.0,), const SizedBox(height: 10.0,),
...@@ -210,11 +213,9 @@ class _DonationListItem extends StatelessWidget { ...@@ -210,11 +213,9 @@ class _DonationListItem extends StatelessWidget {
Expanded( Expanded(
flex: 15, flex: 15,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[ children: <Widget>[
Column( Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Text( Text(
...@@ -283,7 +284,6 @@ class _DonationListItem extends StatelessWidget { ...@@ -283,7 +284,6 @@ class _DonationListItem extends StatelessWidget {
flex: 11, flex: 11,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Text( Text(
donation.donationStatus.readable, donation.donationStatus.readable,
...@@ -295,7 +295,8 @@ class _DonationListItem extends StatelessWidget { ...@@ -295,7 +295,8 @@ class _DonationListItem extends StatelessWidget {
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontSize: 15), fontSize: 15),
), ),
if (donation.donationType == 'CSH' && (donation.donationStatus == if (donation.donationType == 'CSH' &&
(donation.donationStatus ==
StatusDonation.waitAdminConfirmation || StatusDonation.waitAdminConfirmation ||
donation.donationStatus == StatusDonation.waitProofAgain)) donation.donationStatus == StatusDonation.waitProofAgain))
FlatButton( FlatButton(
......
...@@ -83,7 +83,6 @@ class _DonationReUploadState extends State<DonationReUpload> { ...@@ -83,7 +83,6 @@ class _DonationReUploadState extends State<DonationReUpload> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( Container(
height: 40, height: 40,
......
...@@ -15,7 +15,6 @@ class Home extends StatelessWidget { ...@@ -15,7 +15,6 @@ class Home extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: const <Widget>[ children: const <Widget>[
HomeProfilePlaceholder(), HomeProfilePlaceholder(),
HomePlaceHolder( HomePlaceHolder(
...@@ -71,11 +70,10 @@ class HomeProfile extends StatelessWidget { ...@@ -71,11 +70,10 @@ class HomeProfile extends StatelessWidget {
padding: const EdgeInsets.only(bottom: 12), padding: const EdgeInsets.only(bottom: 12),
width: double.maxFinite, width: double.maxFinite,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.black, width: 1.2), border: Border.all(width: 1.2),
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ children: <Widget>[
const Text('SELAMAT DATANG', const Text('SELAMAT DATANG',
...@@ -128,7 +126,7 @@ class HomePlaceHolder extends StatelessWidget { ...@@ -128,7 +126,7 @@ class HomePlaceHolder extends StatelessWidget {
image: image:
DecorationImage(image: AssetImage(image), fit: BoxFit.cover), DecorationImage(image: AssetImage(image), fit: BoxFit.cover),
color: Colors.white, color: Colors.white,
border: Border.all(color: Colors.black, width: 1.2), border: Border.all(width: 1.2),
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
), ),
......