combo_widget.dart 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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/foundation.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:fis_theme/theme.dart';
  7. import 'package:flutter/services.dart';
  8. import 'package:get/get.dart';
  9. class SpecialItemHR extends FStatefulWidget {
  10. const SpecialItemHR({Key? key}) : super(key: key);
  11. @override
  12. FState<SpecialItemHR> createState() => _SpecialItemHRState();
  13. }
  14. class _SpecialItemHRState extends FState<SpecialItemHR> {
  15. final application = Get.find<IApplication>();
  16. late final item = application.activeMeasureItem!;
  17. late int selectedIndex = 1;
  18. FWidget buildHRButton(int index) {
  19. return FInkWell(
  20. onTap: () {
  21. final hRFeature = item.feature as StraightLineHeartRateFeature;
  22. hRFeature.setHeartRate(index);
  23. application.updateRenderReady.emit(this, null);
  24. HapticFeedback.mediumImpact();
  25. setState(() {
  26. selectedIndex = index;
  27. });
  28. },
  29. child: FContainer(
  30. decoration: BoxDecoration(
  31. color: selectedIndex == index
  32. ? const Color.fromARGB(255, 101, 211, 71)
  33. : const Color.fromRGBO(70, 70, 70, 1),
  34. border: Border.all(color: const Color.fromRGBO(124, 124, 124, 1)),
  35. borderRadius: BorderRadius.circular(5),
  36. ),
  37. // margin: const EdgeInsets.symmetric(horizontal: 11, vertical: 5),
  38. child: FCenter(
  39. child: FText(
  40. index.toString(),
  41. style: const TextStyle(
  42. color: Colors.white,
  43. ),
  44. ),
  45. ),
  46. ),
  47. );
  48. }
  49. @override
  50. FWidget build(BuildContext context) {
  51. const Decoration _webDecoration = BoxDecoration(
  52. color: Color.fromRGBO(60, 60, 60, 1),
  53. borderRadius: BorderRadius.only(
  54. bottomLeft: Radius.circular(5), bottomRight: Radius.circular(5)),
  55. );
  56. const Decoration _mobileDecoration = BoxDecoration();
  57. return FContainer(
  58. padding: kIsWeb ? const EdgeInsets.only(top: 10, bottom: 5) : null,
  59. decoration: kIsWeb ? _webDecoration : _mobileDecoration,
  60. child: FColumn(
  61. children: [
  62. if (kIsWeb)
  63. FContainer(
  64. padding: const EdgeInsets.symmetric(
  65. vertical: 6,
  66. ),
  67. decoration: BoxDecoration(
  68. borderRadius: BorderRadius.circular(4),
  69. color: FTheme.ins.colorScheme.primary,
  70. ),
  71. margin: const EdgeInsets.symmetric(
  72. horizontal: 11,
  73. ),
  74. width: double.infinity,
  75. child: const FCenter(
  76. child: FText(
  77. 'Time',
  78. style: TextStyle(
  79. color: Colors.white,
  80. ),
  81. ),
  82. ),
  83. ),
  84. _buildHRButtons(),
  85. ],
  86. ),
  87. );
  88. }
  89. FWidget _buildHRButtons() {
  90. return kIsWeb ? _buildWebHRButtons() : _buildMobileHRButtons();
  91. }
  92. FWidget _buildWebHRButtons() {
  93. return FColumn(
  94. crossAxisAlignment: CrossAxisAlignment.start,
  95. children: [
  96. FRow(
  97. children: const [
  98. FSizedBox(
  99. width: 11,
  100. ),
  101. FText(
  102. 'Heart Cycle',
  103. textAlign: TextAlign.start,
  104. style: TextStyle(
  105. color: Colors.white,
  106. ),
  107. ),
  108. ],
  109. ),
  110. FGridView.count(
  111. shrinkWrap: true,
  112. crossAxisCount: 2,
  113. childAspectRatio: 3,
  114. children: [1, 2, 3, 4, 5].map((e) {
  115. return buildHRButton(e);
  116. }).toList(),
  117. ),
  118. ],
  119. );
  120. }
  121. FWidget _buildMobileHRButtons() {
  122. return FExpanded(
  123. child: FListView(
  124. children: [
  125. FColumn(crossAxisAlignment: CrossAxisAlignment.center, children: [
  126. const FText(
  127. 'Heart Cycle',
  128. textAlign: TextAlign.center,
  129. style: TextStyle(
  130. fontSize: 12,
  131. color: Colors.white,
  132. ),
  133. ),
  134. const FSizedBox(
  135. height: 5,
  136. ),
  137. FGridView.count(
  138. shrinkWrap: true,
  139. crossAxisCount: 2,
  140. childAspectRatio: 1.5,
  141. mainAxisSpacing: 5,
  142. crossAxisSpacing: 5,
  143. children: [1, 2, 3, 4, 5].map((e) {
  144. return buildHRButton(e);
  145. }).toList(),
  146. ),
  147. ]),
  148. ],
  149. ),
  150. );
  151. }
  152. }