ai_resul_info.dart 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. import 'package:fis_i18n/i18n.dart';
  2. import 'package:fis_measure/view/paint/date_structure.dart';
  3. import 'package:flutter/material.dart';
  4. /// AI诊断结果
  5. class ResultInfo extends StatelessWidget {
  6. const ResultInfo(
  7. this.aiDetectedObject, this.diagnosisOrgan, this.aiResultIndex,
  8. {Key? key})
  9. : super(key: key);
  10. final List<AIDetectedObject> aiDetectedObject;
  11. final int aiResultIndex;
  12. get isBenignlabel => aiDetectedObject[aiResultIndex].label <= 3;
  13. /// ai部位
  14. final DiagnosisOrganEnum diagnosisOrgan;
  15. @override
  16. Widget build(BuildContext context) {
  17. return Container(
  18. decoration: BoxDecoration(
  19. border: Border.all(
  20. color: Colors.grey,
  21. ),
  22. borderRadius: BorderRadius.circular(4),
  23. color: Colors.transparent,
  24. ),
  25. padding: const EdgeInsets.only(bottom: 10),
  26. child: Column(
  27. children: [
  28. Row(
  29. mainAxisSize: MainAxisSize.max,
  30. children: [
  31. Expanded(
  32. child: Container(
  33. decoration: const BoxDecoration(
  34. borderRadius: BorderRadius.only(
  35. topLeft: Radius.circular(4),
  36. topRight: Radius.circular(4),
  37. ),
  38. color: Color.fromRGBO(54, 169, 206, 1),
  39. ),
  40. padding: const EdgeInsets.only(
  41. top: 4,
  42. bottom: 10,
  43. left: 8,
  44. right: 8,
  45. ),
  46. child: const Text(
  47. 'AI诊断结果',
  48. style: TextStyle(
  49. color: Colors.white,
  50. ),
  51. ),
  52. ),
  53. )
  54. ],
  55. ),
  56. Row(
  57. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  58. children: [
  59. Container(
  60. padding: const EdgeInsets.only(
  61. left: 10,
  62. ),
  63. child: Column(
  64. children: [
  65. _buildTitle(
  66. '疾病标签',
  67. _buildAIDiagnosticOrgans(),
  68. ),
  69. _buildTitle(
  70. '病灶性质',
  71. Text(
  72. isBenignlabel ? '良性' : '恶性',
  73. style: const TextStyle(
  74. color: Colors.white,
  75. ),
  76. ),
  77. ),
  78. ],
  79. ),
  80. ),
  81. SizedBox(
  82. width: 70,
  83. height: 70,
  84. child: Stack(
  85. children: [
  86. SizedBox(
  87. width: 70,
  88. height: 70,
  89. child: CircularProgressIndicator(
  90. valueColor: AlwaysStoppedAnimation(
  91. _buildAITextColor(
  92. aiDetectedObject[aiResultIndex].label,
  93. ),
  94. ),
  95. backgroundColor: Colors.grey,
  96. value: aiDetectedObject[aiResultIndex].confidence,
  97. ),
  98. ),
  99. Center(
  100. child: SizedBox(
  101. width: 45,
  102. height: 45,
  103. child: Text(
  104. '可能性${(aiDetectedObject[aiResultIndex].confidence * 100).toStringAsFixed(1)}%',
  105. style: const TextStyle(
  106. color: Colors.white,
  107. ),
  108. ),
  109. ),
  110. ),
  111. ],
  112. ),
  113. ),
  114. ],
  115. ),
  116. ],
  117. ),
  118. );
  119. }
  120. Widget _buildTitle(String label, Widget value) {
  121. return Column(
  122. mainAxisSize: MainAxisSize.max,
  123. crossAxisAlignment: CrossAxisAlignment.start,
  124. children: [
  125. Text(
  126. label,
  127. style: const TextStyle(
  128. color: Color.fromRGBO(54, 169, 206, 1),
  129. ),
  130. ),
  131. value,
  132. const SizedBox(
  133. height: 5,
  134. ),
  135. ],
  136. );
  137. }
  138. Widget _buildAIDiagnosticOrgans() {
  139. switch (diagnosisOrgan) {
  140. case DiagnosisOrganEnum.Null:
  141. return const SizedBox();
  142. case DiagnosisOrganEnum.placeHolder_1:
  143. return const SizedBox();
  144. case DiagnosisOrganEnum.Breast:
  145. return Text(
  146. i18nBook.remedical.breast.t,
  147. style: const TextStyle(
  148. color: Colors.white,
  149. fontSize: 14,
  150. ),
  151. );
  152. case DiagnosisOrganEnum.Abdomen:
  153. return Text(
  154. i18nBook.bodyParts.abdomen.t,
  155. style: const TextStyle(
  156. color: Colors.white,
  157. fontSize: 14,
  158. ),
  159. );
  160. case DiagnosisOrganEnum.Liver:
  161. return Text(
  162. i18nBook.remedical.liver.t,
  163. style: const TextStyle(
  164. color: Colors.white,
  165. fontSize: 14,
  166. ),
  167. );
  168. case DiagnosisOrganEnum.Cholecyst:
  169. return Text(
  170. i18nBook.remedical.cholecyst.t,
  171. style: const TextStyle(
  172. color: Colors.white,
  173. fontSize: 14,
  174. ),
  175. );
  176. case DiagnosisOrganEnum.Kidney:
  177. return Text(
  178. i18nBook.remedical.kidney.t,
  179. style: const TextStyle(
  180. color: Colors.white,
  181. fontSize: 14,
  182. ),
  183. );
  184. case DiagnosisOrganEnum.Spleen:
  185. return Text(
  186. i18nBook.remedical.spleen.t,
  187. style: const TextStyle(
  188. color: Colors.white,
  189. fontSize: 14,
  190. ),
  191. );
  192. default:
  193. return Container();
  194. }
  195. }
  196. Color _buildAITextColor(int label) {
  197. switch (label) {
  198. case 0:
  199. return Colors.lightBlue;
  200. case 1:
  201. case 2:
  202. case 3:
  203. return Colors.greenAccent;
  204. default:
  205. return Colors.redAccent;
  206. }
  207. }
  208. }