YSAddBodyData.dart 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter_ruler_picker/flutter_ruler_picker.dart';
  4. import 'base/YSBase.dart';
  5. import 'base/YSNetWorking.dart';
  6. class YSAddBodyData extends StatefulWidget {
  7. final int index;
  8. const YSAddBodyData({Key key, this.index}) : super(key: key);
  9. @override
  10. _YSAddBodyDataState createState() => _YSAddBodyDataState();
  11. }
  12. class _YSAddBodyDataState extends State<YSAddBodyData> {
  13. RulerPickerController _rulerPickerController = RulerPickerController(value: 0);
  14. String number = '0.0';
  15. @override
  16. Widget build(BuildContext context) {
  17. return YSBase(
  18. ystitle: '体重选择',
  19. yschild: SingleChildScrollView(
  20. child: Column(
  21. children: [
  22. Container(
  23. margin: EdgeInsets.all(20),
  24. child: Text('孕${widget.index}周',style: TextStyle(fontSize: 16,color: Color(0xFFDB5278),fontWeight: FontWeight.w600),),
  25. ),
  26. Container(
  27. margin: EdgeInsets.only(top: 30,bottom: 15),
  28. child: RulerPicker(
  29. controller: _rulerPickerController,
  30. marker: Container(
  31. height: 60,
  32. width: 3,
  33. color: Color(0xFFDB5278),
  34. ),
  35. onValueChanged: (value) {
  36. setState(() {
  37. number = value.toString();
  38. });
  39. },
  40. width: MediaQuery.of(context).size.width-60,
  41. height: 100,
  42. ranges: [RulerRange(end: 200, begin: 0)],
  43. onBuildRulerScaleText: (int index, num rulerScaleValue) {
  44. return '$index';
  45. },
  46. // beginValue: 1,
  47. // endValue: 100,
  48. ),
  49. ),
  50. RichText(
  51. text: TextSpan(
  52. style: TextStyle(fontSize: 36,color: Color(0xFFDB5278),fontWeight: FontWeight.bold),
  53. children: [
  54. TextSpan(text: number),
  55. TextSpan(text: ' kg',style: TextStyle(fontSize: 16,fontWeight: FontWeight.normal)),
  56. ]
  57. ),
  58. ),
  59. CupertinoButton(
  60. padding: EdgeInsets.all(0),
  61. child: Container(
  62. height: 40,
  63. width: MediaQuery.of(context).size.width-150,
  64. decoration: BoxDecoration(
  65. color: Color(0xFFDB5278),
  66. borderRadius: BorderRadius.all(Radius.circular(20))
  67. ),
  68. alignment: Alignment.center,
  69. child: Text('保存',style: TextStyle(fontSize: 16,color: Colors.white),),
  70. margin: EdgeInsets.only(top: 150),
  71. ),
  72. onPressed: (){
  73. _postWomanBodyData();
  74. },
  75. )
  76. ],
  77. ),
  78. ),
  79. );
  80. }
  81. _postWomanBodyData() async{
  82. if(number=='0.0'){
  83. ysFlutterToast(context, '请选择体重数据');
  84. return;
  85. }
  86. Map dict = await ysRequestHttp(context, requestType.post, 'phase/dueWeightAdd', {'week':widget.index,'weight':number});
  87. if(dict!=null){
  88. Navigator.of(context).pop('确定');
  89. }
  90. }
  91. }