BIG FAT
This commit is contained in:
@ -6,9 +6,11 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class CarManagementOverview extends StatefulWidget {
|
||||
final List<Car> cars;
|
||||
final int? selectedCarId;
|
||||
final Function(String plate) onAdd;
|
||||
final Function(String id) onDelete;
|
||||
final Function(String id, String plate) onEdit;
|
||||
final Future<void> Function() onRefresh;
|
||||
|
||||
const CarManagementOverview({
|
||||
super.key,
|
||||
@ -16,6 +18,8 @@ class CarManagementOverview extends StatefulWidget {
|
||||
required this.onDelete,
|
||||
required this.onEdit,
|
||||
required this.onAdd,
|
||||
required this.onRefresh,
|
||||
this.selectedCarId,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -40,30 +44,14 @@ class _CarManagementOverviewState extends State<CarManagementOverview> {
|
||||
widget.onEdit(car.id.toString(), newName);
|
||||
}
|
||||
|
||||
Widget _buildCarOverview() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(padding: const EdgeInsets.all(15), child: Text("Fahrzeuge", style: Theme.of(context).textTheme.headlineSmall),),
|
||||
Expanded(child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: widget.cars.isEmpty ? const Center(child: Text("keine Fahrzeuge vorhanden")) : ListView.builder(
|
||||
itemBuilder:
|
||||
(context, index) => CarCard(
|
||||
car: widget.cars[index],
|
||||
onEdit: _editCar,
|
||||
onDelete: _removeCar,
|
||||
),
|
||||
itemCount: widget.cars.length,
|
||||
),
|
||||
))
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Fahrzeuge"),
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Theme.of(context).colorScheme.onSecondary,
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _addCar,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
@ -72,7 +60,34 @@ class _CarManagementOverviewState extends State<CarManagementOverview> {
|
||||
color: Theme.of(context).colorScheme.onSecondary,
|
||||
),
|
||||
),
|
||||
body: _buildCarOverview(),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: widget.onRefresh,
|
||||
child: widget.cars.isEmpty
|
||||
? ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(10),
|
||||
children: const [
|
||||
SizedBox(
|
||||
height: 200,
|
||||
child: Center(child: Text("keine Fahrzeuge vorhanden")),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ListView.builder(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(10),
|
||||
itemCount: widget.cars.length,
|
||||
itemBuilder: (context, index) {
|
||||
final car = widget.cars[index];
|
||||
return CarCard(
|
||||
car: car,
|
||||
isSelected: widget.selectedCarId == car.id,
|
||||
onEdit: _editCar,
|
||||
onDelete: _removeCar,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user