exam_body_temperature.dart 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. style: TextStyle(
  58. fontSize: 26,
  59. color: Colors.black,
  60. fontFamily: "NotoSansSC",
  61. fontFamilyFallback: const ["NotoSansSC"],
  62. ),
  63. text: widget.currentInputValue,
  64. children: [
  65. TextSpan(
  66. text: widget.currentFormObject.append ?? '',
  67. style: const TextStyle(fontSize: 26),
  68. )
  69. ],
  70. ),
  71. ),
  72. ],
  73. ),
  74. ),
  75. ),
  76. );
  77. }
  78. Future<void> _inputTemperature() async {
  79. String? result = await VDialogNumber(
  80. title: widget.currentFormObject.label,
  81. initialValue: widget.currentInputValue,
  82. ).show();
  83. if (result?.isNotEmpty ?? false) {
  84. widget.currentInputValue = result ?? '';
  85. widget.bodyTemperatureInput!.call(widget.currentInputValue);
  86. } else {
  87. widget.bodyTemperatureInput!.call('');
  88. }
  89. }
  90. }