From 6ff44041f08620721c76c6734597b75eaa781e74 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Sun, 14 Jun 2026 11:52:37 +0700 Subject: [PATCH] feat: update UI theme and improve subscription data fetching and display logic --- lib/screens/loyalty_dashboard.dart | 22 +----- lib/screens/main_shell.dart | 19 ++++- lib/services/odoo_service.dart | 13 +++- lib/widgets/subscription_list_widget.dart | 89 ++++++++++++++++++----- 4 files changed, 99 insertions(+), 44 deletions(-) diff --git a/lib/screens/loyalty_dashboard.dart b/lib/screens/loyalty_dashboard.dart index 1309288..966ec1a 100644 --- a/lib/screens/loyalty_dashboard.dart +++ b/lib/screens/loyalty_dashboard.dart @@ -40,28 +40,10 @@ class _LoyaltyDashboardState extends State { final rawSubs = results[1] as List; final cms = results[2] as Map; - final List cards = []; - final List subs = [...rawSubs]; - - for (var card in rawCards) { - final progName = (card['program_id']?[1] as String? ?? '').toLowerCase(); - final isSub = progName.contains('subscription') || - card['subscription_start_date'] != null || - card['subscription_end_date'] != null; - if (isSub) { - final code = card['code']; - if (!subs.any((s) => s['code'] == code)) { - subs.add(card); - } - } else { - cards.add(card); - } - } - if (mounted) { setState(() { - _loyaltyCards = cards; - _subscriptions = subs; + _loyaltyCards = rawCards; + _subscriptions = rawSubs; _carouselSlides = (cms['carousel'] as List?) ?? []; _promos = (cms['promos'] as List?) ?? []; _isLoading = false; diff --git a/lib/screens/main_shell.dart b/lib/screens/main_shell.dart index 240347a..7f76339 100644 --- a/lib/screens/main_shell.dart +++ b/lib/screens/main_shell.dart @@ -185,9 +185,22 @@ class _MainShellState extends State { const SizedBox(width: 4), ], ), - body: IndexedStack( - index: _currentIndex, - children: _pages, + body: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + colorScheme.surfaceContainerLowest, + colorScheme.surface, + const Color(0xFFF3EAD3), // Warm traditional restaurant sand/cream + ], + ), + ), + child: IndexedStack( + index: _currentIndex, + children: _pages, + ), ), bottomNavigationBar: NavigationBar( selectedIndex: _currentIndex, diff --git a/lib/services/odoo_service.dart b/lib/services/odoo_service.dart index 5b94ac4..73c2dbe 100644 --- a/lib/services/odoo_service.dart +++ b/lib/services/odoo_service.dart @@ -48,9 +48,18 @@ class OdooService { [ ['partner_id', '=', partnerId], ['program_id.program_type', '=', 'loyalty'], + ['program_id.active', '=', true], ], ], - 'kwargs': {'fields': ['points', 'program_id', 'code']} + 'kwargs': { + 'fields': [ + 'points', + 'program_id', + 'code', + 'subscription_start_date', + 'subscription_end_date', + ] + } }) as List; } @@ -65,10 +74,12 @@ class OdooService { [ ['partner_id', '=', partnerId], ['program_id.program_type', '=', 'subscription'], + ['program_id.active', '=', true], ], ], 'kwargs': { 'fields': [ + 'points', 'program_id', 'code', 'subscription_start_date', diff --git a/lib/widgets/subscription_list_widget.dart b/lib/widgets/subscription_list_widget.dart index d45f283..2479358 100644 --- a/lib/widgets/subscription_list_widget.dart +++ b/lib/widgets/subscription_list_widget.dart @@ -187,28 +187,77 @@ class _SubscriptionCard extends StatelessWidget { ), ], ), - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - 'Validity Period', - style: theme.textTheme.bodySmall?.copyWith( - color: colorScheme.onSurfaceVariant, - fontSize: 10, - ), - ), - const SizedBox(height: 2), - Text( - '$startDate - $endDate', - style: theme.textTheme.bodyMedium?.copyWith( - color: colorScheme.onSurface, - fontWeight: FontWeight.w600, - ), - ), - ], - ), + if (sub['points'] != null) + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + 'Claim Balance', + style: theme.textTheme.bodySmall?.copyWith( + color: colorScheme.onSurfaceVariant, + fontSize: 10, + ), + ), + const SizedBox(height: 2), + Text( + '${(sub['points'] as num).toDouble() % 1 == 0 ? (sub['points'] as num).toInt() : sub['points']} Claims', + style: theme.textTheme.bodyMedium?.copyWith( + color: colorScheme.primary, + fontWeight: FontWeight.bold, + ), + ), + ], + ), ], ), + if (sub['subscription_start_date'] != null && sub['subscription_start_date'] != false) ...[ + const SizedBox(height: 12), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Valid From', + style: theme.textTheme.bodySmall?.copyWith( + color: colorScheme.onSurfaceVariant, + fontSize: 10, + ), + ), + const SizedBox(height: 2), + Text( + startDate, + style: theme.textTheme.bodyMedium?.copyWith( + color: colorScheme.onSurface, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + 'Expires On', + style: theme.textTheme.bodySmall?.copyWith( + color: colorScheme.onSurfaceVariant, + fontSize: 10, + ), + ), + const SizedBox(height: 2), + Text( + endDate, + style: theme.textTheme.bodyMedium?.copyWith( + color: colorScheme.onSurface, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ], + ), + ], ], ), ),