combo_widget.dart 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import 'package:fis_measure/interfaces/process/workspace/application.dart';
  2. import 'package:fis_measure/process/primitives/single_straightline.dart';
  3. import 'package:fis_ui/index.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:fis_theme/theme.dart';
  6. import 'package:get/get.dart';
  7. class SpecialCombo extends FStatefulWidget {
  8. const SpecialCombo({Key? key}) : super(key: key);
  9. @override
  10. FState<SpecialCombo> createState() => _SpecialComboState();
  11. }
  12. class _SpecialComboState extends FState<SpecialCombo> {
  13. final application = Get.find<IApplication>();
  14. late final item = application.activeMeasureItem!;
  15. late int selectedIndex = 1;
  16. FWidget buildHRButton(int index) {
  17. return FInkWell(
  18. onTap: () {
  19. final hRFeature = item.feature as StraightLineHeartRateFeature;
  20. hRFeature.setHeartRate(index);
  21. application.updateRenderReady.emit(this, null);
  22. setState(() {
  23. selectedIndex = index;
  24. });
  25. },
  26. child: FContainer(
  27. decoration: BoxDecoration(
  28. color:
  29. selectedIndex == index ? Colors.greenAccent : Colors.transparent,
  30. border: Border.all(color: Colors.grey),
  31. borderRadius: BorderRadius.circular(5),
  32. ),
  33. margin: const EdgeInsets.symmetric(horizontal: 11, vertical: 5),
  34. padding: const EdgeInsets.all(8),
  35. child: FCenter(
  36. child: FText(
  37. index.toString(),
  38. style: const TextStyle(
  39. color: Colors.white,
  40. ),
  41. ),
  42. ),
  43. ),
  44. );
  45. }
  46. @override
  47. FWidget build(BuildContext context) {
  48. return FColumn(
  49. children: [
  50. FContainer(
  51. padding: const EdgeInsets.symmetric(
  52. vertical: 6,
  53. ),
  54. decoration: BoxDecoration(
  55. borderRadius: BorderRadius.circular(4),
  56. color: FTheme.ins.colorScheme.primary,
  57. ),
  58. margin: const EdgeInsets.symmetric(
  59. horizontal: 11,
  60. ),
  61. width: double.infinity,
  62. child: const FCenter(
  63. child: FText(
  64. 'Time',
  65. style: TextStyle(
  66. color: Colors.white,
  67. ),
  68. ),
  69. ),
  70. ),
  71. FColumn(
  72. crossAxisAlignment: CrossAxisAlignment.start,
  73. children: [
  74. FRow(
  75. children: const [
  76. FSizedBox(
  77. width: 11,
  78. ),
  79. FText(
  80. 'Heart Cycle',
  81. textAlign: TextAlign.start,
  82. style: TextStyle(
  83. color: Colors.white,
  84. ),
  85. ),
  86. ],
  87. ),
  88. FGridView.count(
  89. shrinkWrap: true,
  90. crossAxisCount: 2,
  91. childAspectRatio: 3,
  92. children: [1, 2, 3, 4, 5].map((e) {
  93. return buildHRButton(e);
  94. }).toList(),
  95. ),
  96. ],
  97. ),
  98. ],
  99. );
  100. }
  101. }