FAQs link added and Branch and ATM locator updated

This commit is contained in:
2025-09-25 12:56:03 +05:30
parent cc7c7a8042
commit 0e4072fe8f
5 changed files with 192 additions and 117 deletions

View File

@@ -1,17 +1,22 @@
import '../../../l10n/app_localizations.dart';
import 'package:flutter/material.dart';
import '../../../l10n/app_localizations.dart';
class Branch {
// Enum to define the type of location
enum LocationType { branch, atm }
class Location {
final String name;
final String code;
final String ifsc;
final String? code; // Nullable for ATMs
final String? ifsc; // Nullable for ATMs
final String address;
final LocationType type;
Branch({
Location({
required this.name,
required this.code,
required this.ifsc,
this.code,
this.ifsc,
required this.address,
required this.type,
});
}
@@ -22,103 +27,160 @@ class BranchLocatorScreen extends StatefulWidget {
State<BranchLocatorScreen> createState() => _BranchLocatorScreenState();
}
class _BranchLocatorScreenState extends State<BranchLocatorScreen> {
final TextEditingController _searchController = TextEditingController();
class _BranchLocatorScreenState extends State<BranchLocatorScreen> {
final TextEditingController _searchController = TextEditingController();
// Static list of 2 branches
final List<Branch> _branches = [
Branch(
name: "Dharamsala - Head Office",
code: "002",
ifsc: "KACE0000002",
address: "Civil Lines Dharmashala, Kangra, HP - 176215"),
Branch(
name: "Kangra",
code: "033",
ifsc: "KACE0000033",
address: "Rajput Bhawankangrapo, Kangra, HP "),
];
final List<Location> _allLocations = [
Location(
name: "Dharamsala - Head Office",
code: "002",
ifsc: "KACE0000002",
address: "Civil Lines Dharmashala, Kangra, HP - 176215",
type: LocationType.branch,
),
Location(
name: "Kangra",
code: "033",
ifsc: "KACE0000033",
address: "Rajput Bhawankangrapo, Kangra, HP ",
type: LocationType.branch,
),
Location(
name: "Dharamsala ATM",
address: "Near Main Square, Dharamsala",
type: LocationType.atm,
),
Location(
name: "Kangra ATM",
address: "Opposite Bus Stand, Kangra",
type: LocationType.atm,
),
];
List<Branch> _filteredBranches = [];
List<Location> _filteredLocations = [];
bool _isLoading = false;
@override
void initState() {
super.initState();
_filteredBranches = _branches; // Initially show all branches
}
@override
void initState() {
super.initState();
// _fetchAndSetLocations();
_filteredLocations = _allLocations;
}
void _filterBranches(String query) {
// Example of a future API fetching function
/*
Future<void> _fetchAndSetLocations() async {
setState(() {
_isLoading = true;
});
try {
// final locations = await yourApiService.getLocations();
// setState(() {
// _allLocations = locations;
// _filteredLocations = locations;
// });
} catch (e) {
// Handle error
} finally {
setState(() {
if (query.isEmpty) {
_filteredBranches = _branches;
} else {
_filteredBranches = _branches.where((branch) {
final lowerQuery = query.toLowerCase();
return branch.name.toLowerCase().contains(lowerQuery) ||
branch.code.toLowerCase().contains(lowerQuery) ||
branch.ifsc.toLowerCase().contains(lowerQuery) ||
branch.address.toLowerCase().contains(lowerQuery);
}).toList();
}
_isLoading = false;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).branchLocator),
),
body: Column(
children: [
// Search bar
Padding(
padding: const EdgeInsets.all(12.0),
child: TextField(
controller: _searchController,
onChanged: _filterBranches,
decoration: InputDecoration(
hintText: AppLocalizations.of(context).searchbranchby,
prefixIcon: const Icon(Icons.search),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
// List of branches
Expanded(
child: _filteredBranches.isEmpty
? const Center(child: Text("No matching branches found"))
: ListView.builder(
itemCount: _filteredBranches.length,
itemBuilder: (context, index) {
final branch = _filteredBranches[index];
return Card(
margin: const EdgeInsets.symmetric(
horizontal: 12, vertical: 6),
child: ListTile(
leading: Icon(Icons.location_city,
color: Theme.of(context).colorScheme.primary),
title: Text(branch.name,
style:
const TextStyle(fontWeight: FontWeight.bold)),
subtitle: Text(
"Code: ${branch.code} | IFSC: ${branch.ifsc} \nBranch Address: ${branch.address}"),
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("Selected ${branch.name}")),
);
},
),
);
},
),
),
],
),
);
}
}
*/
void _filterLocations(String query) {
setState(() {
if (query.isEmpty) {
_filteredLocations = _allLocations;
} else {
_filteredLocations = _allLocations.where((location) {
final lowerQuery = query.toLowerCase();
return location.name.toLowerCase().contains(lowerQuery) ||
(location.code?.toLowerCase().contains(lowerQuery) ?? false) ||
(location.ifsc?.toLowerCase().contains(lowerQuery) ?? false) ||
location.address.toLowerCase().contains(lowerQuery);
}).toList();
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).branchLocator),
),
body: Column(
children: [
Padding(
padding: const EdgeInsets.all(12.0),
child: TextField(
controller: _searchController,
onChanged: _filterLocations,
decoration: InputDecoration(
hintText: AppLocalizations.of(context).searchbranchby,
prefixIcon: const Icon(Icons.search),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
// Content area
Expanded(
child: _isLoading
? const Center(child: CircularProgressIndicator())
: _filteredLocations.isEmpty
? const Center(child: Text("No matching locations found"))
: ListView.builder(
itemCount: _filteredLocations.length,
itemBuilder: (context, index) {
final location = _filteredLocations[index];
return _buildLocationItem(location);
},
),
),
],
),
);
}
Widget _buildHeader(String title) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Text(
title,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary,
),
),
);
}
// Helper widget to build a single location item
Widget _buildLocationItem(Location location) {
final isBranch = location.type == LocationType.branch;
return Card(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
child: ListTile(
leading: CircleAvatar(
child: Icon(isBranch ? Icons.location_city : Icons.currency_rupee),
),
title: Text(location.name,
style: const TextStyle(fontWeight: FontWeight.bold)),
subtitle: Text(
isBranch
? "Code: ${location.code} | IFSC: ${location.ifsc}\nAddress: ${location.address}"
: "Address: ${location.address}",
),
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Selected ${location.name}")),
);
},
),
);
}
}

View File

@@ -29,23 +29,30 @@ Widget build(BuildContext context) {
icon: Symbols.add,
label: AppLocalizations.of(context).accountOpeningDeposit,
onTap: () {},
disabled: true, // Add this
disabled: true,
),
const Divider(height: 1),
ServiceManagementTile(
icon: Symbols.add,
label: AppLocalizations.of(context).accountOpeningLoan,
onTap: () {},
disabled: true, // Add this
disabled: true,
),
const Divider(height: 1),
ServiceManagementTile(
icon: Symbols.captive_portal,
label: AppLocalizations.of(context).quickLinks,
onTap: () {},
disabled: true, // Add this
disabled: true,
),
const Divider(height: 1),
ServiceManagementTile(
icon: Symbols.question_mark,
label: AppLocalizations.of(context).faq,
onTap: () {},
disabled: true,
),
const Divider(height: 1),
ServiceManagementTile(
icon: Symbols.missing_controller,
label: AppLocalizations.of(context).branchLocator,
@@ -55,7 +62,7 @@ Widget build(BuildContext context) {
MaterialPageRoute(
builder: (context) => const BranchLocatorScreen()));
},
disabled: true, // Add this
disabled: false,
),
const Divider(height: 1),
],
@@ -68,14 +75,14 @@ class ServiceManagementTile extends StatelessWidget {
final IconData icon;
final String label;
final VoidCallback onTap;
final bool disabled; // Add this line
final bool disabled;
const ServiceManagementTile({
super.key,
required this.icon,
required this.label,
required this.onTap,
this.disabled = false, // Add this line
this.disabled = false,
});
@override
@@ -84,20 +91,20 @@ class ServiceManagementTile extends StatelessWidget {
return ListTile(
leading: Icon(
icon,
color: disabled ? theme.disabledColor : null, // Change color when disabled
color: disabled ? theme.disabledColor : null,
),
title: Text(
label,
style: TextStyle(
color: disabled ? theme.disabledColor : null, // Change color when disabled
color: disabled ? theme.disabledColor : null,
),
),
trailing: Icon(
Symbols.arrow_right,
size: 20,
color: disabled ? theme.disabledColor : null, // Change color when disabled
color: disabled ? theme.disabledColor : null,
),
onTap: disabled ? null : onTap, // Disable onTap when disabled
onTap: disabled ? null : onTap,
);
}
}