Tab Community, tombol Bayar di navbar, logo placeholder, fix crash PIN
- Bottom navbar: Home, Pesanan, Bayar (tombol tengah ke kode bayar), Community, Profil; menu EnakCommunity di beranda pindah ke tab - Image placeholder: logo Enaklo diperbesar, ilustrasi gelas dihapus - Fix assertion Navigator saat PIN gagal karena error non-PIN: flushbar kini tampil lewat onFailure setelah sheet PIN tertutup (bayar, tukar, transfer) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f5e3075205
commit
bc751246d8
@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:shimmer/shimmer.dart';
|
import 'package:shimmer/shimmer.dart';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import '../../../common/theme/theme.dart';
|
|
||||||
import '../assets/assets.gen.dart';
|
import '../assets/assets.gen.dart';
|
||||||
|
|
||||||
part 'image_placeholder.dart';
|
part 'image_placeholder.dart';
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ImagePlaceholder extends StatelessWidget {
|
|||||||
final containerWidth = width ?? constraints.maxWidth;
|
final containerWidth = width ?? constraints.maxWidth;
|
||||||
final containerHeight = height ?? constraints.maxHeight;
|
final containerHeight = height ?? constraints.maxHeight;
|
||||||
|
|
||||||
// Calculate the minimum dimension to determine if we should show simple or detailed version
|
// Logo mengikuti sisi terpendek placeholder
|
||||||
final minDimension = math.min(
|
final minDimension = math.min(
|
||||||
containerWidth == double.infinity ? containerHeight : containerWidth,
|
containerWidth == double.infinity ? containerHeight : containerWidth,
|
||||||
containerHeight == double.infinity ? containerWidth : containerHeight,
|
containerHeight == double.infinity ? containerWidth : containerHeight,
|
||||||
@@ -42,129 +42,44 @@ class ImagePlaceholder extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(child: _buildLogo(context, minDimension)),
|
||||||
child: minDimension < 150
|
|
||||||
? _buildSimpleVersion(minDimension)
|
|
||||||
: _buildDetailedVersion(minDimension),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple version for small sizes (< 100px)
|
Widget _buildLogo(BuildContext context, double minDimension) {
|
||||||
Widget _buildSimpleVersion(double size) {
|
final size = (minDimension * 0.6).clamp(28.0, 140.0);
|
||||||
final iconSize = (size * 0.4).clamp(16.0, 32.0);
|
// Aset logo 1024px; decode seukuran tampilan saja.
|
||||||
final fontSize = (size * 0.12).clamp(8.0, 12.0);
|
final cacheSize = (size * 1.2 * MediaQuery.devicePixelRatioOf(context))
|
||||||
|
.round();
|
||||||
return Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: iconSize * 1.5,
|
|
||||||
height: iconSize * 1.5,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(iconSize * 0.75),
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: Assets.images.logo.image(
|
|
||||||
width: iconSize,
|
|
||||||
height: iconSize,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (size > 50) ...[
|
|
||||||
SizedBox(height: size * 0.05),
|
|
||||||
Text(
|
|
||||||
'Enaklo',
|
|
||||||
style: TextStyle(
|
|
||||||
color: AppColor.primary,
|
|
||||||
fontSize: fontSize,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detailed version for larger sizes (>= 100px)
|
|
||||||
Widget _buildDetailedVersion(double minDimension) {
|
|
||||||
final scaleFactor = minDimension / 200; // Base scale factor
|
|
||||||
|
|
||||||
// Proportional sizes
|
|
||||||
final illustrationSize = (120 * scaleFactor).clamp(80.0, 120.0);
|
|
||||||
final illustrationHeight = (160 * scaleFactor).clamp(100.0, 160.0);
|
|
||||||
final handWidth = (60 * scaleFactor).clamp(30.0, 60.0);
|
|
||||||
final handHeight = (80 * scaleFactor).clamp(40.0, 80.0);
|
|
||||||
final cupWidth = (70 * scaleFactor).clamp(35.0, 70.0);
|
|
||||||
final cupHeight = (90 * scaleFactor).clamp(45.0, 90.0);
|
|
||||||
final logoSize = (40 * scaleFactor).clamp(20.0, 40.0);
|
|
||||||
final fontSize = (12 * scaleFactor).clamp(8.0, 12.0);
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
width: illustrationSize,
|
width: size,
|
||||||
height: illustrationHeight,
|
height: size,
|
||||||
|
padding: EdgeInsets.all(size * 0.04),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(illustrationSize / 2),
|
shape: BoxShape.circle,
|
||||||
),
|
boxShadow: [
|
||||||
child: Stack(
|
BoxShadow(
|
||||||
children: [
|
color: Colors.black.withOpacity(0.08),
|
||||||
// Hand
|
blurRadius: size * 0.1,
|
||||||
Positioned(
|
offset: Offset(0, size * 0.03),
|
||||||
bottom: illustrationHeight * 0.125, // 20/160 ratio
|
|
||||||
left: illustrationSize * 0.25, // 30/120 ratio
|
|
||||||
child: Container(
|
|
||||||
width: handWidth,
|
|
||||||
height: handHeight,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color(0xFFFFDBB3),
|
|
||||||
borderRadius: BorderRadius.circular(handWidth / 2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Coffee cup
|
|
||||||
Positioned(
|
|
||||||
top: illustrationHeight * 0.1875, // 30/160 ratio
|
|
||||||
left: illustrationSize * 0.208, // 25/120 ratio
|
|
||||||
child: Container(
|
|
||||||
width: cupWidth,
|
|
||||||
height: cupHeight,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color(0xFFF4E4BC),
|
|
||||||
borderRadius: BorderRadius.circular(
|
|
||||||
math.max(8.0, 10 * scaleFactor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
// Logo
|
|
||||||
Assets.images.logo.image(
|
|
||||||
width: logoSize,
|
|
||||||
height: logoSize,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
SizedBox(height: math.max(4.0, 8 * scaleFactor)),
|
|
||||||
if (cupHeight > 50) // Only show text if cup is big enough
|
|
||||||
Text(
|
|
||||||
'Enaklo',
|
|
||||||
style: TextStyle(
|
|
||||||
color: AppColor.primary,
|
|
||||||
fontSize: fontSize,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
child: ClipOval(
|
||||||
|
// Sudut aset logo berlatar gelap; diperbesar sedikit supaya yang
|
||||||
|
// terlihat hanya lingkaran merahnya.
|
||||||
|
child: Transform.scale(
|
||||||
|
scale: 1.2,
|
||||||
|
child: Assets.images.logo.image(
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
cacheWidth: cacheSize,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class _CommunityPageState extends State<CommunityPage> {
|
|||||||
slivers: [
|
slivers: [
|
||||||
SliverAppBar(
|
SliverAppBar(
|
||||||
pinned: true,
|
pinned: true,
|
||||||
|
automaticallyImplyLeading: false,
|
||||||
backgroundColor: CommunityColor.background,
|
backgroundColor: CommunityColor.background,
|
||||||
title: const Text('EnakCommunity'),
|
title: const Text('EnakCommunity'),
|
||||||
actions: [
|
actions: [
|
||||||
|
|||||||
@@ -21,6 +21,14 @@ class _MainPageState extends State<MainPage> {
|
|||||||
context.read<AuthBloc>().add(const AuthEvent.fetchCurrentUser());
|
context.read<AuthBloc>().add(const AuthEvent.fetchCurrentUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Kode bayar di kasir; PIN diminta di halamannya sendiri.
|
||||||
|
void _openPay() {
|
||||||
|
final isAuthenticated = context.read<AuthBloc>().state.isAuthenticated;
|
||||||
|
context.router.push(
|
||||||
|
isAuthenticated ? const PaymentCodeRoute() : const OnboardingRoute(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AutoTabsRouter.pageView(
|
return AutoTabsRouter.pageView(
|
||||||
@@ -28,15 +36,26 @@ class _MainPageState extends State<MainPage> {
|
|||||||
HomeRoute(),
|
HomeRoute(),
|
||||||
// VoucherRoute(),
|
// VoucherRoute(),
|
||||||
OrderRoute(),
|
OrderRoute(),
|
||||||
|
CommunityRoute(),
|
||||||
ProfileRoute(),
|
ProfileRoute(),
|
||||||
],
|
],
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
builder: (context, child, pageController) => Scaffold(
|
builder: (context, child, pageController) {
|
||||||
body: child,
|
// Docked FAB ikut naik ke atas keyboard; sembunyikan saat mengetik.
|
||||||
bottomNavigationBar: MainBottomNavbar(
|
final isKeyboardOpen = MediaQuery.viewInsetsOf(context).bottom > 0;
|
||||||
tabsRouter: AutoTabsRouter.of(context),
|
|
||||||
),
|
return Scaffold(
|
||||||
),
|
body: child,
|
||||||
|
floatingActionButton: isKeyboardOpen
|
||||||
|
? null
|
||||||
|
: MainPayButton(onPressed: _openPay),
|
||||||
|
floatingActionButtonLocation: const MainPayButtonLocation(),
|
||||||
|
bottomNavigationBar: MainBottomNavbar(
|
||||||
|
tabsRouter: AutoTabsRouter.of(context),
|
||||||
|
onPayTap: _openPay,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class _HomeMenu {
|
|||||||
required this.icon,
|
required this.icon,
|
||||||
this.route,
|
this.route,
|
||||||
this.requiresLogin = false,
|
this.requiresLogin = false,
|
||||||
|
this.opensTab = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String label;
|
final String label;
|
||||||
@@ -23,6 +24,9 @@ class _HomeMenu {
|
|||||||
/// `null` berarti fitur belum tersedia.
|
/// `null` berarti fitur belum tersedia.
|
||||||
final PageRouteInfo? route;
|
final PageRouteInfo? route;
|
||||||
final bool requiresLogin;
|
final bool requiresLogin;
|
||||||
|
|
||||||
|
/// [route] adalah tab di bottom navbar; dibuka dengan pindah tab, bukan push.
|
||||||
|
final bool opensTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomeServiceSection extends StatelessWidget {
|
class HomeServiceSection extends StatelessWidget {
|
||||||
@@ -78,6 +82,7 @@ class HomeServiceSection extends StatelessWidget {
|
|||||||
label: 'EnakCommunity',
|
label: 'EnakCommunity',
|
||||||
icon: Assets.icons.enakcommunityIcon,
|
icon: Assets.icons.enakcommunityIcon,
|
||||||
route: const CommunityRoute(),
|
route: const CommunityRoute(),
|
||||||
|
opensTab: true,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -94,6 +99,11 @@ class HomeServiceSection extends StatelessWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (menu.opensTab) {
|
||||||
|
context.tabsRouter.navigate(route);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
context.router.push(route);
|
context.router.push(route);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,33 @@
|
|||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../common/theme/theme.dart';
|
||||||
|
|
||||||
class MainBottomNavbar extends StatelessWidget {
|
class MainBottomNavbar extends StatelessWidget {
|
||||||
final TabsRouter tabsRouter;
|
final TabsRouter tabsRouter;
|
||||||
const MainBottomNavbar({super.key, required this.tabsRouter});
|
final VoidCallback onPayTap;
|
||||||
|
const MainBottomNavbar({
|
||||||
|
super.key,
|
||||||
|
required this.tabsRouter,
|
||||||
|
required this.onPayTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Slot tengah hanya tempat label tombol Bayar; lingkarannya
|
||||||
|
/// [MainPayButton] yang menempel di atas navbar.
|
||||||
|
static const int _payIndex = 2;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final activeIndex = tabsRouter.activeIndex;
|
||||||
|
|
||||||
return BottomNavigationBar(
|
return BottomNavigationBar(
|
||||||
currentIndex: tabsRouter.activeIndex,
|
currentIndex: activeIndex >= _payIndex ? activeIndex + 1 : activeIndex,
|
||||||
onTap: (index) {
|
onTap: (index) {
|
||||||
tabsRouter.setActiveIndex(index);
|
if (index == _payIndex) {
|
||||||
|
onPayTap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tabsRouter.setActiveIndex(index > _payIndex ? index - 1 : index);
|
||||||
},
|
},
|
||||||
items: const [
|
items: const [
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
@@ -28,6 +45,16 @@ class MainBottomNavbar extends StatelessWidget {
|
|||||||
label: 'Pesanan',
|
label: 'Pesanan',
|
||||||
tooltip: 'Pesanan',
|
tooltip: 'Pesanan',
|
||||||
),
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: SizedBox(height: 24),
|
||||||
|
label: 'Bayar',
|
||||||
|
tooltip: 'Bayar di kasir',
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(Icons.groups),
|
||||||
|
label: 'Community',
|
||||||
|
tooltip: 'Community',
|
||||||
|
),
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: Icon(Icons.person),
|
icon: Icon(Icons.person),
|
||||||
label: 'Profil',
|
label: 'Profil',
|
||||||
@@ -37,3 +64,40 @@ class MainBottomNavbar extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Seperti [FloatingActionButtonLocation.centerDocked], tapi tombolnya lebih
|
||||||
|
/// menonjol ke atas supaya tidak menempel ke label "Bayar".
|
||||||
|
class MainPayButtonLocation extends StandardFabLocation
|
||||||
|
with FabCenterOffsetX, FabDockedOffsetY {
|
||||||
|
const MainPayButtonLocation();
|
||||||
|
|
||||||
|
static const double _raise = 10;
|
||||||
|
|
||||||
|
@override
|
||||||
|
double getOffsetY(
|
||||||
|
ScaffoldPrelayoutGeometry scaffoldGeometry,
|
||||||
|
double adjustment,
|
||||||
|
) => super.getOffsetY(scaffoldGeometry, adjustment) - _raise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tombol bulat di tengah navbar, dipasang di [MainPayButtonLocation].
|
||||||
|
class MainPayButton extends StatelessWidget {
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
const MainPayButton({super.key, required this.onPressed});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FloatingActionButton(
|
||||||
|
onPressed: onPressed,
|
||||||
|
// Halaman tab (mis. Community) juga punya FAB; tanpa hero supaya tag
|
||||||
|
// default tidak bentrok saat pindah halaman.
|
||||||
|
heroTag: null,
|
||||||
|
tooltip: 'Bayar di kasir',
|
||||||
|
elevation: 4,
|
||||||
|
backgroundColor: AppColor.primary,
|
||||||
|
foregroundColor: AppColor.white,
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: const Icon(Icons.qr_code_scanner_rounded, size: 28),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,14 +14,21 @@ typedef PinSubmitCallback = Future<WalletFailure?> Function(String pin);
|
|||||||
enum _PinSheetResult { success, failed, forgotPin, pinNotSet }
|
enum _PinSheetResult { success, failed, forgotPin, pinNotSet }
|
||||||
|
|
||||||
/// Meminta PIN lalu menjalankan [onSubmit]. Error PIN (§6.5) ditangani di dalam
|
/// Meminta PIN lalu menjalankan [onSubmit]. Error PIN (§6.5) ditangani di dalam
|
||||||
/// sheet; failure lain menutup sheet dan ditampilkan oleh halaman pemanggil.
|
/// sheet; failure lain menutup sheet lalu diteruskan ke [onFailure].
|
||||||
/// Mengembalikan `true` bila [onSubmit] sukses.
|
/// Mengembalikan `true` bila [onSubmit] sukses.
|
||||||
|
///
|
||||||
|
/// Tampilkan failure lewat [onFailure], jangan dari listener bloc: flushbar juga
|
||||||
|
/// berupa route, jadi bila muncul selagi sheet masih terbuka, pop milik sheet
|
||||||
|
/// justru menutup flushbar dan Navigator gagal assertion.
|
||||||
Future<bool> showPinSheet(
|
Future<bool> showPinSheet(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
required String title,
|
required String title,
|
||||||
String? subtitle,
|
String? subtitle,
|
||||||
required PinSubmitCallback onSubmit,
|
required PinSubmitCallback onSubmit,
|
||||||
|
ValueChanged<WalletFailure>? onFailure,
|
||||||
}) async {
|
}) async {
|
||||||
|
WalletFailure? lastFailure;
|
||||||
|
|
||||||
final result = await showModalBottomSheet<_PinSheetResult>(
|
final result = await showModalBottomSheet<_PinSheetResult>(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
@@ -30,8 +37,11 @@ Future<bool> showPinSheet(
|
|||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
),
|
),
|
||||||
builder: (_) =>
|
builder: (_) => _PinSheet(
|
||||||
_PinSheet(title: title, subtitle: subtitle, onSubmit: onSubmit),
|
title: title,
|
||||||
|
subtitle: subtitle,
|
||||||
|
onSubmit: (pin) async => lastFailure = await onSubmit(pin),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!context.mounted) return false;
|
if (!context.mounted) return false;
|
||||||
@@ -46,6 +56,8 @@ Future<bool> showPinSheet(
|
|||||||
context.router.push(PinSetupRoute(purpose: PinOtpPurpose.setup));
|
context.router.push(PinSetupRoute(purpose: PinOtpPurpose.setup));
|
||||||
return false;
|
return false;
|
||||||
case _PinSheetResult.failed:
|
case _PinSheetResult.failed:
|
||||||
|
if (lastFailure != null) onFailure?.call(lastFailure!);
|
||||||
|
return false;
|
||||||
case null:
|
case null:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ class _ExchangePageState extends State<ExchangePage> {
|
|||||||
final result = await bloc.stream.firstWhere((s) => !s.isSubmitting);
|
final result = await bloc.stream.firstWhere((s) => !s.isSubmitting);
|
||||||
return result.failureOption.toNullable();
|
return result.failureOption.toNullable();
|
||||||
},
|
},
|
||||||
|
onFailure: _showFailure,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (success && mounted) {
|
if (success && mounted) {
|
||||||
@@ -173,11 +174,6 @@ class _ExchangePageState extends State<ExchangePage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MultiBlocListener(
|
return MultiBlocListener(
|
||||||
listeners: [
|
listeners: [
|
||||||
BlocListener<ExchangeFormBloc, ExchangeFormState>(
|
|
||||||
listenWhen: (p, c) => p.failureOption != c.failureOption,
|
|
||||||
listener: (context, state) =>
|
|
||||||
state.failureOption.fold(() {}, _showFailure),
|
|
||||||
),
|
|
||||||
BlocListener<ExchangeFormBloc, ExchangeFormState>(
|
BlocListener<ExchangeFormBloc, ExchangeFormState>(
|
||||||
listenWhen: (p, c) => p.preview != c.preview && c.preview != null,
|
listenWhen: (p, c) => p.preview != c.preview && c.preview != null,
|
||||||
listener: (context, state) => setState(() => _rate = state.preview),
|
listener: (context, state) => setState(() => _rate = state.preview),
|
||||||
|
|||||||
@@ -73,18 +73,13 @@ class _PaymentCodePageState extends State<PaymentCodePage> {
|
|||||||
final state = await bloc.stream.firstWhere((s) => !s.isSubmitting);
|
final state = await bloc.stream.firstWhere((s) => !s.isSubmitting);
|
||||||
return state.failureOption.toNullable();
|
return state.failureOption.toNullable();
|
||||||
},
|
},
|
||||||
|
onFailure: (f) => AppFlushbar.showError(context, walletFailureMessage(f)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocConsumer<PaymentCodeFormBloc, PaymentCodeFormState>(
|
return BlocBuilder<PaymentCodeFormBloc, PaymentCodeFormState>(
|
||||||
listenWhen: (p, c) => p.failureOption != c.failureOption,
|
|
||||||
listener: (context, state) => state.failureOption.fold(() {}, (f) {
|
|
||||||
if (!f.isPinError) {
|
|
||||||
AppFlushbar.showError(context, walletFailureMessage(f));
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final code = state.paymentCode;
|
final code = state.paymentCode;
|
||||||
|
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ class _TransferPageState extends State<TransferPage> {
|
|||||||
final result = await bloc.stream.firstWhere((s) => !s.isSubmitting);
|
final result = await bloc.stream.firstWhere((s) => !s.isSubmitting);
|
||||||
return result.failureOption.toNullable();
|
return result.failureOption.toNullable();
|
||||||
},
|
},
|
||||||
|
onFailure: _showFailure,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (success && mounted) {
|
if (success && mounted) {
|
||||||
@@ -201,11 +202,6 @@ class _TransferPageState extends State<TransferPage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MultiBlocListener(
|
return MultiBlocListener(
|
||||||
listeners: [
|
listeners: [
|
||||||
BlocListener<TransferFormBloc, TransferFormState>(
|
|
||||||
listenWhen: (p, c) => p.failureOption != c.failureOption,
|
|
||||||
listener: (context, state) =>
|
|
||||||
state.failureOption.fold(() {}, _showFailure),
|
|
||||||
),
|
|
||||||
BlocListener<TransferFormBloc, TransferFormState>(
|
BlocListener<TransferFormBloc, TransferFormState>(
|
||||||
listenWhen: (p, c) =>
|
listenWhen: (p, c) =>
|
||||||
p.recipient != c.recipient && c.recipient != null,
|
p.recipient != c.recipient && c.recipient != null,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class AppRouter extends RootStackRouter {
|
|||||||
AutoRoute(page: HomeRoute.page),
|
AutoRoute(page: HomeRoute.page),
|
||||||
AutoRoute(page: VoucherRoute.page),
|
AutoRoute(page: VoucherRoute.page),
|
||||||
AutoRoute(page: OrderRoute.page),
|
AutoRoute(page: OrderRoute.page),
|
||||||
|
AutoRoute(page: CommunityRoute.page),
|
||||||
AutoRoute(page: ProfileRoute.page),
|
AutoRoute(page: ProfileRoute.page),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -91,8 +92,7 @@ class AppRouter extends RootStackRouter {
|
|||||||
AutoRoute(page: FerrisWheelRoute.page),
|
AutoRoute(page: FerrisWheelRoute.page),
|
||||||
AutoRoute(page: MisteryBoxRoute.page),
|
AutoRoute(page: MisteryBoxRoute.page),
|
||||||
|
|
||||||
// Community
|
// Community (halaman utamanya tab di Main)
|
||||||
AutoRoute(page: CommunityRoute.page),
|
|
||||||
AutoRoute(page: CommunityDetailRoute.page),
|
AutoRoute(page: CommunityDetailRoute.page),
|
||||||
AutoRoute(page: CommunityPostDetailRoute.page),
|
AutoRoute(page: CommunityPostDetailRoute.page),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user