Code Formatted
This commit is contained in:
@@ -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});
|
||||
|
||||
@@ -15,52 +14,51 @@ class BranchLocatorScreen extends StatefulWidget {
|
||||
State<BranchLocatorScreen> createState() => _BranchLocatorScreenState();
|
||||
}
|
||||
|
||||
class _BranchLocatorScreenState extends State<BranchLocatorScreen> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
var service = getIt<BranchService>();
|
||||
bool _isLoading = true;
|
||||
List<Branch> _allBranches = [];
|
||||
List<Branch> _filteredBranches = [];
|
||||
class _BranchLocatorScreenState extends State<BranchLocatorScreen> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
var service = getIt<BranchService>();
|
||||
bool _isLoading = true;
|
||||
List<Branch> _allBranches = [];
|
||||
List<Branch> _filteredBranches = [];
|
||||
|
||||
@override
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// _fetchAndSetLocations();
|
||||
_loadBranches();
|
||||
}
|
||||
|
||||
Future<void> _loadBranches() async {
|
||||
final data = await service.fetchBranchList();
|
||||
setState(() {
|
||||
_allBranches = data;
|
||||
_filteredBranches = data;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
Future<void> _loadBranches() async {
|
||||
final data = await service.fetchBranchList();
|
||||
setState(() {
|
||||
_allBranches = data;
|
||||
_filteredBranches = data;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
void _filterBranches(String query) {
|
||||
setState(() {
|
||||
if (query.isEmpty) {
|
||||
_filteredBranches = _allBranches;
|
||||
} else {
|
||||
_filteredBranches = _allBranches.where((branch) {
|
||||
final lowerQuery = query.toLowerCase();
|
||||
return branch.branch_name.toLowerCase().contains(lowerQuery);
|
||||
}).toList();
|
||||
}
|
||||
});
|
||||
}
|
||||
setState(() {
|
||||
if (query.isEmpty) {
|
||||
_filteredBranches = _allBranches;
|
||||
} else {
|
||||
_filteredBranches = _allBranches.where((branch) {
|
||||
final lowerQuery = query.toLowerCase();
|
||||
return branch.branch_name.toLowerCase().contains(lowerQuery);
|
||||
}).toList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
"Branch Locator",
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Stack(
|
||||
@@ -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
|
||||
},
|
||||
),
|
||||
@@ -132,7 +132,7 @@ class BranchLocatorScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
// Helper widget to build a single branch item
|
||||
|
||||
|
||||
Widget _buildBranchItem(Branch branch) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
@@ -155,7 +155,6 @@ class BranchLocatorScreen extends StatefulWidget {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Shimmer loading list
|
||||
Widget _buildShimmerList() {
|
||||
return ListView.builder(
|
||||
|
||||
Reference in New Issue
Block a user