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,84 @@
|
||||
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/outlet/outlet_loader/outlet_loader_bloc.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../components/button/button.dart';
|
||||
import '../wallet/wallet_ui.dart';
|
||||
import 'widgets/outlet_tile.dart';
|
||||
|
||||
/// Semua outlet tempat EnakPoint & EnakCoin berlaku (§4.4).
|
||||
@RoutePage()
|
||||
class OutletPage extends StatelessWidget {
|
||||
const OutletPage({super.key});
|
||||
|
||||
void _refresh(BuildContext context) =>
|
||||
context.read<OutletLoaderBloc>().add(const OutletLoaderEvent.fetched());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.background,
|
||||
appBar: AppBar(title: const Text('Outlet')),
|
||||
body: BlocBuilder<OutletLoaderBloc, OutletLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (!state.hasLoaded) {
|
||||
return state.failureOption.fold(
|
||||
() => const Center(
|
||||
child: SpinKitFadingCircle(color: AppColor.primary, size: 36),
|
||||
),
|
||||
(f) => Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
walletFailureMessage(f),
|
||||
textAlign: TextAlign.center,
|
||||
style: AppStyle.md,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
AppOutlineButton(
|
||||
title: 'Coba lagi',
|
||||
width: 160,
|
||||
onPressed: () => _refresh(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
color: AppColor.primary,
|
||||
onRefresh: () async {
|
||||
_refresh(context);
|
||||
await context.read<OutletLoaderBloc>().stream.firstWhere(
|
||||
(s) => !s.isFetching,
|
||||
);
|
||||
},
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 24),
|
||||
itemCount: state.outlets.length + 1,
|
||||
separatorBuilder: (_, _) => const SizedBox(height: 10),
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return Text(
|
||||
'EnakPoint & EnakCoin kamu berlaku di '
|
||||
'${state.outlets.length} outlet berikut.',
|
||||
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
|
||||
);
|
||||
}
|
||||
return OutletTile(outlet: state.outlets[index - 1]);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../../domain/wallet/wallet.dart';
|
||||
import '../../wallet/wallet_ui.dart';
|
||||
|
||||
/// Satu outlet: nama, alamat, dan di mana EnakPoint/EnakCoin berlaku.
|
||||
class OutletTile extends StatelessWidget {
|
||||
const OutletTile({super.key, required this.outlet});
|
||||
|
||||
final Outlet outlet;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(AppValue.borderRadius),
|
||||
border: Border.all(color: AppColor.borderLight),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primaryWithOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.storefront_rounded,
|
||||
color: AppColor.primary,
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
outlet.name,
|
||||
style: AppStyle.md.copyWith(fontWeight: FontWeight.w700),
|
||||
),
|
||||
if (outlet.address != null) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
outlet.address!,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppStyle.xs.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
],
|
||||
if (outlet.acceptsPointPayment ||
|
||||
outlet.earnsPoints ||
|
||||
outlet.earnsCoins) ...[
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 6,
|
||||
runSpacing: 6,
|
||||
children: [
|
||||
if (outlet.acceptsPointPayment)
|
||||
const _Chip(
|
||||
label: 'Bisa bayar pakai EnakPoint',
|
||||
icon: Icon(
|
||||
Icons.check_circle_rounded,
|
||||
size: 14,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
highlighted: true,
|
||||
),
|
||||
if (outlet.earnsPoints)
|
||||
const _Chip(
|
||||
label: 'Dapat EnakPoint',
|
||||
icon: WalletCurrencyIcon(
|
||||
currency: WalletCurrency.point,
|
||||
size: 14,
|
||||
),
|
||||
),
|
||||
if (outlet.earnsCoins)
|
||||
const _Chip(
|
||||
label: 'Dapat EnakCoin',
|
||||
icon: WalletCurrencyIcon(
|
||||
currency: WalletCurrency.coin,
|
||||
size: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Chip extends StatelessWidget {
|
||||
const _Chip({
|
||||
required this.label,
|
||||
required this.icon,
|
||||
this.highlighted = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final Widget icon;
|
||||
final bool highlighted;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: highlighted
|
||||
? AppColor.primaryWithOpacity(0.08)
|
||||
: AppColor.background,
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
icon,
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
label,
|
||||
style: AppStyle.xs.copyWith(
|
||||
fontSize: 10,
|
||||
color: highlighted ? AppColor.primary : AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user