exam_body_temperature.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import 'package:flutter/material.dart';
  2. import 'package:vitalapp/components/dialog_number.dart';
  3. import 'package:vitalapp/pages/check/models/form.dart';
  4. import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_card.dart';
  5. // ignore: must_be_immutable
  6. class ExamBodyTemperature extends StatefulWidget {
  7. ExamBodyTemperature({
  8. super.key,
  9. required this.currentFormObject,
  10. required this.currentInputValue,
  11. this.bodyTemperatureInput,
  12. });
  13. FormObject currentFormObject;
  14. String currentInputValue;
  15. Function(String value)? bodyTemperatureInput;
  16. @override
  17. State<ExamBodyTemperature> createState() => _ExamBodyTemperatureState();
  18. }
  19. class _ExamBodyTemperatureState extends State<ExamBodyTemperature> {
  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. _buildTemperature(),
  33. ],
  34. );
  35. }
  36. Widget _buildTemperature() {
  37. return ExamCard(
  38. title: widget.currentFormObject.label ?? '',
  39. clickCard: () {
  40. _inputTemperature();
  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: 26),
  66. )
  67. ],
  68. ),
  69. ),
  70. ],
  71. ),
  72. ),
  73. ),
  74. );
  75. }
  76. Future<void> _inputTemperature() 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.bodyTemperatureInput!.call(widget.currentInputValue);
  84. }
  85. }
  86. }