exam_body_temperature.dart 2.6 KB

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