forked from eatvio/eatvio_app
feat(profile): fix pickers
This commit is contained in:
@@ -21,89 +21,76 @@ class CircumferenceChartWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CircumferenceChartWidgetState extends State<CircumferenceChartWidget> {
|
||||
late final chestController;
|
||||
late final hipController;
|
||||
late final waistController;
|
||||
late FixedExtentScrollController chestController;
|
||||
late FixedExtentScrollController waistController;
|
||||
late FixedExtentScrollController hipController;
|
||||
late int chest;
|
||||
late int hip;
|
||||
late int waist;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
chestController = FixedExtentScrollController(initialItem: int.parse(widget.chartData.last.chestCircumference.toString()));
|
||||
hipController = FixedExtentScrollController(initialItem: int.parse(widget.chartData.last.hipCircumference.toString()));
|
||||
waistController = FixedExtentScrollController(initialItem: int.parse(widget.chartData.last.waistCircumference.toString()));
|
||||
chest = widget.chartData.last.chestCircumference;
|
||||
hip = widget.chartData.last.hipCircumference;
|
||||
waist = widget.chartData.last.waistCircumference;
|
||||
}
|
||||
late int hip;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'${widget.chartData.last.chestCircumference} см',
|
||||
'${widget.chartData.last.chestCircumference}',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 48,
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
widget.chartData.last.chestCircumference > widget.chartData[widget.chartData.length - 2].chestCircumference
|
||||
? Icon(
|
||||
Icons.arrow_drop_up,
|
||||
size: 48,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
)
|
||||
: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
size: 48,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
),
|
||||
Text(
|
||||
'${widget.chartData.last.waistCircumference} см',
|
||||
'${widget.chartData.last.waistCircumference}',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 48,
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
widget.chartData.last.waistCircumference > widget.chartData[widget.chartData.length - 2].waistCircumference
|
||||
? Icon(
|
||||
Icons.arrow_drop_up,
|
||||
size: 48,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
)
|
||||
: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
size: 48,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
),
|
||||
Text(
|
||||
'${widget.chartData.last.hipCircumference} см',
|
||||
'${widget.chartData.last.hipCircumference}',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 48,
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
widget.chartData.last.hipCircumference > widget.chartData[widget.chartData.length - 2].hipCircumference
|
||||
? Icon(
|
||||
Icons.arrow_drop_up,
|
||||
size: 48,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
)
|
||||
: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
size: 48,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
),
|
||||
],
|
||||
@@ -151,8 +138,14 @@ class _CircumferenceChartWidgetState extends State<CircumferenceChartWidget> {
|
||||
tooltipBehavior: TooltipBehavior(enable: true),
|
||||
),
|
||||
FloatingActionButton.small(
|
||||
heroTag: 'addWeight',
|
||||
heroTag: 'addCircumference',
|
||||
onPressed: () {
|
||||
chest = widget.chartData.last.chestCircumference;
|
||||
waist = widget.chartData.last.waistCircumference;
|
||||
hip = widget.chartData.last.hipCircumference;
|
||||
chestController = FixedExtentScrollController(initialItem: chest - 20);
|
||||
waistController = FixedExtentScrollController(initialItem: waist - 20);
|
||||
hipController = FixedExtentScrollController(initialItem: hip - 20);
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
@@ -173,22 +166,7 @@ class _CircumferenceChartWidgetState extends State<CircumferenceChartWidget> {
|
||||
chest = value;
|
||||
},
|
||||
children: [
|
||||
for (int i = 0; i < 301; i++) Text('$i'),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CupertinoPicker(
|
||||
magnification: 1.22,
|
||||
squeeze: 1.2,
|
||||
useMagnifier: true,
|
||||
scrollController: hipController,
|
||||
itemExtent: 24,
|
||||
onSelectedItemChanged: (int value) {
|
||||
hip = value;
|
||||
},
|
||||
children: [
|
||||
for (int i = 0; i < 301; i++) Text('$i'),
|
||||
for (int i = 20; i < 200; i++) Text('$i'),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -203,7 +181,22 @@ class _CircumferenceChartWidgetState extends State<CircumferenceChartWidget> {
|
||||
waist = value;
|
||||
},
|
||||
children: [
|
||||
for (int i = 0; i < 301; i++) Text('$i'),
|
||||
for (int i = 20; i < 200; i++) Text('$i'),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: CupertinoPicker(
|
||||
magnification: 1.22,
|
||||
squeeze: 1.2,
|
||||
useMagnifier: true,
|
||||
scrollController: hipController,
|
||||
itemExtent: 24,
|
||||
onSelectedItemChanged: (int value) {
|
||||
hip = value;
|
||||
},
|
||||
children: [
|
||||
for (int i = 20; i < 200; i++) Text('$i'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user