fix paddings of buttons and other widgets
This commit is contained in:
parent
0080e39605
commit
d2ab82aaf5
@ -36,6 +36,9 @@ class _EnterFoodWidgetState extends State<EnterFoodWidget> {
|
||||
controller: kcalPerMassController);
|
||||
|
||||
var enterButton = ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
double massAsNumber = 0.0;
|
||||
double kcalPerMassAsNumber = 0.0;
|
||||
@ -81,12 +84,15 @@ class _EnterFoodWidgetState extends State<EnterFoodWidget> {
|
||||
},
|
||||
child: const Icon(Icons.add));
|
||||
|
||||
return RowWidgetWithSpacers(
|
||||
nameWidget,
|
||||
massWidget,
|
||||
kcalPerMassWidget,
|
||||
null,
|
||||
enterButton,
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 4.0),
|
||||
child: RowWidget(
|
||||
nameWidget,
|
||||
massWidget,
|
||||
kcalPerMassWidget,
|
||||
null,
|
||||
enterButton,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -12,16 +12,20 @@ class FoodEntryWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: RowWidgetWithSpacers(
|
||||
Text(entry.name),
|
||||
Text(entry.mass.toString()),
|
||||
Text(entry.kcalPerMass.toString()),
|
||||
Text((entry.mass * entry.kcalPerMass / 100).toString()),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
onDelete(context);
|
||||
},
|
||||
child: const Icon(Icons.delete_forever_rounded)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0),
|
||||
child: RowWidget(
|
||||
Text(entry.name),
|
||||
Text(entry.mass.toString()),
|
||||
Text(entry.kcalPerMass.toString()),
|
||||
Text((entry.mass * entry.kcalPerMass / 100).toString()),
|
||||
IconButton(
|
||||
style: IconButton.styleFrom(padding: EdgeInsets.zero),
|
||||
onPressed: () {
|
||||
onDelete(context);
|
||||
},
|
||||
icon: const Icon(Icons.delete_forever_rounded)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class PerDateWidget extends StatelessWidget {
|
||||
itemBuilder: (BuildContext itemBuilderContext, int index) {
|
||||
if (index == state.foodEntries.length) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: SumWidget(limit: state.kcalLimit),
|
||||
);
|
||||
}
|
||||
|
@ -1,63 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RowWidgetWithSpacers extends StatefulWidget {
|
||||
class RowWidget extends StatefulWidget {
|
||||
final Widget? widget1;
|
||||
final Widget? widget2;
|
||||
final Widget? widget3;
|
||||
final Widget? widget4;
|
||||
final Widget? widget5;
|
||||
|
||||
const RowWidgetWithSpacers(
|
||||
const RowWidget(
|
||||
this.widget1, this.widget2, this.widget3, this.widget4, this.widget5,
|
||||
{super.key});
|
||||
|
||||
@override
|
||||
State<RowWidgetWithSpacers> createState() => _RowWidgetWithSpacersState();
|
||||
State<RowWidget> createState() => _RowWidgetState();
|
||||
}
|
||||
|
||||
class _RowWidgetWithSpacersState extends State<RowWidgetWithSpacers> {
|
||||
class _RowWidgetState extends State<RowWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 8.0,
|
||||
right: 2.0,
|
||||
),
|
||||
child: widget.widget1 ?? Container(),
|
||||
)),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2.0),
|
||||
child: widget.widget2 ?? Container(),
|
||||
)),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2.0),
|
||||
child: widget.widget3 ?? Container(),
|
||||
)),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2.0),
|
||||
child: widget.widget4 ?? Container(),
|
||||
)),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2.0),
|
||||
child: widget.widget5 ?? Container(),
|
||||
)),
|
||||
],
|
||||
),
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(flex: 10, child: widget.widget1 ?? Container()),
|
||||
Expanded(flex: 6, child: widget.widget2 ?? Container()),
|
||||
Expanded(flex: 6, child: widget.widget3 ?? Container()),
|
||||
Expanded(flex: 8, child: widget.widget4 ?? Container()),
|
||||
Expanded(flex: 3, child: widget.widget5 ?? Container()),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class SumWidget extends StatelessWidget {
|
||||
sum += entry.kcalPerMass / 100 * entry.mass;
|
||||
}
|
||||
|
||||
return RowWidgetWithSpacers(
|
||||
return RowWidget(
|
||||
null,
|
||||
null,
|
||||
const Text("kcal heute:"),
|
||||
|
Loading…
Reference in New Issue
Block a user