import 'package:fis_i18n/i18n.dart'; import 'package:fis_measure/view/paint/date_structure.dart'; import 'package:flutter/material.dart'; /// AI诊断结果 class ResultInfo extends StatelessWidget { const ResultInfo( this.aiDetectedObject, this.diagnosisOrgan, this.aiResultIndex, {Key? key}) : super(key: key); final List aiDetectedObject; final int aiResultIndex; get isBenignlabel => aiDetectedObject[aiResultIndex].label <= 3; /// ai部位 final DiagnosisOrganEnum diagnosisOrgan; @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( border: Border.all( color: Colors.grey, ), borderRadius: BorderRadius.circular(4), color: Colors.transparent, ), padding: const EdgeInsets.only(bottom: 10), child: Column( children: [ Row( mainAxisSize: MainAxisSize.max, children: [ Expanded( child: Container( decoration: const BoxDecoration( borderRadius: BorderRadius.only( topLeft: Radius.circular(4), topRight: Radius.circular(4), ), color: Color.fromRGBO(54, 169, 206, 1), ), padding: const EdgeInsets.only( top: 4, bottom: 10, left: 8, right: 8, ), child: const Text( 'AI诊断结果', style: TextStyle( color: Colors.white, ), ), ), ) ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( padding: const EdgeInsets.only( left: 10, ), child: Column( children: [ _buildTitle( '疾病标签', _buildAIDiagnosticOrgans(), ), _buildTitle( '病灶性质', Text( isBenignlabel ? '良性' : '恶性', style: const TextStyle( color: Colors.white, ), ), ), ], ), ), SizedBox( width: 70, height: 70, child: Stack( children: [ SizedBox( width: 70, height: 70, child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation( _buildAITextColor( aiDetectedObject[aiResultIndex].label, ), ), backgroundColor: Colors.grey, value: aiDetectedObject[aiResultIndex].confidence, ), ), Center( child: SizedBox( width: 45, height: 45, child: Text( '可能性${(aiDetectedObject[aiResultIndex].confidence * 100).toStringAsFixed(1)}%', style: const TextStyle( color: Colors.white, ), ), ), ), ], ), ), ], ), ], ), ); } Widget _buildTitle(String label, Widget value) { return Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( label, style: const TextStyle( color: Color.fromRGBO(54, 169, 206, 1), ), ), value, const SizedBox( height: 5, ), ], ); } Widget _buildAIDiagnosticOrgans() { switch (diagnosisOrgan) { case DiagnosisOrganEnum.Null: return const SizedBox(); case DiagnosisOrganEnum.placeHolder_1: return const SizedBox(); case DiagnosisOrganEnum.Breast: return Text( i18nBook.remedical.breast.t, style: const TextStyle( color: Colors.white, fontSize: 14, ), ); case DiagnosisOrganEnum.Abdomen: return Text( i18nBook.bodyParts.abdomen.t, style: const TextStyle( color: Colors.white, fontSize: 14, ), ); case DiagnosisOrganEnum.Liver: return Text( i18nBook.remedical.liver.t, style: const TextStyle( color: Colors.white, fontSize: 14, ), ); case DiagnosisOrganEnum.Cholecyst: return Text( i18nBook.remedical.cholecyst.t, style: const TextStyle( color: Colors.white, fontSize: 14, ), ); case DiagnosisOrganEnum.Kidney: return Text( i18nBook.remedical.kidney.t, style: const TextStyle( color: Colors.white, fontSize: 14, ), ); case DiagnosisOrganEnum.Spleen: return Text( i18nBook.remedical.spleen.t, style: const TextStyle( color: Colors.white, fontSize: 14, ), ); default: return Container(); } } Color _buildAITextColor(int label) { switch (label) { case 0: return Colors.lightBlue; case 1: case 2: case 3: return Colors.greenAccent; default: return Colors.redAccent; } } }