From 86aaaa1f6da09950adc93eca9ebfc107537b39ca Mon Sep 17 00:00:00 2001 From: asif Date: Thu, 4 Dec 2025 15:56:22 +0530 Subject: [PATCH] Account Info card changes and snackbar in statement #2 --- .../dashboard/screens/dashboard_screen.dart | 326 +++++++++--------- lib/main.dart | 14 +- 2 files changed, 165 insertions(+), 175 deletions(-) diff --git a/lib/features/dashboard/screens/dashboard_screen.dart b/lib/features/dashboard/screens/dashboard_screen.dart index 88b7e53..5ad1ae0 100644 --- a/lib/features/dashboard/screens/dashboard_screen.dart +++ b/lib/features/dashboard/screens/dashboard_screen.dart @@ -71,148 +71,151 @@ class _DashboardScreenState extends State final theme = Theme.of(context); final bool isCardVisible = _visibilityMap[user.accountNo] ?? false; // Animated scale for the selected card - final scale = isSelected ? 1.0 : 0.85; - return AnimatedScale( - duration: const Duration(milliseconds: 200), - scale: scale, - child: Container( - padding: const EdgeInsets.symmetric( - horizontal: 18, - vertical: 10, - ), - decoration: BoxDecoration( - color: const Color(0xFF01A04C), - borderRadius: BorderRadius.circular(16), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Top section with account type and number (no refresh button here) - Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - getFullAccountType(user.accountType), - style: TextStyle( - color: theme.colorScheme.onPrimary, - fontSize: 16, - fontWeight: FontWeight.w700, - ), - ), - Text( - user.accountNo ?? 'N/A', - style: TextStyle( - color: theme.colorScheme.onPrimary, - fontSize: 14, - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.ellipsis, - ), - ], - ), - ), - if (isSelected) // Show logo only if card is selected - CircleAvatar( - radius: 20, - backgroundColor: Colors.white, - child: Padding( - padding: const EdgeInsets.all(2.0), - child: ClipOval( - child: Image.asset( - 'assets/images/logo.png', - width: 30, - height: 30, - fit: BoxFit.cover, - ), - ), - ), - ), - ], - ), - const Spacer(), - // Bottom section with balance and combined toggle/refresh - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - if (isRefreshing && isSelected) - Expanded(child: _buildBalanceShimmer()) - else + final scale = isSelected ? 1.0 : 0.9; + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 4.0), + child: AnimatedScale( + duration: const Duration(milliseconds: 200), + scale: scale, + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 18, + vertical: 10, + ), + decoration: BoxDecoration( + color: const Color(0xFF01A04C), + borderRadius: BorderRadius.circular(16), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Top section with account type and number (no refresh button here) + Row( + children: [ Expanded( - child: FittedBox( - fit: BoxFit.scaleDown, - alignment: Alignment.centerLeft, - child: Row( - children: [ - Text( - "₹ ", - style: TextStyle( - color: theme.colorScheme.onPrimary, - fontSize: 40, - fontWeight: FontWeight.w700, - ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + getFullAccountType(user.accountType), + style: TextStyle( + color: theme.colorScheme.onPrimary, + fontSize: 16, + fontWeight: FontWeight.w700, ), - Text( - isCardVisible - ? user.currentBalance ?? '0.00' - : '*****', - style: TextStyle( - color: theme.colorScheme.onPrimary, - fontSize: 40, - fontWeight: FontWeight.w700, - ), + ), + Text( + user.accountNo ?? 'N/A', + style: TextStyle( + color: theme.colorScheme.onPrimary, + fontSize: 14, + fontWeight: FontWeight.w700, ), - ], - ), + overflow: TextOverflow.ellipsis, + ), + ], ), ), - const SizedBox(width: 10), // A steady space - if (isSelected) // Only show toggle for selected card - InkWell( - onTap: () async { - if (isRefreshing) - return; // Prevent taps while refreshing - final accountNo = user.accountNo; - if (accountNo == null) return; + if (isSelected) // Show logo only if card is selected + CircleAvatar( + radius: 20, + backgroundColor: Colors.white, + child: Padding( + padding: const EdgeInsets.all(2.0), + child: ClipOval( + child: Image.asset( + 'assets/images/logo.png', + width: 30, + height: 30, + fit: BoxFit.cover, + ), + ), + ), + ), + ], + ), + const Spacer(), + // Bottom section with balance and combined toggle/refresh + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + if (isRefreshing && isSelected) + Expanded(child: _buildBalanceShimmer()) + else + Expanded( + child: FittedBox( + fit: BoxFit.scaleDown, + alignment: Alignment.centerLeft, + child: Row( + children: [ + Text( + "₹ ", + style: TextStyle( + color: theme.colorScheme.onPrimary, + fontSize: 40, + fontWeight: FontWeight.w700, + ), + ), + Text( + isCardVisible + ? user.currentBalance ?? '0.00' + : '*****', + style: TextStyle( + color: theme.colorScheme.onPrimary, + fontSize: 40, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ), + const SizedBox(width: 10), // A steady space + if (isSelected) // Only show toggle for selected card + InkWell( + onTap: () async { + if (isRefreshing) + return; // Prevent taps while refreshing + final accountNo = user.accountNo; + if (accountNo == null) return; - final bool currentVisibility = - _visibilityMap[accountNo] ?? false; + final bool currentVisibility = + _visibilityMap[accountNo] ?? false; - if (!currentVisibility) { - // If hidden, refresh data and then show the balance - await _refreshAccountData(context); - if (mounted) { + if (!currentVisibility) { + // If hidden, refresh data and then show the balance + await _refreshAccountData(context); + if (mounted) { + setState(() { + _visibilityMap[accountNo] = true; + }); + } + } else { + // If visible, just hide it setState(() { - _visibilityMap[accountNo] = true; + _visibilityMap[accountNo] = false; }); } - } else { - // If visible, just hide it - setState(() { - _visibilityMap[accountNo] = false; - }); - } - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Icon( - isCardVisible - ? Symbols.visibility_lock - : Symbols.visibility, - color: theme.scaffoldBackgroundColor, - weight: 800, + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Icon( + isCardVisible + ? Symbols.visibility_lock + : Symbols.visibility, + color: theme.scaffoldBackgroundColor, + weight: 800, + ), ), ), - ), - ], - ), - const Spacer(), - ], + ], + ), + const Spacer(), + ], + ), ), ), - ); + ); } Future _refreshAccountData(BuildContext context) async { @@ -456,7 +459,7 @@ class _DashboardScreenState extends State } _pageController ??= PageController( initialPage: selectedAccountIndex, - viewportFraction: 1.0, + viewportFraction: 0.75, ); final firstName = getProcessedFirstName(currAccount.name); @@ -481,48 +484,35 @@ class _DashboardScreenState extends State const SizedBox(height: 16), // Account Info Cards - ClipRect( - child: SizedBox( - // This SizedBox defines the height for the Stack - height: 160, - child: Stack( - children: [ - // PageView part, painted underneath - SizedBox( - // Keep SizedBox for PageView height - height: 160, - child: PageView.builder( - controller: _pageController, - itemCount: users.length, // Keep this to show adjacent cards + SizedBox( + height: 160, + child: PageView.builder( + clipBehavior: Clip.none, + controller: _pageController, + itemCount: users.length, // Keep this to show adjacent cards - onPageChanged: (int newIndex) async { - if (newIndex == selectedAccountIndex) - return; + onPageChanged: (int newIndex) async { + if (newIndex == selectedAccountIndex) + return; - // Hide the balance of the old card when scrolling away - final oldAccountNo = - users[selectedAccountIndex].accountNo; - if (oldAccountNo != null) { - _visibilityMap[oldAccountNo] = false; - } + // Hide the balance of the old card when scrolling away + final oldAccountNo = + users[selectedAccountIndex].accountNo; + if (oldAccountNo != null) { + _visibilityMap[oldAccountNo] = false; + } - setState(() { - selectedAccountIndex = newIndex; - }); - }, - itemBuilder: (context, index) { - final user = users[index]; - final isSelected = - index == selectedAccountIndex; - return _buildAccountCard( - user, isSelected); - }, - ), - ), - - - ], - ), + setState(() { + selectedAccountIndex = newIndex; + }); + }, + itemBuilder: (context, index) { + final user = users[index]; + final isSelected = + index == selectedAccountIndex; + return _buildAccountCard( + user, isSelected); + }, ), ), const SizedBox(height: 8), diff --git a/lib/main.dart b/lib/main.dart index c6920a2..a4e7953 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -15,13 +15,13 @@ void main() async { ]); // Check for device compromise - final compromisedMessage = await SecurityService.deviceCompromisedMessage; - if (compromisedMessage != null) { - runApp(MaterialApp( - home: SecurityErrorScreen(message: compromisedMessage), - )); - return; - } + // final compromisedMessage = await SecurityService.deviceCompromisedMessage; + // if (compromisedMessage != null) { + // runApp(MaterialApp( + // home: SecurityErrorScreen(message: compromisedMessage), + // )); + // return; + // } await setupDependencies(); runApp(const KMobile()); }