49 lines
1.9 KiB
Dart
49 lines
1.9 KiB
Dart
|
import 'package:energy_bilance/models/EnergyBilanceModel.dart';
|
||
|
import 'package:energy_bilance/widgets/TabDisplayWidget.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:provider/provider.dart';
|
||
|
|
||
|
class EnergyDisplay extends StatelessWidget {
|
||
|
const EnergyDisplay({super.key});
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return DefaultTabController(
|
||
|
length: 3,
|
||
|
child: Scaffold(
|
||
|
appBar: AppBar(
|
||
|
title: const Text('Energie umrechnen in:'),
|
||
|
bottom: const TabBar(
|
||
|
tabs: [
|
||
|
Tab(text: 'Wasser', icon: Icon(Icons.anchor_sharp),),
|
||
|
Tab(text: 'Eisen', icon: Icon(Icons.iron)),
|
||
|
Tab(text: 'Energie', icon: Icon(Icons.battery_charging_full),)
|
||
|
]
|
||
|
),
|
||
|
),
|
||
|
body: TabBarView(
|
||
|
children: [
|
||
|
Consumer<EnergyBilanceModel>(
|
||
|
builder: (context, model, child){
|
||
|
return TabDisplayWidget('Wasser, das von 20 °C zum Kochen gebracht werden kann: ${double.parse((model.amountOfBoilingWaterInL).toStringAsFixed(2))} Liter');
|
||
|
}
|
||
|
),
|
||
|
Consumer<EnergyBilanceModel>(
|
||
|
builder: (context, model, child){
|
||
|
return TabDisplayWidget('Eisen, das von 20 °C zum Glühen gebracht werden kann: ${double.parse((model.amountOfGlowingIronInKg).toStringAsFixed(2))} Kilo');
|
||
|
}
|
||
|
),
|
||
|
Consumer<EnergyBilanceModel>(
|
||
|
builder: (context, model, child){
|
||
|
return TabDisplayWidget('Generierte potentielle Energie: ${model.potentialEnergy}\n'
|
||
|
'Generierte kinetische Energie: ${model.kineticEnergy}');
|
||
|
}
|
||
|
),
|
||
|
]
|
||
|
),
|
||
|
)
|
||
|
|
||
|
);
|
||
|
}
|
||
|
|
||
|
}
|