formatted some files
This commit is contained in:
@@ -7,50 +7,61 @@ class Branch {
|
||||
final String ifsc;
|
||||
final String address;
|
||||
|
||||
Branch({required this.name, required this.code, required this.ifsc, required this.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();
|
||||
@override
|
||||
State<BranchLocatorScreen> createState() => _BranchLocatorScreenState();
|
||||
}
|
||||
|
||||
class _BranchLocatorScreenState extends State<BranchLocatorScreen> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
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 "),
|
||||
];
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
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) {
|
||||
@@ -78,7 +89,7 @@ branch.address.toLowerCase().contains(lowerQuery);
|
||||
// label: Text( AppLocalizations.of(context).searchbranch),
|
||||
// onPressed: () {
|
||||
// // Place API here
|
||||
|
||||
|
||||
// // ScaffoldMessenger.of(context).showSnackBar(
|
||||
// // SnackBar(content: Text( AppLocalizations.of(context).branchsearchsoon)),
|
||||
// // );
|
||||
@@ -91,58 +102,62 @@ branch.address.toLowerCase().contains(lowerQuery);
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context).branchLocator),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
@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),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
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}")),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
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}")),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -74,10 +74,9 @@ class _ServiceScreen extends State<ServiceScreen> {
|
||||
label: AppLocalizations.of(context).branchLocator,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const BranchLocatorScreen())
|
||||
);
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const BranchLocatorScreen()));
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
|
Reference in New Issue
Block a user