164 lines
5.1 KiB
Dart
164 lines
5.1 KiB
Dart
import '../../../l10n/app_localizations.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class Branch {
|
|
final String name;
|
|
final String code;
|
|
final String ifsc;
|
|
final String address;
|
|
|
|
Branch({
|
|
required this.name,
|
|
required this.code,
|
|
required this.ifsc,
|
|
required this.address,
|
|
});
|
|
}
|
|
|
|
class BranchLocatorScreen extends StatefulWidget {
|
|
const BranchLocatorScreen({super.key});
|
|
|
|
@override
|
|
State<BranchLocatorScreen> createState() => _BranchLocatorScreenState();
|
|
}
|
|
|
|
class _BranchLocatorScreenState extends State<BranchLocatorScreen> {
|
|
final TextEditingController _searchController = TextEditingController();
|
|
|
|
// Static list of 5 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, Kangra, HP "),
|
|
];
|
|
|
|
List<Branch> _filteredBranches = [];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_filteredBranches = _branches; // Initially show all branches
|
|
}
|
|
|
|
void _filterBranches(String query) {
|
|
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();
|
|
}
|
|
});
|
|
}
|
|
|
|
// @override
|
|
// Widget build(BuildContext context) {
|
|
// return Scaffold(
|
|
// appBar: AppBar(
|
|
// title: Text(AppLocalizations.of(context).branchLocator),
|
|
// ),
|
|
// body: Center(
|
|
// child: Column(
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
// children: [
|
|
// Icon(
|
|
// Icons.location_on,
|
|
// size: 80,
|
|
// color: Theme.of(context).primaryColor,
|
|
// ),
|
|
// const SizedBox(height: 16),
|
|
// Text(
|
|
// AppLocalizations.of(context).findnearbybranched,
|
|
// style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
|
// ),
|
|
// const SizedBox(height: 24),
|
|
// ElevatedButton.icon(
|
|
// icon: const Icon(Icons.search),
|
|
// label: Text( AppLocalizations.of(context).searchbranch),
|
|
// onPressed: () {
|
|
// // Place API here
|
|
|
|
// // ScaffoldMessenger.of(context).showSnackBar(
|
|
// // SnackBar(content: Text( AppLocalizations.of(context).branchsearchsoon)),
|
|
// // );
|
|
// },
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// );
|
|
// }
|
|
// }
|
|
|
|
@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).primaryColor),
|
|
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}")),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|