consultation_picture_component.dart 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. import 'package:fis_i18n/i18n.dart';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:fis_ui/index.dart';
  4. import 'package:flutter/material.dart';
  5. /// 会诊图像
  6. class FConsultationContentImage extends StatelessWidget implements FWidget {
  7. /// 图片参数
  8. final ConsultationFileDTO? consultationFileInfo;
  9. /// 是否是测量页面
  10. final bool? isMeasure;
  11. /// 图片类型
  12. late RemedicalFileDataTypeEnum? fileDataType;
  13. /// 改变图片地址
  14. final VoidCallback? onDoubleTap;
  15. /// 图片单机事件
  16. final VoidCallback? onTap;
  17. /// 是否是选择状态
  18. final bool isPureImage;
  19. ///是否显示左上角序号
  20. final bool? ifShowIndex;
  21. ///图像宽度
  22. final double contentWidth;
  23. ///图像高度
  24. final double contentHeight;
  25. ///序号
  26. final int serialNo;
  27. ///图片文字描述
  28. final String? description;
  29. ///插件
  30. final FWidget? plugin;
  31. FConsultationContentImage({
  32. Key? key,
  33. this.isMeasure = false,
  34. this.onDoubleTap,
  35. this.onTap,
  36. this.isPureImage = false,
  37. this.ifShowIndex = true,
  38. this.serialNo = 0,
  39. this.description = '',
  40. this.contentHeight = 200,
  41. this.contentWidth = 300,
  42. this.consultationFileInfo,
  43. this.fileDataType,
  44. this.plugin,
  45. }) : super(key: key);
  46. @override
  47. FWidget build(BuildContext context) {
  48. if (fileDataType == null) {
  49. fileDataType = consultationFileInfo?.fileDataType;
  50. }
  51. FWidget child;
  52. if (isPureImage) {
  53. child = FContainer(
  54. color: Colors.black,
  55. child: FImage.network(
  56. consultationFileInfo?.previewImageUrl ?? "",
  57. width: contentWidth,
  58. height: contentHeight,
  59. errorBuilder: ((context, error, stackTrace) {
  60. return Container(
  61. child: Text(i18nBook.common.error.t),
  62. );
  63. }),
  64. ),
  65. );
  66. } else {
  67. child = _buildFContentImage(
  68. fileDataType!,
  69. consultationFileInfo?.previewImageUrl ?? "",
  70. );
  71. }
  72. return FStack(
  73. children: [
  74. FPositioned(child: child),
  75. FPositioned(
  76. right: 10,
  77. top: 5,
  78. child: plugin ?? FSizedBox(),
  79. ),
  80. ],
  81. );
  82. }
  83. FWidget _buildFContentImage(
  84. RemedicalFileDataTypeEnum fileDataType,
  85. String previewUrl,
  86. ) {
  87. switch (fileDataType) {
  88. case RemedicalFileDataTypeEnum.Image:
  89. case RemedicalFileDataTypeEnum.ThirdVidSingle:
  90. case RemedicalFileDataTypeEnum.VinnoVidSingle:
  91. return _buildImageCard(
  92. previewUrl,
  93. );
  94. case RemedicalFileDataTypeEnum.ThirdVidMovie:
  95. case RemedicalFileDataTypeEnum.VinnoVidMovie:
  96. return _buildVidMovieCard(
  97. previewUrl,
  98. );
  99. default:
  100. return FContainer(
  101. child: FText(i18nBook.common.error.t),
  102. );
  103. }
  104. }
  105. FWidget _buildImageCard(
  106. String previewUrl,
  107. ) {
  108. return FInkWell(
  109. onDoubleTap: () {
  110. onDoubleTap?.call();
  111. },
  112. onTap: () {
  113. onTap?.call();
  114. },
  115. child: Container(
  116. width: 190,
  117. height: 160,
  118. color: Colors.black,
  119. child: Stack(
  120. children: [
  121. Center(
  122. child: Image.network(
  123. previewUrl,
  124. errorBuilder: ((context, error, stackTrace) {
  125. return Container(
  126. child: Text(i18nBook.common.error.t),
  127. );
  128. }),
  129. ),
  130. ),
  131. if (ifShowIndex!) _buildIndex(),
  132. FPositioned(
  133. bottom: 5,
  134. left: 5,
  135. child: _buildApplication(),
  136. ),
  137. ],
  138. ),
  139. ),
  140. );
  141. }
  142. FWidget _buildVidMovieCard(String previewUrl) {
  143. return FContainer(
  144. width: 190,
  145. height: 160,
  146. color: Colors.black,
  147. child: FStack(
  148. children: [
  149. FCenter(
  150. child: FImage.network(
  151. previewUrl,
  152. errorBuilder: ((context, error, stackTrace) {
  153. return Container(
  154. child: Text(i18nBook.common.error.t),
  155. );
  156. }),
  157. ),
  158. ),
  159. FInkWell(
  160. onDoubleTap: () {
  161. onDoubleTap?.call();
  162. },
  163. onTap: () {
  164. onTap?.call();
  165. },
  166. child: Center(
  167. child: Container(
  168. child: Icon(
  169. Icons.play_circle_outline_rounded,
  170. color: Colors.white,
  171. size: 50,
  172. ),
  173. ),
  174. ),
  175. ),
  176. if (ifShowIndex!) _buildIndex(),
  177. FPositioned(
  178. bottom: 5,
  179. left: 5,
  180. child: _buildApplication(),
  181. ),
  182. ],
  183. ),
  184. );
  185. }
  186. ///创建序号
  187. FWidget _buildIndex() {
  188. return FPositioned(
  189. left: 5,
  190. child: FText(
  191. (serialNo).toString(),
  192. style: TextStyle(
  193. color: Colors.white,
  194. ),
  195. ),
  196. );
  197. }
  198. ///构建描述字段
  199. FWidget _buildApplication() {
  200. return FText(
  201. description ?? "",
  202. style: TextStyle(
  203. color: Colors.white,
  204. fontSize: 10,
  205. overflow: TextOverflow.ellipsis,
  206. ),
  207. );
  208. }
  209. }