Code Formatted

This commit is contained in:
2025-11-24 18:18:36 +05:30
parent b7fe6a9d18
commit 18db360a45
19 changed files with 805 additions and 754 deletions

View File

@@ -65,9 +65,8 @@ factory Branch.fromJson(Map<String, dynamic> json) {
}
static List<Branch> listFromJson(List<dynamic> jsonList) {
final beneficiaryList = jsonList
.map((beneficiary) => Branch.fromJson(beneficiary))
.toList();
final beneficiaryList =
jsonList.map((beneficiary) => Branch.fromJson(beneficiary)).toList();
return beneficiaryList;
}
}

View File

@@ -101,7 +101,8 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
? fromDate!.add(const Duration(days: 183))
: now;
final initialToDate = toDate ?? now;
final clampedInitialToDate = initialToDate.isBefore(fromDate!) ? fromDate! : initialToDate;
final clampedInitialToDate =
initialToDate.isBefore(fromDate!) ? fromDate! : initialToDate;
final picked = await showDatePicker(
context: context,
initialDate: clampedInitialToDate,
@@ -238,8 +239,11 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
itemCount: 3,
itemBuilder: (_, __) => ListTile(
leading: Shimmer.fromColors(
baseColor: Theme.of(context).colorScheme.surfaceVariant,
highlightColor: Theme.of(context).colorScheme.onSurfaceVariant,
baseColor:
Theme.of(context).colorScheme.surfaceVariant,
highlightColor: Theme.of(context)
.colorScheme
.onSurfaceVariant,
child: CircleAvatar(
radius: 12,
backgroundColor:
@@ -247,8 +251,11 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
),
),
title: Shimmer.fromColors(
baseColor: Theme.of(context).colorScheme.surfaceVariant,
highlightColor: Theme.of(context).colorScheme.onSurfaceVariant,
baseColor:
Theme.of(context).colorScheme.surfaceVariant,
highlightColor: Theme.of(context)
.colorScheme
.onSurfaceVariant,
child: Container(
height: 10,
width: 100,
@@ -257,8 +264,11 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
),
),
subtitle: Shimmer.fromColors(
baseColor: Theme.of(context).colorScheme.surfaceVariant,
highlightColor: Theme.of(context).colorScheme.onSurfaceVariant,
baseColor:
Theme.of(context).colorScheme.surfaceVariant,
highlightColor: Theme.of(context)
.colorScheme
.onSurfaceVariant,
child: Container(
height: 8,
width: 60,
@@ -288,7 +298,9 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
? Symbols.call_received
: Symbols.call_made,
color: tx.type == 'CR'
? Theme.of(context).colorScheme.secondary
? Theme.of(context)
.colorScheme
.secondary
: Theme.of(context).colorScheme.error,
),
title: Text(
@@ -332,7 +344,8 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
);
},
separatorBuilder: (context, index) {
return Divider(color: Theme.of(context).dividerColor);
return Divider(
color: Theme.of(context).dividerColor);
},
),
),

View File

@@ -46,7 +46,8 @@ class _AllAccountsScreenState extends State<AllAccountsScreen> {
itemBuilder: (context, index) {
final user = widget.users[index];
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
padding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: _buildAccountCard(user),
);
},

View File

@@ -22,7 +22,9 @@ class BeneficiaryDetailsScreen extends StatelessWidget {
_showSuccessDialog(context);
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('${AppLocalizations.of(context).failedToDeleteBeneficiary} : $e')),
SnackBar(
content: Text(
'${AppLocalizations.of(context).failedToDeleteBeneficiary} : $e')),
);
}
}
@@ -33,7 +35,8 @@ class BeneficiaryDetailsScreen extends StatelessWidget {
builder: (BuildContext context) {
return AlertDialog(
title: Text(AppLocalizations.of(context).success),
content: Text(AppLocalizations.of(context).beneficiaryDeletedSuccessfully),
content:
Text(AppLocalizations.of(context).beneficiaryDeletedSuccessfully),
actions: <Widget>[
TextButton(
child: Text(AppLocalizations.of(context).ok),
@@ -53,8 +56,8 @@ class BeneficiaryDetailsScreen extends StatelessWidget {
builder: (BuildContext context) {
return AlertDialog(
title: Text(AppLocalizations.of(context).deleteBeneficiary),
content:
Text(AppLocalizations.of(context).areYouSureYouWantToDeleteThisBeneficiary),
content: Text(AppLocalizations.of(context)
.areYouSureYouWantToDeleteThisBeneficiary),
actions: <Widget>[
TextButton(
child: Text(AppLocalizations.of(context).cancel),

View File

@@ -17,8 +17,9 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
appBar: AppBar(
title: Text(
AppLocalizations.of(context).chequeManagement,
style:
TextStyle(color: Theme.of(context).textTheme.titleLarge?.color, fontWeight: FontWeight.w500),
style: TextStyle(
color: Theme.of(context).textTheme.titleLarge?.color,
fontWeight: FontWeight.w500),
),
centerTitle: false,
),

View File

@@ -222,7 +222,8 @@ class _DashboardScreenState extends State<DashboardScreen>
if (isSelected) // Only show toggle for selected card
InkWell(
onTap: () async {
if (isRefreshing) return; // Prevent taps while refreshing
if (isRefreshing)
return; // Prevent taps while refreshing
final accountNo = user.accountNo;
if (accountNo == null) return;
@@ -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),
);
}
@@ -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;
}
@@ -568,8 +576,10 @@ class _DashboardScreenState extends State<DashboardScreen>
},
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>
);
}
}

View File

@@ -68,8 +68,10 @@ class _EnquiryScreen extends State<EnquiryScreen> {
GestureDetector(
onTap: () => _launchPhoneNumber(phone),
child: Text(phone,
style:
TextStyle(color: Theme.of(context).colorScheme.primary)), // Changed color for visibility
style: TextStyle(
color: Theme.of(context)
.colorScheme
.primary)), // Changed color for visibility
),
],
);
@@ -91,14 +93,16 @@ class _EnquiryScreen extends State<EnquiryScreen> {
children: [
const SizedBox(height: 20),
GestureDetector(
onTap: () => _launchUrl("https://kccbhp.bank.in/complaint-form/"),
onTap: () =>
_launchUrl("https://kccbhp.bank.in/complaint-form/"),
child: Row(mainAxisSize: MainAxisSize.min, children: [
Text(
"Complaint Form",
style: TextStyle(
fontSize: 17,
color: Theme.of(context).colorScheme.primary,
decoration: TextDecoration.underline, // Added underline for link clarity
decoration: TextDecoration
.underline, // Added underline for link clarity
decorationColor:
Theme.of(context).colorScheme.primary,
),

View File

@@ -492,7 +492,8 @@ class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
},
),
const SizedBox(height: 8),
if (_isLoadingLimit) Text(AppLocalizations.of(context).fetchingDailyLimit),
if (_isLoadingLimit)
Text(AppLocalizations.of(context).fetchingDailyLimit),
if (!_isLoadingLimit && _limit != null)
Text(
'Remaining Daily Limit: ${_formatCurrency.format(_limit!.dailyLimit - _limit!.usedLimit)}',

View File

@@ -148,7 +148,8 @@ class FundTransferManagementTile extends StatelessWidget {
),
elevation: 4, // Add some elevation for better visual separation
child: InkWell(
onTap: disable ? null : onTap, // Disable InkWell if the tile is disabled
onTap:
disable ? null : onTap, // Disable InkWell if the tile is disabled
borderRadius: BorderRadius.circular(12.0),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 16.0),

View File

@@ -17,7 +17,11 @@ class ProfileScreen extends StatefulWidget {
final String mobileNumber;
final String customerNo;
final String customerName;
const ProfileScreen({super.key, required this.mobileNumber, required this.customerNo, required this.customerName});
const ProfileScreen(
{super.key,
required this.mobileNumber,
required this.customerNo,
required this.customerName});
@override
State<ProfileScreen> createState() => _ProfileScreenState();
@@ -357,8 +361,8 @@ Widget build(BuildContext context) {
Text(
widget.customerNo,
style: theme.textTheme.bodyMedium?.copyWith(
color:
theme.colorScheme.onSurface.withOpacity(0.7),
color: theme.colorScheme.onSurface
.withOpacity(0.7),
),
),
],
@@ -611,8 +615,7 @@ class _SectionTile extends StatelessWidget {
? Icon(Icons.chevron_right, color: theme.colorScheme.onSurface)
: null,
onTap: onTap,
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),

View File

@@ -57,7 +57,8 @@ class SecuritySettingsScreen extends StatelessWidget {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(loc.mpinChangedSuccessfully),
backgroundColor: Theme.of(context).colorScheme.secondary,
backgroundColor:
Theme.of(context).colorScheme.secondary,
),
);
}

View File

@@ -108,7 +108,8 @@ class QuickPayManagementTile extends StatelessWidget {
),
elevation: 4, // Add some elevation for better visual separation
child: InkWell(
onTap: disable ? null : onTap, // Disable InkWell if the tile is disabled
onTap:
disable ? null : onTap, // Disable InkWell if the tile is disabled
borderRadius: BorderRadius.circular(12.0),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 36.0, horizontal: 16.0),

View File

@@ -15,10 +15,12 @@ class ATMLocatorScreen extends StatefulWidget {
class _ATMLocatorScreenState extends State<ATMLocatorScreen> {
final TextEditingController _searchController = TextEditingController();
var service = getIt<BranchService>(); // Added: Instance of BranchService for API calls
var service =
getIt<BranchService>(); // Added: Instance of BranchService for API calls
bool _isLoading = true; // State variable to manage loading status
List<Atm> _allAtms = []; // Changed: List to hold all fetched Atm objects
List<Atm> _filteredAtms = []; // Changed: List to hold filtered Atm objects for display
List<Atm> _filteredAtms =
[]; // Changed: List to hold filtered Atm objects for display
@override
void initState() {
@@ -28,7 +30,8 @@ class _ATMLocatorScreenState extends State<ATMLocatorScreen> {
/// Fetches the list of ATMs from the API using BranchService.
Future<void> _loadAtms() async {
final data = await service.fetchAtmList(); // Call the new fetchAtmList method
final data =
await service.fetchAtmList(); // Call the new fetchAtmList method
setState(() {
_allAtms = data; // Update the list of all ATMs
_filteredAtms = data; // Initialize filtered list with all ATMs
@@ -37,14 +40,18 @@ class _ATMLocatorScreenState extends State<ATMLocatorScreen> {
}
/// Filters the list of ATMs based on the search query.
void _filterAtms(String query) { // Changed: Renamed from _filterLocations
void _filterAtms(String query) {
// Changed: Renamed from _filterLocations
setState(() {
if (query.isEmpty) {
_filteredAtms = _allAtms; // If query is empty, show all ATMs
} else {
_filteredAtms = _allAtms.where((atm) { // Changed: Filter based on Atm object
_filteredAtms = _allAtms.where((atm) {
// Changed: Filter based on Atm object
final lowerQuery = query.toLowerCase();
return atm.name.toLowerCase().contains(lowerQuery); // Filter by atm.name
return atm.name
.toLowerCase()
.contains(lowerQuery); // Filter by atm.name
}).toList();
}
});
@@ -64,7 +71,8 @@ class _ATMLocatorScreenState extends State<ATMLocatorScreen> {
padding: const EdgeInsets.all(12.0),
child: TextField(
controller: _searchController,
onChanged: _filterAtms, // Updated: Call _filterAtms on text change
onChanged:
_filterAtms, // Updated: Call _filterAtms on text change
decoration: InputDecoration(
hintText: "Name/Address", // Hint text for the search bar
prefixIcon: const Icon(Icons.search), // Search icon
@@ -81,12 +89,16 @@ class _ATMLocatorScreenState extends State<ATMLocatorScreen> {
? _buildShimmerList() // Display shimmer while loading
: _filteredAtms.isEmpty
? const Center(
child: Text("No matching ATMs found")) // Message if no ATMs found
child: Text(
"No matching ATMs found")) // Message if no ATMs found
: ListView.builder(
itemCount: _filteredAtms.length, // Number of items in the filtered list
itemCount: _filteredAtms
.length, // Number of items in the filtered list
itemBuilder: (context, index) {
final atm = _filteredAtms[index]; // Get the current Atm object
return _buildAtmItem(atm); // Build the ATM list item
final atm = _filteredAtms[
index]; // Get the current Atm object
return _buildAtmItem(
atm); // Build the ATM list item
},
),
),
@@ -111,9 +123,9 @@ class _ATMLocatorScreenState extends State<ATMLocatorScreen> {
);
}
/// Helper widget to build a single ATM list item.
Widget _buildAtmItem(Atm atm) { // Changed: Takes an Atm object
Widget _buildAtmItem(Atm atm) {
// Changed: Takes an Atm object
return Card(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
child: ListTile(

View File

@@ -81,7 +81,8 @@
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: theme.colorScheme.primary, // Indicate it's clickable
color:
theme.colorScheme.primary, // Indicate it's clickable
decoration: TextDecoration.underline,
),
),
@@ -98,6 +99,7 @@
),
);
}
Future<void> _launchUrl(String urlString) async {
final Uri url = Uri.parse(urlString);
if (!await launchUrl(url)) {

View File

@@ -7,7 +7,6 @@ import 'package:kmobile/di/injection.dart';
import 'package:shimmer/shimmer.dart';
import 'package:kmobile/features/service/screens/branch_details_screen.dart';
class BranchLocatorScreen extends StatefulWidget {
const BranchLocatorScreen({super.key});
@@ -51,7 +50,6 @@ class BranchLocatorScreen extends StatefulWidget {
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -88,11 +86,13 @@ class BranchLocatorScreen extends StatefulWidget {
? _buildShimmerList() // Changed to shimmer
: _filteredBranches.isEmpty
? const Center(
child: Text("No matching branches found")) // Updated tex
child: Text(
"No matching branches found")) // Updated tex
: ListView.builder(
itemCount: _filteredBranches.length,
itemBuilder: (context, index) {
final branch = _filteredBranches[index]; // Changed to
final branch =
_filteredBranches[index]; // Changed to
return _buildBranchItem(branch); // Updated
},
),
@@ -155,7 +155,6 @@ class BranchLocatorScreen extends StatefulWidget {
);
}
// Shimmer loading list
Widget _buildShimmerList() {
return ListView.builder(

View File

@@ -52,7 +52,8 @@ class _ServiceScreen extends State<ServiceScreen> {
label: AppLocalizations.of(context).faq,
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => const FaqsScreen()),
MaterialPageRoute(
builder: (context) => const FaqsScreen()),
);
},
disabled: false,
@@ -120,7 +121,8 @@ class ServiceManagementTile extends StatelessWidget {
),
elevation: 4, // Add some elevation for better visual separation
child: InkWell(
onTap: disabled ? null : onTap, // Disable InkWell if the tile is disabled
onTap:
disabled ? null : onTap, // Disable InkWell if the tile is disabled
borderRadius: BorderRadius.circular(12.0),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 16.0),
@@ -130,7 +132,8 @@ class ServiceManagementTile extends StatelessWidget {
Icon(
icon,
size: 48, // Make icon larger
color: disabled ? theme.disabledColor : theme.colorScheme.primary,
color:
disabled ? theme.disabledColor : theme.colorScheme.primary,
),
const SizedBox(height: 12),
Text(
@@ -138,7 +141,9 @@ class ServiceManagementTile extends StatelessWidget {
textAlign: TextAlign.center,
style: theme.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
color: disabled ? theme.disabledColor : theme.colorScheme.onSurface,
color: disabled
? theme.disabledColor
: theme.colorScheme.onSurface,
),
),
],