cpd_2022_energy/lib/widgets/EnergyDisplay.dart

49 lines
1.9 KiB
Dart
Raw Permalink Normal View History

2022-11-07 22:12:21 +01:00
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){
2022-11-08 21:37:47 +01:00
return TabDisplayWidget('Generierte potentielle Energie: ${model.potentialEnergy} Joule\n'
'Generierte kinetische Energie: ${model.kineticEnergy} Joule');
2022-11-07 22:12:21 +01:00
}
),
]
),
)
);
}
}