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> {
return TextFormField(
initialValue: widget.initialValue,
decoration:
customInputDecorationForm(context, widget.label, widget.prefixText, widget.prefixIcon),
obscureText: widget.isPassword == true ? _obscureText : false,
customInputDecorationForm(context,
widget.label, widget.prefixText, widget.prefixIcon),
obscureText: widget.isPassword && _obscureText,
onFieldSubmitted: widget.onSubmit,
onSaved: widget.onSave,
maxLength: widget.maxLength,
......
......@@ -103,7 +103,6 @@ class _ListItemBank extends StatelessWidget {
margin: const EdgeInsets.symmetric(vertical: 5),
child: Material(
type: MaterialType.card,
shadowColor: Colors.black,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0))),
elevation: 1,
......
......@@ -36,7 +36,6 @@ class CartView extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
flex: 3,
......@@ -135,7 +134,6 @@ class _KeranjangBody extends StatelessWidget {
class _ItemBody extends StatelessWidget {
final CartItem item;
static const int int64MaxValue = 9223372036854775807;
const _ItemBody({Key key, @required this.item}) : super(key: key);
@override
Widget build(BuildContext context) {
......@@ -156,9 +154,7 @@ class _ItemBody extends StatelessWidget {
(create: (_) => CounterItem(
total: item.quantity,
minimum: 0,
maksimum: item.product.preOrder
? int64MaxValue
: item.product.stock),
maksimum: item.product.stock),
child: _CartDescription(cartItem: item)),
),
),
......@@ -187,7 +183,6 @@ class _CartDescription extends StatelessWidget {
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
'${cartItem.product.name}',
......@@ -201,7 +196,6 @@ class _CartDescription extends StatelessWidget {
PriceTextFormatter(
price: '${cartItem.product.price}',
),
if (cartItem.product.preOrder) const Text('Preorder')
],
),
Column(
......@@ -222,7 +216,7 @@ class _CartDescription extends StatelessWidget {
color: Theme.of(context).primaryColor,
shape: BoxShape.circle,
),
margin: EdgeInsets.symmetric(vertical: 3.0),
margin: const EdgeInsets.symmetric(vertical: 3.0),
child: const Icon(Icons.delete_forever,
color: Colors.white,),
),
......@@ -249,7 +243,9 @@ class _CartDescription extends StatelessWidget {
key: ValueKey<int>(cartItem.quantity),
text: TextSpan(
text: 'Jumlah: ',
style: const TextStyle(color: Colors.black, fontSize: 15),
style:
const TextStyle(color: Colors.black,
fontSize: 15),
children: <TextSpan>[
TextSpan(
text: '${cartItem.quantity}',
......@@ -265,7 +261,8 @@ class _CartDescription extends StatelessWidget {
child: PriceTextFormatter(
key: ValueKey<int>(cartItem.quantity),
price:
'${double.parse(cartItem.product.price) * cartItem.quantity}',
'${double.parse(cartItem.product.price)
* cartItem.quantity}',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w800,
......@@ -320,7 +317,6 @@ class _CartDescription extends StatelessWidget {
class _ModalCartItem extends StatelessWidget {
final CartItem cartItem;
static const int int64MaxValue = 9223372036854775807;
const _ModalCartItem({Key key, @required this.cartItem})
: assert(cartItem != null),
......@@ -331,9 +327,7 @@ class _ModalCartItem extends StatelessWidget {
create: (_) => CounterItem(
total: cartItem.quantity,
minimum: 0,
maksimum: cartItem.product.preOrder
? int64MaxValue
: cartItem.product.stock),
maksimum: cartItem.product.stock),
child: Builder(
builder: (BuildContext context) {
return Padding(
......@@ -385,9 +379,7 @@ class _ModalCartItem extends StatelessWidget {
fontSize: 20),
),
Text(
cartItem.product.preOrder
? 'Preorder'
: 'Stok: '
'Stok: '
'${cartItem.product.stock}',
style: const TextStyle(fontSize: 17),
)
......@@ -406,7 +398,7 @@ class _ModalCartItem extends StatelessWidget {
decoration: ShapeDecoration(
color: Theme.of(context)
.primaryColor,
shape: CircleBorder(),
shape: const CircleBorder(),
),
child: IconButton(
icon: const Icon(Icons.remove),
......@@ -430,7 +422,7 @@ class _ModalCartItem extends StatelessWidget {
decoration: ShapeDecoration(
color: Theme.of(context)
.primaryColor,
shape: CircleBorder(),
shape: const CircleBorder(),
),
child: IconButton(
icon: const Icon(Icons.add),
......
......@@ -10,7 +10,9 @@ import 'goods_donation_state.dart';
class GoodsDonationBloc extends Bloc<GoodsDonationEvent, GoodsDonationState> {
final DonationRepository _donationRepository;
GoodsDonationBloc(this._donationRepository, this._changeBottomNavigationBarBloc);
GoodsDonationBloc(
this._donationRepository,
this._changeBottomNavigationBarBloc);
final ChangeBottomNavigationBarBloc _changeBottomNavigationBarBloc;
@override
......
......@@ -9,7 +9,9 @@ import 'money_donation_state.dart';
class MoneyDonationBloc extends Bloc<DonationEvent, MoneyDonationState> {
final DonationRepository _donationRepository;
MoneyDonationBloc(this._donationRepository, this._changeBottomNavigationBarBloc);
MoneyDonationBloc(
this._donationRepository,
this._changeBottomNavigationBarBloc);
final ChangeBottomNavigationBarBloc _changeBottomNavigationBarBloc;
@override
......
......@@ -112,8 +112,10 @@ class __ChooseDonationState extends State<_ChooseDonation> {
child: Center(
child: Text(
'OK',
style: Theme.of(context).textTheme.bodyText1.copyWith(
fontSize: 18, color: const Color.fromRGBO(60, 141, 188, 1)),
style: Theme.of(context).
textTheme.bodyText1.copyWith(
fontSize: 18, color:
const Color.fromRGBO(60, 141, 188, 1)),
),
)),
],
......
......@@ -97,15 +97,20 @@ class _DonasiBarangState extends State<DonasiBarang> {
.copyWith(fontSize: 18),
),
Container(
margin: const EdgeInsets.only(top: 10),
margin: const EdgeInsets.only(top: 10, bottom: 20),
width: MediaQuery.of(context).size.width,
child: Text(
'Silakan isi detil barang yang ingin didonasikan',
'Silakan isi detil barang yang ingin didonasikan.',
style: Theme.of(context)
.textTheme
.bodyText2
.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> {
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
..._getGoodsForm(),
Row(
......@@ -151,11 +155,13 @@ class _DonasiBarangState extends State<DonasiBarang> {
),
const SizedBox(width: 70),
Container(
width: MediaQuery.of(context).size.width / 1.8,
width: MediaQuery.
of(context).size.width / 2,
height: 80,
color: Colors.white,
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
padding: const
EdgeInsets.only(top: 8.0),
child: TextFormField(
controller: addressController,
keyboardType:
......@@ -179,7 +185,7 @@ class _DonasiBarangState extends State<DonasiBarang> {
style: Theme.of(context)
.textTheme
.bodyText2
.copyWith(fontSize: 18),
.copyWith(fontSize: 16),
),
Radio(
key: const Key('DLV-button'),
......@@ -198,7 +204,7 @@ class _DonasiBarangState extends State<DonasiBarang> {
style: Theme.of(context)
.textTheme
.bodyText2
.copyWith(fontSize: 18),
.copyWith(fontSize: 16),
),
],
),
......@@ -229,8 +235,6 @@ class _DonasiBarangState extends State<DonasiBarang> {
}
if (_formKey.currentState.validate()) {
_formKey.currentState.save();
print(goodsDescList);
print(goodsQtyList);
for (var i = 0; i < goodsDescList.length; i++) {
if (i == goodsDescList.length-1) {
isFinal = true;
......@@ -328,14 +332,18 @@ class GoodsForm extends StatefulWidget {
}
class _GoodsFormState extends State<GoodsForm> {
final TextEditingController _goodsDescriptionController = TextEditingController();
final TextEditingController _goodsQuantityController = TextEditingController();
final TextEditingController
_goodsDescriptionController = TextEditingController();
final TextEditingController
_goodsQuantityController = TextEditingController();
@override
Widget build(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
_goodsDescriptionController.text = _DonasiBarangState.goodsDescList[widget.index] ?? '';
_goodsQuantityController.text = _DonasiBarangState.goodsQtyList[widget.index] ?? '';
_goodsDescriptionController.text =
_DonasiBarangState.goodsDescList[widget.index] ?? '';
_goodsQuantityController.text =
_DonasiBarangState.goodsQtyList[widget.index] ?? '';
});
return Column(
......@@ -362,11 +370,12 @@ class _GoodsFormState extends State<GoodsForm> {
),
const SizedBox(width: 20),
Container(
width: MediaQuery.of(context).size.width / 1.8,
width: MediaQuery.of(context).size.width / 2,
height: 50,
child: TextFormField(
key: const Key('goods-desc'),
onChanged: (v) => _DonasiBarangState.goodsDescList[widget.index] = v,
onChanged: (v) =>
_DonasiBarangState.goodsDescList[widget.index] = v,
controller: _goodsDescriptionController,
validator: (value) {
return value.isEmpty
......@@ -402,12 +411,13 @@ class _GoodsFormState extends State<GoodsForm> {
),
const SizedBox(width: 70),
Container(
width: MediaQuery.of(context).size.width / 1.8,
width: MediaQuery.of(context).size.width / 2,
height: 50,
color: Colors.white,
child: TextFormField(
key: const Key('goods-qty'),
onChanged: (v) => _DonasiBarangState.goodsQtyList[widget.index] = v,
onChanged: (v) =>
_DonasiBarangState.goodsQtyList[widget.index] = v,
controller: _goodsQuantityController,
validator: (value) {
return value.isEmpty
......
......@@ -24,9 +24,15 @@ class DonationRepository {
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;
methodOfDelivery == 'DLV' ? deliveryAddress = null : deliveryAddress = address;
methodOfDelivery == 'DLV' ?
deliveryAddress = null : deliveryAddress = address;
final formData = FormData.fromMap({
'program': program,
'donation_type': 'GDS',
......
......@@ -178,7 +178,10 @@ class _DonationDetaiDialog extends StatelessWidget {
child: Wrap(children: [
const Icon(Icons.clear, size: 22.0, key: Key('clear-icon'),),
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,),
......@@ -210,11 +213,9 @@ class _DonationListItem extends StatelessWidget {
Expanded(
flex: 15,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
......@@ -283,7 +284,6 @@ class _DonationListItem extends StatelessWidget {
flex: 11,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
donation.donationStatus.readable,
......@@ -295,7 +295,8 @@ class _DonationListItem extends StatelessWidget {
fontWeight: FontWeight.w600,
fontSize: 15),
),
if (donation.donationType == 'CSH' && (donation.donationStatus ==
if (donation.donationType == 'CSH' &&
(donation.donationStatus ==
StatusDonation.waitAdminConfirmation ||
donation.donationStatus == StatusDonation.waitProofAgain))
FlatButton(
......
......@@ -83,7 +83,6 @@ class _DonationReUploadState extends State<DonationReUpload> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
height: 40,
......
......@@ -15,7 +15,6 @@ class Home extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: const <Widget>[
HomeProfilePlaceholder(),
HomePlaceHolder(
......@@ -71,11 +70,10 @@ class HomeProfile extends StatelessWidget {
padding: const EdgeInsets.only(bottom: 12),
width: double.maxFinite,
decoration: BoxDecoration(
border: Border.all(color: Colors.black, width: 1.2),
border: Border.all(width: 1.2),
borderRadius: BorderRadius.circular(10),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
const Text('SELAMAT DATANG',
......@@ -128,7 +126,7 @@ class HomePlaceHolder extends StatelessWidget {
image:
DecorationImage(image: AssetImage(image), fit: BoxFit.cover),
color: Colors.white,
border: Border.all(color: Colors.black, width: 1.2),
border: Border.all(width: 1.2),
borderRadius: BorderRadius.circular(10),
),
),
......
......@@ -57,17 +57,16 @@ class OTPPage extends StatelessWidget {
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const Text('Mohon masukkan OTP yang dikirim ke nomor anda',
softWrap: true),
const Divider(
height: 20,
thickness: null,
),
Theme(
data: Theme.of(context)
.copyWith(inputDecorationTheme: const InputDecorationTheme()),
.copyWith(inputDecorationTheme:
const InputDecorationTheme()),
child: PinPut(
onSubmit: (String pin) {
_otpSubmitted(pin, context);
......
......@@ -12,7 +12,8 @@ abstract class SearchProductState extends Equatable {
}
class InitialSearchProductState extends SearchProductState {
const InitialSearchProductState({hasReachedMax}) : super(0, '', hasReachedMax: true);
const InitialSearchProductState({hasReachedMax}) :
super(0, '', hasReachedMax: true);
@override
List<Object> get props => [page, searchQuery];
......
......@@ -118,8 +118,8 @@ class ProductGrid extends StatelessWidget {
borderRadius: BorderRadius.circular(8),
color: Colors.white,
boxShadow: [
BoxShadow(
offset: const Offset(2, 0),
const BoxShadow(
offset: Offset(2, 0),
color: Colors.black38,
blurRadius: 10,
spreadRadius: 0.5),
......@@ -157,7 +157,6 @@ class ProductGrid extends StatelessWidget {
PriceTextFormatter(
price: _product.price,
),
if (_product.preOrder) const Text('Preorder')
],
),
),
......@@ -171,7 +170,7 @@ class ProductGrid extends StatelessWidget {
BlocProvider.of<CartBloc>(context)
.add(AddCartItem(1, _product.id));
},
icon: Icon(
icon: const Icon(
Icons.add_shopping_cart,
),
alignment: Alignment.bottomCenter,
......
......@@ -96,7 +96,7 @@ class _ProductDescription extends StatelessWidget {
),
),
Text(
product.preOrder ? 'Preorder' : 'Stock: ${product.stock}',
'Stock: ${product.stock}',
style: const TextStyle(
fontSize: 15,
color: Colors.black54,
......@@ -113,7 +113,7 @@ class _ProductDescription extends StatelessWidget {
BlocProvider.of<CartBloc>(context)
.add(AddCartItem(1, product.id));
},
icon: Icon(Icons.add_shopping_cart),
icon: const Icon(Icons.add_shopping_cart),
label: Text(product.stock == 0 ? 'Habis' : 'Tambah'),
color: Theme.of(context).primaryColor,
textColor: const Color(0xff003636),
......
......@@ -75,7 +75,7 @@ class _SliverAppBarProductState extends State<SliverAppBarProduct> {
shape: const CircleBorder(),
),
child: IconButton(
icon: Icon(Icons.arrow_back),
icon: const Icon(Icons.arrow_back),
onPressed: () {
Navigator.of(context).pop();
},
......@@ -83,7 +83,7 @@ class _SliverAppBarProductState extends State<SliverAppBarProduct> {
),
),
secondChild: IconButton(
icon: Icon(Icons.arrow_back),
icon: const Icon(Icons.arrow_back),
onPressed: () {
Navigator.of(context).pop();
},
......@@ -92,9 +92,7 @@ class _SliverAppBarProductState extends State<SliverAppBarProduct> {
isFirst ? CrossFadeState.showFirst : CrossFadeState.showSecond,
),
),
floating: false,
pinned: true,
snap: false,
backgroundColor: Colors.white,
title: AnimatedCrossFade(
duration: duration,
......@@ -109,7 +107,7 @@ class _SliverAppBarProductState extends State<SliverAppBarProduct> {
'${widget.label}',
maxLines: 2,
textAlign: TextAlign.center,
style: TextStyle(color: Colors.black),
style: const TextStyle(color: Colors.black),
),
),
secondChild: Container(
......@@ -119,7 +117,7 @@ class _SliverAppBarProductState extends State<SliverAppBarProduct> {
'${widget.label}',
maxLines: 2,
textAlign: TextAlign.center,
style: TextStyle(color: Colors.black),
style: const TextStyle(color: Colors.black),
),
),
crossFadeState:
......
......@@ -40,7 +40,6 @@ class _BodyDetailProduct extends StatelessWidget {
}) : super(key: key);
final Product product;
static const int int64MaxValue = 9223372036854775807;
@override
Widget build(BuildContext context) {
......@@ -48,7 +47,7 @@ class _BodyDetailProduct extends StatelessWidget {
create: (context) => CounterItem(
total: 1,
minimum: 1,
maksimum: product.preOrder ? int64MaxValue : product.stock),
maksimum: product.stock),
child: Builder(
builder: (BuildContext context) {
return LayoutBuilder(
......@@ -105,9 +104,7 @@ class _BodyDetailProduct extends StatelessWidget {
fontSize: 20),
),
Text(
product.preOrder
? 'Preorder'
: 'Stok: ${product.stock}',
'Stok: ${product.stock}',
style:
const TextStyle(fontSize: 17),
)
......@@ -115,7 +112,7 @@ class _BodyDetailProduct extends StatelessWidget {
),
),
Expanded(
flex: 5,
flex: 3,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
......@@ -127,10 +124,12 @@ class _BodyDetailProduct extends StatelessWidget {
ShapeDecoration(
color: Theme.of(context)
.primaryColor,
shape: CircleBorder(),
shape: const CircleBorder(),
),
child: IconButton(
icon: const Icon(Icons.remove),
icon:
const Icon
(Icons.remove),
onPressed: () {
context
.read<CounterItem>()
......@@ -151,7 +150,7 @@ class _BodyDetailProduct extends StatelessWidget {
decoration: ShapeDecoration(
color: Theme.of(context)
.primaryColor,
shape: CircleBorder(),
shape: const CircleBorder(),
),
child: IconButton(
icon: const Icon(Icons.add),
......
......@@ -18,14 +18,11 @@ class Product extends Equatable {
@JsonKey(nullable: true)
final int stock;
final bool preOrder;
@JsonKey(nullable: true)
final String image;
const Product(
{this.id,
this.preOrder,
this.name,
this.category,
this.categoryName,
......@@ -52,6 +49,5 @@ class Product extends Equatable {
price,