add econtrol gasstation view and logic
This commit is contained in:
56
lib/pages/gasstations_view.dart
Normal file
56
lib/pages/gasstations_view.dart
Normal file
@@ -0,0 +1,56 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../controller/gasstations_controller.dart';
|
||||
|
||||
class GasstationsPage extends GetView<GasstationsController> {
|
||||
static const String namedRoute = '/gasstations-page';
|
||||
const GasstationsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var staCtrl = controller;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 100,
|
||||
backgroundColor: Colors.blueGrey,
|
||||
foregroundColor: Colors.white,
|
||||
title: const Text('Gas Stations'),
|
||||
),
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.blueGrey[800]!,
|
||||
Colors.blueGrey[600]!,
|
||||
Colors.blueGrey[300]!,
|
||||
Colors.blue[100]!,
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Obx(() {
|
||||
if (staCtrl.isLoading.value) {
|
||||
return const CircularProgressIndicator();
|
||||
} else if (staCtrl.eControlData.isEmpty) {
|
||||
return const Text('No gas stations found.');
|
||||
} else {
|
||||
return ListView.builder(
|
||||
itemCount: staCtrl.eControlData.length,
|
||||
itemBuilder: (context, index) {
|
||||
final station = staCtrl.eControlData[index];
|
||||
return ListTile(
|
||||
title: Text(station.name ?? 'Unknown Station'),
|
||||
subtitle: Text(station.location?.address ?? 'No address'),
|
||||
trailing: Text(station.open == true ? 'Open' : 'Closed'),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,12 @@ class HomePage extends GetView<HomeController> {
|
||||
homCtrl.onInit();
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.gas_meter),
|
||||
onPressed: () {
|
||||
homCtrl.goToGasStations();
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.collections),
|
||||
onPressed: () {
|
||||
|
||||
Reference in New Issue
Block a user