Files
enaklo-flutter/lib/presentation/pages/wallet/wallet_expiring_page.dart
T
efrilmandClaude Opus 5.5 f5e3075205 EnakPoint & EnakCoin wallet, PIN, outlet, order, community, reward
- Wallet EnakPoint & EnakCoin: beranda, riwayat, saldo kedaluwarsa, kode
  bayar, tukar EnakCoin, transfer
- PIN (buat, ganti, lupa), outlet, riwayat order, game spin
- Halaman community, webview, coming soon, dan ikon menu beranda baru
- Redesign Reward Saya: kartu tiket, filter chip, detail kode + QR
- Hapus customer point loader, menu, dan checkout lama
- Base URL ke enaklo-pos-api.altru.id

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 01:43:22 +07:00

132 lines
4.3 KiB
Dart

import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import '../../../application/wallet/wallet_expiring_loader/wallet_expiring_loader_bloc.dart';
import '../../../common/extension/extension.dart';
import '../../../common/theme/theme.dart';
import '../../../domain/wallet/wallet.dart';
import '../../../injection.dart';
import '../../components/button/button.dart';
import 'wallet_ui.dart';
/// Saldo yang akan kedaluwarsa (ยง4.3).
@RoutePage()
class WalletExpiringPage extends StatelessWidget implements AutoRouteWrapper {
const WalletExpiringPage({super.key});
@override
Widget wrappedRoute(BuildContext context) => BlocProvider(
create: (_) =>
getIt<WalletExpiringLoaderBloc>()
..add(const WalletExpiringLoaderEvent.fetched()),
child: this,
);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.background,
appBar: AppBar(title: const Text('Akan Kedaluwarsa')),
body: BlocBuilder<WalletExpiringLoaderBloc, WalletExpiringLoaderState>(
builder: (context, state) {
if (state.isFetching) {
return const Center(
child: SpinKitFadingCircle(color: AppColor.primary, size: 36),
);
}
final failure = state.failureOption.toNullable();
if (failure != null) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(walletFailureMessage(failure), style: AppStyle.md),
const SizedBox(height: 16),
AppOutlineButton(
title: 'Coba lagi',
width: 160,
onPressed: () => context
.read<WalletExpiringLoaderBloc>()
.add(const WalletExpiringLoaderEvent.fetched()),
),
],
),
);
}
final expiring = state.expiring;
return ListView(
padding: const EdgeInsets.all(16),
children: [
Text(
'Saldo bisa dipakai sampai pukul 23:59 WIB pada tanggal '
'kedaluwarsa. Saldo yang kedaluwarsa hangus tanpa kompensasi.',
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
),
const SizedBox(height: 16),
_Section(currency: WalletCurrency.point, items: expiring.point),
const SizedBox(height: 16),
_Section(currency: WalletCurrency.coin, items: expiring.coin),
],
);
},
),
);
}
}
class _Section extends StatelessWidget {
const _Section({required this.currency, required this.items});
final WalletCurrency currency;
final List<ExpiringAmount> items;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: AppColor.white,
borderRadius: BorderRadius.circular(AppValue.borderRadius),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
child: Text(
currency.label,
style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700),
),
),
if (items.isEmpty)
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 20),
child: Text(
'Tidak ada saldo yang akan kedaluwarsa',
style: AppStyle.md.copyWith(color: AppColor.textSecondary),
),
)
else
...items.map(
(item) => ListTile(
leading: const Icon(Icons.schedule, color: AppColor.warning),
title: Text(
'${item.amount.thousandFormat} ${currency.label}',
style: AppStyle.md.copyWith(fontWeight: FontWeight.w700),
),
subtitle: Text(
'Berlaku sampai ${item.date.toDate}, 23:59 WIB',
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
),
),
),
],
),
);
}
}