feat: update UI theme and improve subscription data fetching and display logic

This commit is contained in:
Suherdy Yacob 2026-06-14 11:52:37 +07:00
parent afa528abd6
commit 6ff44041f0
4 changed files with 99 additions and 44 deletions

View File

@ -40,28 +40,10 @@ class _LoyaltyDashboardState extends State<LoyaltyDashboard> {
final rawSubs = results[1] as List<dynamic>;
final cms = results[2] as Map<String, dynamic>;
final List<dynamic> cards = [];
final List<dynamic> 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<dynamic>?) ?? [];
_promos = (cms['promos'] as List<dynamic>?) ?? [];
_isLoading = false;

View File

@ -185,9 +185,22 @@ class _MainShellState extends State<MainShell> {
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,

View File

@ -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<dynamic>;
}
@ -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',

View File

@ -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,
),
),
],
),
],
),
],
],
),
),