exam_body_weight.dart 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import 'package:flutter/material.dart';
  2. import 'package:vitalapp/pages/check/models/form.dart';
  3. import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_card.dart';
  4. import 'package:vitalapp/components/dialog_number.dart';
  5. // ignore: must_be_immutable
  6. class ExamBodyWeight extends StatefulWidget {
  7. ExamBodyWeight({
  8. super.key,
  9. required this.currentFormObject,
  10. required this.currentInputValue,
  11. this.bodyWeightInput,
  12. });
  13. FormObject currentFormObject;
  14. String currentInputValue;
  15. Function(String value)? bodyWeightInput;
  16. @override
  17. State<ExamBodyWeight> createState() => _ExamBodyWeightState();
  18. }
  19. class _ExamBodyWeightState extends State<ExamBodyWeight> {
  20. @override
  21. void initState() {
  22. super.initState();
  23. }
  24. @override
  25. void dispose() {
  26. super.dispose();
  27. }
  28. @override
  29. Widget build(BuildContext context) {
  30. return Stack(
  31. children: [
  32. _buildBMI(),
  33. ],
  34. );
  35. }
  36. Widget _buildBMI() {
  37. return ExamCard(
  38. title: widget.currentFormObject.label ?? '',
  39. clickCard: () {
  40. _inputBMI();
  41. },
  42. content: Container(
  43. alignment: Alignment.bottomRight,
  44. padding: const EdgeInsets.only(
  45. bottom: 20,
  46. right: 30,
  47. left: 40,
  48. ),
  49. constraints: const BoxConstraints(minHeight: 50),
  50. child: FittedBox(
  51. child: Row(
  52. mainAxisAlignment: MainAxisAlignment.end,
  53. crossAxisAlignment: CrossAxisAlignment.end,
  54. children: [
  55. RichText(
  56. text: TextSpan(
  57. text: widget.currentInputValue,
  58. style: const TextStyle(
  59. fontSize: 26,
  60. color: Colors.black,
  61. ),
  62. children: [
  63. TextSpan(
  64. text: widget.currentFormObject.append ?? '',
  65. style: const TextStyle(fontSize: 25),
  66. )
  67. ],
  68. ),
  69. ),
  70. ],
  71. ),
  72. ),
  73. ),
  74. );
  75. }
  76. Future<void> _inputBMI() async {
  77. String? result = await VDialogNumber(
  78. title: widget.currentFormObject.label,
  79. initialValue: widget.currentInputValue,
  80. ).show();
  81. if (result?.isNotEmpty ?? false) {
  82. widget.currentInputValue = result ?? '';
  83. widget.bodyWeightInput!.call(widget.currentInputValue);
  84. }
  85. }
  86. }