us_image_pool.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import 'package:flutter/material.dart';
  2. import 'package:flyinsono/lab/color/lab_colors.dart';
  3. import 'package:flyinsono/lab/components/lab_loading_wrapper.dart';
  4. import 'package:flyinsono/lab/mock_data/mock_rpc.dart';
  5. import 'package:flyinsono/lab/pages/lab_data/controller.dart';
  6. import 'package:flyinsono/lab/pages/lab_data/widgets/us_image_thumbnail.dart';
  7. import 'package:flyinsono/lab/style/lab_box_decoration.dart';
  8. import 'package:flyinsono/utils/datetime.dart';
  9. import 'package:get/get.dart';
  10. import 'package:fis_jsonrpc/rpc.dart';
  11. class USImagePool extends GetView<LabDataController> {
  12. const USImagePool({Key? key}) : super(key: key);
  13. @override
  14. Widget build(BuildContext context) {
  15. return GetBuilder<LabDataController>(
  16. id: LabDataController.imageListId,
  17. builder: (context) {
  18. return Container(
  19. decoration: LabBoxDecoration.base,
  20. child: LabLoadingWrapper(
  21. decoration: LabBoxDecoration.base,
  22. loading: controller.isImageListLoading,
  23. child: Padding(
  24. padding: const EdgeInsets.all(5),
  25. child: GridView.builder(
  26. padding: const EdgeInsets.all(5),
  27. gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
  28. crossAxisCount: 6,
  29. crossAxisSpacing: 5,
  30. mainAxisSpacing: 5,
  31. childAspectRatio: 3 / 2,
  32. ),
  33. itemCount: controller.imageList.length,
  34. itemBuilder: (context, index) {
  35. var imageType =
  36. controller.imageList[index].vidDataInfo.imageType;
  37. var image = controller.imageList[index];
  38. bool isVideo = [
  39. SampleRemedicalFileDataTypeEnum.AnalysisVideo,
  40. SampleRemedicalFileDataTypeEnum.VinnoVidMovie,
  41. SampleRemedicalFileDataTypeEnum.ThirdVidMovie,
  42. SampleRemedicalFileDataTypeEnum.AnalysisVideo,
  43. ].contains(image.fileDataType) &&
  44. imageType != ImageType.URM_Result;
  45. return MouseRegion(
  46. cursor: SystemMouseCursors.click,
  47. child: GestureDetector(
  48. onTap: () {
  49. controller.clickImage(index);
  50. },
  51. child: USImageThumbnail(
  52. imageUrl:
  53. controller.imageList[index].vidDataInfo.coverUrl,
  54. description: ((index + 1).toString() +
  55. " " +
  56. controller.imageList[index].fileTypeName +
  57. " ${DataTimeUtils.convertToLocalString(controller.imageList[index].createTime)}"),
  58. labelBuilder: _buildLabel(
  59. controller.imageList[index].vidDataInfo.imageType,
  60. ),
  61. isVideo: isVideo,
  62. ),
  63. ),
  64. );
  65. },
  66. ),
  67. ),
  68. ),
  69. );
  70. },
  71. );
  72. }
  73. Widget? _buildLabel(ImageType imageType) {
  74. switch (imageType) {
  75. case ImageType.URM:
  76. return Text(
  77. 'URM',
  78. style: TextStyle(
  79. color: LabColors.green400,
  80. fontWeight: FontWeight.bold,
  81. fontSize: 12,
  82. ),
  83. );
  84. case ImageType.URM_Result:
  85. return Text(
  86. 'URM 分析结果',
  87. style: TextStyle(
  88. color: LabColors.green400,
  89. fontWeight: FontWeight.bold,
  90. fontSize: 12,
  91. ),
  92. );
  93. case ImageType.Measure_Result:
  94. return Text(
  95. '图像',
  96. style: TextStyle(
  97. color: LabColors.green400,
  98. fontWeight: FontWeight.bold,
  99. fontSize: 12,
  100. ),
  101. );
  102. case ImageType.Video:
  103. return Text(
  104. '视频',
  105. style: TextStyle(
  106. color: LabColors.green400,
  107. fontWeight: FontWeight.bold,
  108. fontSize: 12,
  109. ),
  110. );
  111. default:
  112. return null;
  113. }
  114. }
  115. }