Fakultas Ilmu Komputer UI

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

Merge branch 'bugfixing' into 'staging'

Bugfixing

See merge request !101
parents 0d8f75b1 8647d12f
...@@ -117,7 +117,7 @@ class __MyDonationsState extends State<_MyDonations> { ...@@ -117,7 +117,7 @@ class __MyDonationsState extends State<_MyDonations> {
? const Center( ? const Center(
child: CustomCircularIndicator(), child: CustomCircularIndicator(),
) )
: _DonationListItem( : _CardDonation(
donation: state.donations[index], donation: state.donations[index],
); );
})); }));
...@@ -129,6 +129,68 @@ class __MyDonationsState extends State<_MyDonations> { ...@@ -129,6 +129,68 @@ class __MyDonationsState extends State<_MyDonations> {
} }
} }
class _CardDonation extends StatelessWidget {
const _CardDonation({
Key key,
@required this.donation,
}) : super(key: key);
final Donation donation;
@override
Widget build(BuildContext context) {
if (donation.donationType == 'CSH') {
return _DonationListItem(
donation: donation,
);
} else {
return GestureDetector(
onTap: () {
showDialog(context: context, builder: (BuildContext context) =>
_DonationDetaiDialog(donation: donation,));
},
child: _DonationListItem(
donation: donation,
),
);
}
}
}
class _DonationDetaiDialog extends StatelessWidget {
final Donation donation;
const _DonationDetaiDialog({
Key key,
@required this.donation,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Dialog(
child: Container(
height: 100,
margin: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.pop(context);
},
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),)
],),
),
const SizedBox(height: 10.0,),
Text('Barang: ${donation.goodsDescription}'),
Text('Jumlah: ${donation.goodsQuantity}'),
],
),
),
);
}
}
class _DonationListItem extends StatelessWidget { class _DonationListItem extends StatelessWidget {
const _DonationListItem({ const _DonationListItem({
Key key, Key key,
...@@ -256,3 +318,4 @@ class _DonationListItem extends StatelessWidget { ...@@ -256,3 +318,4 @@ class _DonationListItem extends StatelessWidget {
); );
} }
} }
...@@ -70,12 +70,14 @@ class DetailProgram extends StatelessWidget { ...@@ -70,12 +70,14 @@ class DetailProgram extends StatelessWidget {
_DeskripsiRow( _DeskripsiRow(
icon: Icons.calendar_today, icon: Icons.calendar_today,
label: label:
'${formatDate(program.startDateTime)}'), '${formatDate(program.startDateTime)}'
', ${formatTime(program.startDateTime)} WIB -'),
if (program.endDateTime != null) if (program.endDateTime != null)
_DeskripsiRow( _DeskripsiRow(
icon: Icons.schedule,
label: label:
'${formatTime(program.startDateTime)}', '${formatDate(program.endDateTime)}'
', ${formatTime(program.endDateTime)} WIB',
), ),
if (program.location != null && if (program.location != null &&
program.location != '') program.location != '')
...@@ -411,7 +413,7 @@ class _ButtonDownloadNote extends StatelessWidget { ...@@ -411,7 +413,7 @@ class _ButtonDownloadNote extends StatelessWidget {
class _DeskripsiRow extends StatelessWidget { class _DeskripsiRow extends StatelessWidget {
const _DeskripsiRow({ const _DeskripsiRow({
Key key, Key key,
@required this.icon, this.icon,
@required this.label, @required this.label,
}) : super(key: key); }) : super(key: key);
...@@ -429,6 +431,7 @@ class _DeskripsiRow extends StatelessWidget { ...@@ -429,6 +431,7 @@ class _DeskripsiRow extends StatelessWidget {
child: Icon( child: Icon(
icon, icon,
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
size: 18,
), ),
), ),
), ),
......
...@@ -131,6 +131,56 @@ void main() { ...@@ -131,6 +131,56 @@ void main() {
})).called(1); })).called(1);
}); });
testWidgets('show dialog for goods donation', (WidgetTester tester) async {
when(dio.get(_donation, queryParameters: queryParam)).thenAnswer(
(_) async =>
Response<Map<String, dynamic>>(statusCode: 200, data:
{
'count': 1,
'next': 'ada',
'previous': null,
'results': [
{
'id': '5b0a405c-a5a2-415e-9788-2b52c50792b1',
'donation_number': '8DVQQ6',
'program': 'b02580b3-d1ab-4bf8-b4c3-87a340ed3319',
'program_code': '5GZW45',
'user': 'f26c3bcd-f9d3-469e-b466-57610d9acdcb',
'user_username': 'sarah',
'user_full_name': 'sarah',
'user_phone_number': '+628123456789',
'program_name': 'Program Mengaji Bersama',
'donation_type': 'GDS',
'donation_status': '002',
'amount': null,
'readable_donation_status': 'Selesai',
'proof_of_bank_transfer': null,
'user_bank_name': null,
'user_bank_account_name': null,
'bank_account_transfer_destination': null,
'transfer_destination_bank_name': null,
'transfer_destination_bank_account_name': null,
'transfer_destination_bank_account_number': null,
'goods_quantity': '1',
'goods_description': 'kaos',
'delivery_method': 'PCK',
'delivery_address': 'rumah',
'created_at': '2020-11-27T09:11:13.019671+07:00',
'updated_at': '2020-12-05T20:29:11.013324+07:00'
}
]
}));
await tester.pumpWidget(widgetTested);
expect(find.byType(CircularProgressIndicator), findsOneWidget);
await tester.pump(Duration(seconds: 5));
await tester.pump();
expect(find.text('27 November 2020'), findsOneWidget);
await tester.tap(find.text('27 November 2020'));
await tester.pump(Duration(seconds: 3));
expect(find.text('Barang: kaos'), findsOneWidget);
expect(find.text('Jumlah: 1'), findsOneWidget);
});
testWidgets('refresh load', (WidgetTester tester) async { testWidgets('refresh load', (WidgetTester tester) async {
when(dio.get(_donation, queryParameters: queryParam)).thenAnswer( when(dio.get(_donation, queryParameters: queryParam)).thenAnswer(
(_) async => (_) async =>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment