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