Code Formatted
This commit is contained in:
@@ -125,143 +125,144 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
child: Transform.translate(
|
||||
offset: isSelected ? const Offset(10.0, 0.0) : Offset.zero,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 2),
|
||||
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
|
||||
margin: const EdgeInsets.symmetric(horizontal: 2),
|
||||
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(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -325,8 +326,7 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
return Shimmer.fromColors(
|
||||
baseColor: theme.colorScheme.primary,
|
||||
highlightColor: theme.colorScheme.onPrimary,
|
||||
child: Container(
|
||||
height: 36, color: theme.scaffoldBackgroundColor),
|
||||
child: Container(height: 36, color: theme.scaffoldBackgroundColor),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -445,8 +445,8 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
onTap: () {
|
||||
final authState = context.read<AuthCubit>().state;
|
||||
String mobileNumberToPass = '';
|
||||
String customerNo ='';
|
||||
String customerName = '';
|
||||
String customerNo = '';
|
||||
String customerName = '';
|
||||
if (authState is Authenticated) {
|
||||
if (selectedAccountIndex >= 0 &&
|
||||
selectedAccountIndex < authState.users.length) {
|
||||
@@ -454,7 +454,7 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
authState.users[selectedAccountIndex].mobileNo ?? '';
|
||||
customerNo =
|
||||
authState.users[selectedAccountIndex].cifNumber ?? '';
|
||||
customerName=
|
||||
customerName =
|
||||
authState.users[selectedAccountIndex].name ?? '';
|
||||
}
|
||||
}
|
||||
@@ -462,8 +462,10 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
ProfileScreen(mobileNumber: mobileNumberToPass, customerNo: customerNo, customerName: customerName),
|
||||
builder: (context) => ProfileScreen(
|
||||
mobileNumber: mobileNumberToPass,
|
||||
customerNo: customerNo,
|
||||
customerName: customerName),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -535,25 +537,31 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
|
||||
// Account Info Cards
|
||||
ClipRect(
|
||||
child: SizedBox( // This SizedBox defines the height for the Stack
|
||||
child: SizedBox(
|
||||
// This SizedBox defines the height for the Stack
|
||||
height: 160,
|
||||
child: Stack(
|
||||
children: [
|
||||
// PageView part, painted underneath
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 48.0), // Space for tab (40) + gap (8)
|
||||
child: SizedBox( // Keep SizedBox for PageView height
|
||||
padding: const EdgeInsets.only(
|
||||
left: 48.0), // Space for tab (40) + gap (8)
|
||||
child: SizedBox(
|
||||
// Keep SizedBox for PageView height
|
||||
height: 160,
|
||||
child: PageView.builder(
|
||||
controller: _pageController,
|
||||
itemCount: users.length,
|
||||
clipBehavior: Clip.none, // Keep this to show adjacent cards
|
||||
clipBehavior: Clip
|
||||
.none, // Keep this to show adjacent cards
|
||||
padEnds: false,
|
||||
onPageChanged: (int newIndex) async {
|
||||
if (newIndex == selectedAccountIndex) return;
|
||||
if (newIndex == selectedAccountIndex)
|
||||
return;
|
||||
|
||||
// Hide the balance of the old card when scrolling away
|
||||
final oldAccountNo = users[selectedAccountIndex].accountNo;
|
||||
final oldAccountNo =
|
||||
users[selectedAccountIndex].accountNo;
|
||||
if (oldAccountNo != null) {
|
||||
_visibilityMap[oldAccountNo] = false;
|
||||
}
|
||||
@@ -561,15 +569,17 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
setState(() {
|
||||
selectedAccountIndex = newIndex;
|
||||
});
|
||||
|
||||
|
||||
await _loadTransactions(
|
||||
users[newIndex].accountNo!,
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
final user = users[index];
|
||||
final isSelected = index == selectedAccountIndex;
|
||||
return _buildAccountCard(user, isSelected);
|
||||
final isSelected =
|
||||
index == selectedAccountIndex;
|
||||
return _buildAccountCard(
|
||||
user, isSelected);
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -715,7 +725,6 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -777,9 +786,7 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
Icon(
|
||||
icon,
|
||||
size: 30,
|
||||
color: disable
|
||||
? theme.disabledColor
|
||||
: theme.colorScheme.primary,
|
||||
color: disable ? theme.disabledColor : theme.colorScheme.primary,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
@@ -788,9 +795,8 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
color: disable
|
||||
? theme.disabledColor
|
||||
: theme.colorScheme.onSurface,
|
||||
color:
|
||||
disable ? theme.disabledColor : theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -799,4 +805,3 @@ class _DashboardScreenState extends State<DashboardScreen>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user