Skip to content

Commit

Permalink
Merge pull request #26 from adryanev/dev
Browse files Browse the repository at this point in the history
fix: ticketer approval button spammed
  • Loading branch information
adryanev authored Dec 9, 2022
2 parents 04bfe13 + b95c804 commit 6b5fee0
Showing 1 changed file with 59 additions and 31 deletions.
90 changes: 59 additions & 31 deletions lib/features/scanner/presentation/pages/scan_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,35 @@ class ScanDetailPage extends StatelessWidget with FailureMessageHandler {
: () {
showDialog<dynamic>(
context: context,
builder: (_) => ConfirmationDialog(
title: 'Konfirmasi Setuju',
description:
'Apakah anda menyetujui tiket ini?',
onDismiss: () {
Navigator.pop(context);
},
onConfirm: () {
context.read<ScanDetailBloc>().add(
const ScanDetailEvent
.approveButtonPressed(),
);
},
confirmText: 'Setuju',
dismissText: 'Batal',
builder: (_) => BlocProvider.value(
value: context.read<ScanDetailBloc>(),
child: BlocBuilder<ScanDetailBloc,
ScanDetailState>(
builder: (context, state) {
return ConfirmationDialog(
title: 'Konfirmasi Setuju',
description:
'Apakah anda menyetujui tiket ini?',
onDismiss: () {
Navigator.pop(context);
},
onConfirm: state.isLoading
? null
: () {
context
.read<ScanDetailBloc>()
.add(
const ScanDetailEvent
.approveButtonPressed(),
);
},
confirmText: state.isLoading
? 'Loading'
: 'Setuju',
dismissText: 'Batal',
);
},
),
),
);
},
Expand All @@ -116,22 +130,36 @@ class ScanDetailPage extends StatelessWidget with FailureMessageHandler {
: () {
showDialog<dynamic>(
context: context,
builder: (_) => ConfirmationDialog(
title: 'Konfirmasi Pembayaran',
description:
'Pastikan anda sudah menerima uang '
'dari pengunjung',
onDismiss: () {
Navigator.pop(context);
},
onConfirm: () {
context.read<ScanDetailBloc>().add(
const ScanDetailEvent
.payNowButtonPressed(),
);
},
confirmText: 'Konfirmasi',
dismissText: 'Batal',
builder: (_) => BlocProvider.value(
value: context.read<ScanDetailBloc>(),
child: BlocBuilder<ScanDetailBloc,
ScanDetailState>(
builder: (context, state) {
return ConfirmationDialog(
title: 'Konfirmasi Pembayaran',
description:
'Pastikan anda sudah menerima uang '
'dari pengunjung',
onDismiss: () {
Navigator.pop(context);
},
onConfirm: state.isLoading
? null
: () {
context
.read<ScanDetailBloc>()
.add(
const ScanDetailEvent
.payNowButtonPressed(),
);
},
confirmText: state.isLoading
? 'Loading'
: 'Konfirmasi',
dismissText: 'Batal',
);
},
),
),
);
},
Expand Down

0 comments on commit 6b5fee0

Please sign in to comment.