pisa.dart 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import 'package:fis_i18n/i18n.dart';
  2. import 'package:fis_measure/define.dart';
  3. import 'package:fis_measure/interfaces/process/items/item_metas.dart';
  4. import 'package:fis_measure/interfaces/process/workspace/application.dart';
  5. import 'package:fis_measure/process/primitives/combos/pisa.dart';
  6. import 'package:fis_measure/process/primitives/rvsp.dart';
  7. import 'package:fis_measure/utils/prompt_box.dart';
  8. import 'package:fis_ui/index.dart';
  9. import 'package:fis_ui/interface/interactive_container.dart';
  10. import 'package:flutter/material.dart';
  11. import 'package:get/get.dart';
  12. import 'normal_child.dart';
  13. import 'widgets.dart';
  14. class AlsVelItemButton extends FStatefulWidget {
  15. const AlsVelItemButton({super.key});
  16. @override
  17. FState<FStatefulWidget> createState() => _AlsVelItemButtonState();
  18. }
  19. class _AlsVelItemButtonState extends FState<AlsVelItemButton> {
  20. double _customAlsVelValue = 0;
  21. @override
  22. void initState() {
  23. _initState();
  24. super.initState();
  25. }
  26. @override
  27. FWidget build(BuildContext context) {
  28. return NormalChildButton(
  29. businessParent: const FPlaceHolderInteractiveContainer(),
  30. activeIndex: -1,
  31. index: 0,
  32. itemMeta: ItemMeta(
  33. "Als.Vel",
  34. measureType: '',
  35. description: 'Als.Vel',
  36. outputs: [],
  37. ),
  38. onClick: () {
  39. Get.dialog(_buildDialog());
  40. },
  41. );
  42. }
  43. void _initState() {
  44. final activeMeasureItem = Get.find<IApplication>().activeMeasureItem;
  45. if (activeMeasureItem == null) {
  46. return;
  47. }
  48. _customAlsVelValue = (activeMeasureItem as Pisa).alsVel.value!;
  49. }
  50. FWidget _buildDialog() {
  51. final children = <Widget>[];
  52. children.add(_buildInputButton());
  53. return FSimpleDialog(
  54. title: const FText("Als.Vel", style: TextStyle(color: Colors.white)),
  55. okString: i18nBook.common.confirm.t,
  56. cancelString: i18nBook.common.cancel.t,
  57. isDefault: true,
  58. children: children,
  59. onOk: () {
  60. _onValueConfrim();
  61. Get.back();
  62. },
  63. onCancel: () {
  64. Get.back();
  65. },
  66. onClose: () {
  67. Get.back();
  68. },
  69. );
  70. }
  71. void _onValueConfrim() {
  72. final activeMeasureItem = Get.find<IApplication>().activeMeasureItem;
  73. if (activeMeasureItem == null) {
  74. return;
  75. }
  76. double alsVel = _customAlsVelValue;
  77. (activeMeasureItem as Pisa).updateAlsVel(alsVel);
  78. }
  79. Widget _buildInputButton() {
  80. return CustomChildInputOptionWidget(
  81. isActive: false,
  82. value: _customAlsVelValue.toString(),
  83. suffixWidget: const Text(" cm/s"),
  84. onClick: () {
  85. //
  86. },
  87. onInputChanged: (String value) {
  88. final doubleValue = double.tryParse(value);
  89. if (doubleValue == null) {
  90. PromptBox.toast("请输入正确的Als.Vel数值");
  91. } else {
  92. _customAlsVelValue = doubleValue;
  93. }
  94. },
  95. );
  96. }
  97. }