MyNewAppWriteTankApp/lib/pages/tanklist/tanklist_view.dart
2025-08-26 09:12:36 +02:00

163 lines
6.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import './tanklist_controller.dart';
import './widgets/my_list_tile_item.dart';
class TanklistPage extends GetView<TanklistController> {
static const namedRoute = '/tank-stop-liste-page';
const TanklistPage({super.key});
@override
Widget build(BuildContext context) {
var tankListCtrl = controller;
return PopScope(
canPop: false,
child: SafeArea(
child: Scaffold(
appBar: AppBar(
shadowColor: Colors.grey,
title: Text('Tankstops'),
centerTitle: true,
//backgroundColor: Colors.grey.shade600,
actions: [
IconButton(
icon: Icon(Icons.add_chart, color: Colors.grey.shade300),
onPressed: () async {
// Handle go to Chart View
tankListCtrl.goToGasView();
},
),
IconButton(
icon: Icon(Icons.local_gas_station_sharp, color: Colors.grey.shade300),
onPressed: () async {
// Handle go to Chart View
tankListCtrl.goToChartView();
},
),
IconButton(
icon: Icon(Icons.logout, color: Colors.grey.shade300),
onPressed: () async {
// Handle logout logic here
tankListCtrl.logoutSessionAndGoToLoginPage();
},
),
],
),
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment
.end, // Positioniere die Buttons am unteren Ende
crossAxisAlignment: CrossAxisAlignment.end, // Richte sie rechts aus
mainAxisSize: MainAxisSize.min, // Nimm nur den benötigten Platz ein
children: [
FloatingActionButton(
onPressed: () => tankListCtrl.goToInputPage(),
backgroundColor: Colors.blue,
child: Icon(Icons.add),
),
],
),
body: Obx(() => tankListCtrl.isloadingList.value == false
? Padding(
padding: EdgeInsetsGeometry.only(left: 25, right: 25),
child: Column(
children: [
SizedBox(
child: Column(
children: [
Text(tankListCtrl.szRxYear.value,
style: TextStyle(
fontSize: 25, color: Colors.orange)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
Text('Jahresverbrauch',
style: TextStyle(fontSize: 14)),
Text(tankListCtrl.szRxSummeYearLiter.value,
style: TextStyle(
fontSize: 20,
color: Colors.orange)),
],
),
Column(
children: [
Text('Jahressumme',
style: TextStyle(fontSize: 14)),
Text(tankListCtrl.szRxSummePrice.value,
style: TextStyle(
fontSize: 20,
color: Colors.orange)),
],
),
],
),
],
),
),
Divider(
color: Colors.grey.shade200,
height: 0.0,
),
Expanded(
child: tankListCtrl.rxTankListActualYear.isNotEmpty ? ListView.builder(
padding: EdgeInsets.only(top: 8, bottom: 8),
physics: const BouncingScrollPhysics(),
itemBuilder: ((BuildContext context, int index) {
var item = tankListCtrl.rxTankListActualYear[index];
return Column(
children: [
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.blue.withValues(
alpha: 0.35,
), // Die Farbe des Schattens
spreadRadius:
1, // Wie weit sich der Schatten ausbreitet
blurRadius:
1, // Wie stark der Schatten verschwommen ist
offset: const Offset(
0,
3,
), // Der Versatz des Schattens (x, y)
),
],
),
child: MyListTileItem(
listItem: item,
onPressedEdit: () {
tankListCtrl.goToUpdatePage(item);
},
onPressedDelete: () {
tankListCtrl.deleteTankStop(item.documentId);
},
),
),
SizedBox(height: 15),
],
);
}),
itemCount: tankListCtrl.rxTankListActualYear.length,
):Expanded(child: Center(
child: Text('Keine Einträge für das aktuelle Jahr vorhanden',
style: TextStyle(
fontSize: 18, color: Colors.grey.shade600)),
),
)
),
],
),
)
: Center(
child: CircularProgressIndicator(
color: Colors.blue,
),
)),
),
),
);
}
}