feat(profile): fix pickers

This commit is contained in:
mso7nueh
2024-09-04 13:03:57 +03:00
parent 0316ea9228
commit d76f535663
5 changed files with 70 additions and 87 deletions

View File

@@ -86,12 +86,6 @@ class _BlogPostWidgetState extends State<BlogPostWidget> {
child: Html(
data: widget.feedBlogPostModel.description,
),
// child: Text(
// widget.feedBlogPostModel.description,
// style: TextStyle(
// color: Colors.black87,
// ),
// ),
),
if (widget.feedBlogPostModel.title.isNotEmpty || widget.feedBlogPostModel.description.isNotEmpty) SizedBox(height: 8),
GestureDetector(

View File

@@ -112,20 +112,21 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
Builder(
builder: (context) {
if (_selectedChipIndex == 0)
return WeightChartWidget(
chartPoints: chartPoints,
profileCubit: context.read<ProfileCubit>(),
);
if (_selectedChipIndex == 1)
return CircumferenceChartWidget(
chartData: chartData,
profileCubit: context.read<ProfileCubit>(),
);
if (_selectedChipIndex == 2)
return ImtChartWidget(chartPoints: chartPoints);
else
return Container();
switch (_selectedChipIndex) {
case 0:
return WeightChartWidget(
chartPoints: chartPoints,
profileCubit: context.read<ProfileCubit>(),
);
case 1:
return CircumferenceChartWidget(
chartData: chartData,
profileCubit: context.read<ProfileCubit>(),
);
case 2:
return ImtChartWidget(chartPoints: chartPoints);
}
return SizedBox.shrink();
},
),
SizedBox(height: 8),

View File

@@ -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'),
],
),
),

View File

@@ -22,22 +22,22 @@ class ImtChartWidget extends StatelessWidget {
child: Row(
children: [
Text(
'${chartPoints.last.bmi.toStringAsFixed(2)} кг/м²',
'${chartPoints.last.bmi.toStringAsFixed(2)}',
style: TextStyle(
color: Colors.black,
fontSize: 48,
fontSize: 40,
fontWeight: FontWeight.w500,
),
),
chartPoints.last.bmi > chartPoints[chartPoints.length - 2].bmi
? Icon(
Icons.arrow_drop_up,
size: 48,
size: 40,
color: Colors.grey,
)
: Icon(
Icons.arrow_drop_down,
size: 48,
size: 40,
color: Colors.grey,
),
],

View File

@@ -21,20 +21,11 @@ class WeightChartWidget extends StatefulWidget {
}
class _WeightChartWidgetState extends State<WeightChartWidget> {
late final weightKiloController;
late final weightGramsController;
late FixedExtentScrollController weightKiloController;
late FixedExtentScrollController weightGramsController;
late int weightKilo;
late int weightGrams;
@override
void initState() {
super.initState();
weightKiloController = FixedExtentScrollController(initialItem: int.parse(widget.chartPoints.last.weight.toString().split('.')[0]) - 20);
weightGramsController = FixedExtentScrollController(initialItem: int.parse(widget.chartPoints.last.weight.toString().split('.')[1][0]));
weightKilo = int.parse(widget.chartPoints.last.weight.toString().split('.')[0]);
weightGrams = int.parse(widget.chartPoints.last.weight.toString().split('.')[1][0]);
}
@override
Widget build(BuildContext context) {
return Column(
@@ -48,19 +39,19 @@ class _WeightChartWidgetState extends State<WeightChartWidget> {
'${widget.chartPoints.last.weight.toStringAsFixed(1)} кг',
style: TextStyle(
color: Colors.black,
fontSize: 48,
fontSize: 40,
fontWeight: FontWeight.w500,
),
),
widget.chartPoints.last.weight > widget.chartPoints[widget.chartPoints.length - 2].weight
? Icon(
Icons.arrow_drop_up,
size: 48,
size: 40,
color: Colors.grey.withOpacity(0.4),
)
: Icon(
Icons.arrow_drop_down,
size: 48,
size: 40,
color: Colors.grey.withOpacity(0.4),
),
],
@@ -113,6 +104,10 @@ class _WeightChartWidgetState extends State<WeightChartWidget> {
FloatingActionButton.small(
heroTag: 'addWeight',
onPressed: () {
weightKilo = int.parse(widget.chartPoints.last.weight.toString().split('.')[0]);
weightGrams = int.parse(widget.chartPoints.last.weight.toString().split('.')[1][0]);
weightKiloController = FixedExtentScrollController(initialItem: weightKilo - 20);
weightGramsController = FixedExtentScrollController(initialItem: weightGrams);
showModalBottomSheet(
useRootNavigator: true,
context: context,
@@ -133,7 +128,7 @@ class _WeightChartWidgetState extends State<WeightChartWidget> {
weightKilo = value + 20;
},
children: [
for (int i = 20; i < 301; i++) Text('$i'),
for (int i = 20; i < 300; i++) Text('$i'),
],
),
),