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:
efrilm
2026-10-01 01:43:22 +07:00
co-authored by Claude Opus 5.5
parent 5954510b93
commit f5e3075205
253 changed files with 47212 additions and 17437 deletions
@@ -0,0 +1,147 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../../common/theme/theme.dart';
/// Input 6 digit dengan tampilan kotak. Nilainya tidak pernah disimpan di luar
/// [controller]; pemanggil wajib mengosongkannya setelah dipakai.
class PinCodeField extends StatefulWidget {
const PinCodeField({
super.key,
required this.controller,
this.onCompleted,
this.obscure = true,
this.hasError = false,
this.enabled = true,
this.autofocus = true,
});
final TextEditingController controller;
final ValueChanged<String>? onCompleted;
final bool obscure;
final bool hasError;
final bool enabled;
final bool autofocus;
static const int length = 6;
@override
State<PinCodeField> createState() => _PinCodeFieldState();
}
class _PinCodeFieldState extends State<PinCodeField> {
final FocusNode _focusNode = FocusNode();
@override
void initState() {
super.initState();
widget.controller.addListener(_onChanged);
_focusNode.addListener(() => setState(() {}));
}
@override
void didUpdateWidget(covariant PinCodeField oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.controller != widget.controller) {
oldWidget.controller.removeListener(_onChanged);
widget.controller.addListener(_onChanged);
}
}
@override
void dispose() {
widget.controller.removeListener(_onChanged);
_focusNode.dispose();
super.dispose();
}
void _onChanged() {
setState(() {});
final value = widget.controller.text;
if (value.length == PinCodeField.length) {
widget.onCompleted?.call(value);
}
}
@override
Widget build(BuildContext context) {
final value = widget.controller.text;
return GestureDetector(
onTap: () => _focusNode.requestFocus(),
child: Stack(
children: [
// Field asli tak terlihat yang menerima input keyboard.
Opacity(
opacity: 0,
child: SizedBox(
height: 52,
child: TextField(
controller: widget.controller,
focusNode: _focusNode,
enabled: widget.enabled,
autofocus: widget.autofocus,
keyboardType: TextInputType.number,
maxLength: PinCodeField.length,
enableSuggestions: false,
autocorrect: false,
enableInteractiveSelection: false,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
decoration: const InputDecoration(counterText: ''),
),
),
),
IgnorePointer(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: List.generate(PinCodeField.length, (index) {
final filled = index < value.length;
final active =
widget.enabled &&
_focusNode.hasFocus &&
index == value.length;
return Container(
width: 44,
height: 52,
alignment: Alignment.center,
decoration: BoxDecoration(
color: widget.enabled
? AppColor.white
: AppColor.backgroundGradient.first,
borderRadius: BorderRadius.circular(10),
border: Border.all(
width: active || widget.hasError ? 2 : 1,
color: widget.hasError
? AppColor.error
: active
? AppColor.primary
: AppColor.border,
),
),
child: filled
? widget.obscure
? Container(
width: 12,
height: 12,
decoration: const BoxDecoration(
color: AppColor.textPrimary,
shape: BoxShape.circle,
),
)
: Text(
value[index],
style: AppStyle.xl.copyWith(
fontWeight: FontWeight.w700,
),
)
: null,
);
}),
),
),
],
),
);
}
}
@@ -0,0 +1,205 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import '../../../../common/theme/theme.dart';
import '../../../../domain/wallet/wallet.dart';
import '../../../router/app_router.gr.dart';
import '../../wallet/wallet_ui.dart';
import 'pin_code_field.dart';
/// Mengirim PIN ke server. Kembalikan `null` bila sukses, atau failure-nya.
typedef PinSubmitCallback = Future<WalletFailure?> Function(String pin);
enum _PinSheetResult { success, failed, forgotPin, pinNotSet }
/// Meminta PIN lalu menjalankan [onSubmit]. Error PIN (§6.5) ditangani di dalam
/// sheet; failure lain menutup sheet dan ditampilkan oleh halaman pemanggil.
/// Mengembalikan `true` bila [onSubmit] sukses.
Future<bool> showPinSheet(
BuildContext context, {
required String title,
String? subtitle,
required PinSubmitCallback onSubmit,
}) async {
final result = await showModalBottomSheet<_PinSheetResult>(
context: context,
isScrollControlled: true,
isDismissible: false,
backgroundColor: AppColor.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
builder: (_) =>
_PinSheet(title: title, subtitle: subtitle, onSubmit: onSubmit),
);
if (!context.mounted) return false;
switch (result) {
case _PinSheetResult.success:
return true;
case _PinSheetResult.forgotPin:
context.router.push(PinSetupRoute(purpose: PinOtpPurpose.reset));
return false;
case _PinSheetResult.pinNotSet:
context.router.push(PinSetupRoute(purpose: PinOtpPurpose.setup));
return false;
case _PinSheetResult.failed:
case null:
return false;
}
}
class _PinSheet extends StatefulWidget {
const _PinSheet({required this.title, this.subtitle, required this.onSubmit});
final String title;
final String? subtitle;
final PinSubmitCallback onSubmit;
@override
State<_PinSheet> createState() => _PinSheetState();
}
class _PinSheetState extends State<_PinSheet> {
final TextEditingController _controller = TextEditingController();
bool _isSubmitting = false;
String? _errorText;
/// PIN terkunci atau transfer ditahan: input tidak berguna lagi.
bool _isBlocked = false;
@override
void dispose() {
_controller.dispose();
super.dispose();
}
Future<void> _submit(String pin) async {
if (_isSubmitting || _isBlocked) return;
setState(() {
_isSubmitting = true;
_errorText = null;
});
final failure = await widget.onSubmit(pin);
if (!mounted) return;
// PIN tidak disimpan lebih lama dari yang diperlukan.
_controller.clear();
if (failure == null) {
Navigator.of(context).pop(_PinSheetResult.success);
return;
}
final handled = failure.maybeMap(
pinNotSet: (_) {
Navigator.of(context).pop(_PinSheetResult.pinNotSet);
return true;
},
pinInvalid: (_) {
setState(() => _errorText = walletFailureMessage(failure));
return true;
},
pinLocked: (_) {
setState(() {
_errorText = walletFailureMessage(failure);
_isBlocked = true;
});
return true;
},
transferBlocked: (_) {
setState(() {
_errorText = walletFailureMessage(failure);
_isBlocked = true;
});
return true;
},
orElse: () => false,
);
if (!handled) {
Navigator.of(context).pop(_PinSheetResult.failed);
return;
}
setState(() => _isSubmitting = false);
}
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.only(
left: 20,
right: 20,
top: 12,
bottom: MediaQuery.of(context).viewInsets.bottom + 24,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
widget.title,
style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700),
),
),
IconButton(
onPressed: _isSubmitting
? null
: () => Navigator.of(context).pop(),
icon: const Icon(Icons.close, color: AppColor.textSecondary),
),
],
),
Text(
widget.subtitle ?? 'Masukkan PIN 6 digit kamu',
style: AppStyle.md.copyWith(color: AppColor.textSecondary),
),
const SizedBox(height: 24),
PinCodeField(
controller: _controller,
enabled: !_isSubmitting && !_isBlocked,
hasError: _errorText != null,
onCompleted: _submit,
),
const SizedBox(height: 16),
if (_isSubmitting)
const Center(
child: SpinKitFadingCircle(color: AppColor.primary, size: 28),
)
else if (_errorText != null)
Text(
_errorText!,
style: AppStyle.md.copyWith(
color: AppColor.error,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: _isSubmitting
? null
: () => Navigator.of(context).pop(_PinSheetResult.forgotPin),
child: Text(
'Lupa PIN',
style: AppStyle.md.copyWith(
color: AppColor.primary,
fontWeight: FontWeight.w700,
),
),
),
),
],
),
);
}
}