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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5954510b93
commit
f5e3075205
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/theme/theme.dart';
|
||||
|
||||
/// Konfirmasi sebelum transaksi yang tidak bisa dibatalkan.
|
||||
Future<bool> showWalletConfirmDialog(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
required String message,
|
||||
required String confirmLabel,
|
||||
}) async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
backgroundColor: AppColor.white,
|
||||
title: Text(
|
||||
title,
|
||||
style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700),
|
||||
),
|
||||
content: Text(message, style: AppStyle.md),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||||
child: Text(
|
||||
'Batal',
|
||||
style: AppStyle.md.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||||
child: Text(
|
||||
confirmLabel,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return confirmed == true;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/extension/extension.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../../domain/wallet/wallet.dart';
|
||||
|
||||
class WalletExpiringBanner extends StatelessWidget {
|
||||
const WalletExpiringBanner({
|
||||
super.key,
|
||||
required this.currency,
|
||||
required this.expiring,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
final WalletCurrency currency;
|
||||
final ExpiringAmount expiring;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(AppValue.borderRadius),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.warningWithOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(AppValue.borderRadius),
|
||||
border: Border.all(color: AppColor.warning),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.schedule, color: AppColor.warning, size: 20),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${expiring.amount.thousandFormat} ${currency.label} akan '
|
||||
'kedaluwarsa pada ${expiring.date.toDate}',
|
||||
style: AppStyle.sm.copyWith(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 14,
|
||||
color: AppColor.textSecondary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
import '../../../../application/wallet/wallet_history_loader/wallet_history_loader_bloc.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../../domain/wallet/wallet.dart';
|
||||
import '../wallet_ui.dart';
|
||||
import 'wallet_transaction_tile.dart';
|
||||
|
||||
/// Riwayat dari [WalletHistoryLoaderBloc] terdekat, sebagai sliver di dalam
|
||||
/// [CustomScrollView]. Filter tipe/mata uang diatur oleh halaman pemakainya.
|
||||
class WalletHistorySection extends StatefulWidget {
|
||||
const WalletHistorySection({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.emptyIcon,
|
||||
required this.emptyTitle,
|
||||
required this.emptySubtitle,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final IconData emptyIcon;
|
||||
final String emptyTitle;
|
||||
final String Function(WalletCurrency currency) emptySubtitle;
|
||||
|
||||
@override
|
||||
State<WalletHistorySection> createState() => _WalletHistorySectionState();
|
||||
}
|
||||
|
||||
class _WalletHistorySectionState extends State<WalletHistorySection> {
|
||||
static const _radius = Radius.circular(AppValue.borderRadius);
|
||||
|
||||
/// Item yang sudah pernah dianimasikan, supaya tidak berkedip ulang saat
|
||||
/// di-scroll keluar lalu masuk lagi.
|
||||
final Set<String> _animatedIds = {};
|
||||
|
||||
/// Sebelum request pertama selesai, tampilkan skeleton, bukan "kosong".
|
||||
bool _hasFetched = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocConsumer<WalletHistoryLoaderBloc, WalletHistoryLoaderState>(
|
||||
// Awal fetch halaman pertama (ganti tab / refresh) mengosongkan list,
|
||||
// jadi item yang datang berikutnya boleh dianimasikan lagi.
|
||||
listenWhen: (p, c) => p.isFetching != c.isFetching,
|
||||
listener: (context, state) {
|
||||
if (state.isFetching) {
|
||||
_animatedIds.clear();
|
||||
} else {
|
||||
_hasFetched = true;
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
final showList = state.items.isNotEmpty;
|
||||
|
||||
return SliverMainAxisGroup(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(child: _buildHeader(state)),
|
||||
if (showList)
|
||||
SliverList.builder(
|
||||
itemCount: state.items.length + (state.hasMore ? 1 : 0),
|
||||
itemBuilder: (context, index) {
|
||||
if (index >= state.items.length) return _buildLoadingMore();
|
||||
return _buildItem(state, index);
|
||||
},
|
||||
)
|
||||
else
|
||||
SliverToBoxAdapter(
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
child: _buildPlaceholder(state),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(WalletHistoryLoaderState state) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 0, 4, 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.title,
|
||||
style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700),
|
||||
),
|
||||
),
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: Text(
|
||||
state.currency.label,
|
||||
key: ValueKey(state.currency),
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItem(WalletHistoryLoaderState state, int index) {
|
||||
final tx = state.items[index];
|
||||
final isFirst = index == 0;
|
||||
final isLast = index == state.items.length - 1 && !state.hasMore;
|
||||
final animate = _animatedIds.add(tx.id);
|
||||
|
||||
final tile = Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: isFirst ? _radius : Radius.zero,
|
||||
bottom: isLast ? _radius : Radius.zero,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
if (!isFirst)
|
||||
const Divider(
|
||||
height: 1,
|
||||
indent: 68,
|
||||
endIndent: 16,
|
||||
color: AppColor.borderLight,
|
||||
),
|
||||
WalletTransactionTile(transaction: tx),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (!animate) return tile;
|
||||
return _FadeSlideIn(
|
||||
key: ValueKey(tx.id),
|
||||
// Hanya item awal yang bertahap; item hasil scroll langsung muncul.
|
||||
delay: Duration(milliseconds: index < 8 ? index * 50 : 0),
|
||||
child: tile,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoadingMore() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.vertical(bottom: _radius),
|
||||
),
|
||||
child: const Center(
|
||||
child: SpinKitFadingCircle(color: AppColor.primary, size: 24),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPlaceholder(WalletHistoryLoaderState state) {
|
||||
if (state.isFetching || !_hasFetched) {
|
||||
return const _HistorySkeleton(key: ValueKey('skeleton'));
|
||||
}
|
||||
|
||||
final failure = state.failureOption.toNullable();
|
||||
if (failure != null) {
|
||||
return _MessageCard(
|
||||
key: const ValueKey('error'),
|
||||
icon: Icons.wifi_off_rounded,
|
||||
title: walletFailureMessage(failure),
|
||||
action: TextButton(
|
||||
onPressed: () => context.read<WalletHistoryLoaderBloc>().add(
|
||||
const WalletHistoryLoaderEvent.refreshed(),
|
||||
),
|
||||
child: Text(
|
||||
'Coba lagi',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return _MessageCard(
|
||||
key: ValueKey('empty-${state.currency}'),
|
||||
icon: widget.emptyIcon,
|
||||
title: widget.emptyTitle,
|
||||
subtitle: widget.emptySubtitle(state.currency),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _MessageCard extends StatelessWidget {
|
||||
const _MessageCard({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.action,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final Widget? action;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 28),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(AppValue.borderRadius),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 52,
|
||||
height: 52,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primaryWithOpacity(0.08),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(icon, color: AppColor.primary, size: 26),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppStyle.md.copyWith(fontWeight: FontWeight.w700),
|
||||
),
|
||||
if (subtitle != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
subtitle!,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
],
|
||||
if (action != null) ...[const SizedBox(height: 4), action!],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _HistorySkeleton extends StatelessWidget {
|
||||
const _HistorySkeleton({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget bar(double width, double height) => Container(
|
||||
width: width,
|
||||
height: height,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
);
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(AppValue.borderRadius),
|
||||
),
|
||||
child: Shimmer.fromColors(
|
||||
baseColor: AppColor.borderLight,
|
||||
highlightColor: AppColor.white,
|
||||
child: Column(
|
||||
children: List.generate(
|
||||
3,
|
||||
(_) => Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColor.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
bar(120, 12),
|
||||
const SizedBox(height: 8),
|
||||
bar(80, 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
bar(56, 14),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Fade + geser naik sekali saat pertama kali muncul.
|
||||
class _FadeSlideIn extends StatefulWidget {
|
||||
const _FadeSlideIn({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.delay = Duration.zero,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final Duration delay;
|
||||
|
||||
@override
|
||||
State<_FadeSlideIn> createState() => _FadeSlideInState();
|
||||
}
|
||||
|
||||
class _FadeSlideInState extends State<_FadeSlideIn>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 350),
|
||||
);
|
||||
late final Animation<double> _curve = CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: Curves.easeOutCubic,
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Future.delayed(widget.delay, () {
|
||||
if (mounted) _controller.forward();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FadeTransition(
|
||||
opacity: _curve,
|
||||
child: SlideTransition(
|
||||
position: Tween(
|
||||
begin: const Offset(0, 0.15),
|
||||
end: Offset.zero,
|
||||
).animate(_curve),
|
||||
child: widget.child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../components/button/button.dart';
|
||||
|
||||
/// Layar sukses untuk tukar dan transfer.
|
||||
class WalletResultView extends StatelessWidget {
|
||||
const WalletResultView({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.amountText,
|
||||
required this.lines,
|
||||
required this.onDone,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String amountText;
|
||||
final List<String> lines;
|
||||
final VoidCallback onDone;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
const Icon(Icons.check_circle, color: AppColor.success, size: 72),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
title,
|
||||
style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
amountText,
|
||||
style: AppStyle.h4.copyWith(fontWeight: FontWeight.w700),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
...lines.map(
|
||||
(line) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6),
|
||||
child: Text(
|
||||
line,
|
||||
style: AppStyle.md.copyWith(color: AppColor.textSecondary),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
AppElevatedButton(title: 'Selesai', onPressed: onDone),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../../domain/wallet/wallet.dart';
|
||||
import '../wallet_ui.dart';
|
||||
|
||||
class WalletTransactionTile extends StatelessWidget {
|
||||
const WalletTransactionTile({
|
||||
super.key,
|
||||
required this.transaction,
|
||||
this.showCurrency = false,
|
||||
});
|
||||
|
||||
final WalletTransaction transaction;
|
||||
|
||||
/// Tampilkan mata uang di samping jumlah, untuk list yang mencampur
|
||||
/// EnakPoint & EnakCoin. Satu order menghasilkan dua transaksi (POINT dan
|
||||
/// COIN) dengan deskripsi dan jumlah yang sama.
|
||||
final bool showCurrency;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tx = transaction;
|
||||
final color = signedAmountColor(tx.amount);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
tx.isIncoming ? Icons.south_west : Icons.north_east,
|
||||
color: color,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
tx.type.label,
|
||||
style: AppStyle.md.copyWith(fontWeight: FontWeight.w700),
|
||||
),
|
||||
if (tx.description.isNotEmpty) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
tx.description,
|
||||
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
],
|
||||
if (tx.createdAt != null) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
formatWibDateTime(tx.createdAt!),
|
||||
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
],
|
||||
if (tx.isIncoming && tx.expiresAt != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Berlaku sampai ${formatWibDate(tx.expiresAt!)}',
|
||||
style: AppStyle.xs.copyWith(
|
||||
color: AppColor.warning,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
formatSignedAmount(tx.amount),
|
||||
style: AppStyle.md.copyWith(
|
||||
color: color,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
if (showCurrency) ...[
|
||||
const SizedBox(width: 4),
|
||||
WalletCurrencyIcon(currency: tx.currency, size: 16),
|
||||
],
|
||||
],
|
||||
),
|
||||
if (showCurrency) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
tx.currency.label,
|
||||
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user