Browse Source

新增会诊图像控件 Reviewed by Jimmy

Caroline 2 years ago
parent
commit
e535c1489d
1 changed files with 213 additions and 0 deletions
  1. 213 0
      lib/components/consultation_picture_component.dart

+ 213 - 0
lib/components/consultation_picture_component.dart

@@ -0,0 +1,213 @@
+import 'package:fis_i18n/i18n.dart';
+import 'package:fis_jsonrpc/rpc.dart';
+import 'package:fis_ui/index.dart';
+import 'package:flutter/material.dart';
+
+/// 会诊图像
+class FConsultationContentImage extends StatelessWidget implements FWidget {
+  /// 图片参数
+  final ConsultationFileDTO? consultationFileInfo;
+
+  /// 是否是测量页面
+  final bool? isMeasure;
+
+  /// 图片类型
+  late RemedicalFileDataTypeEnum? fileDataType;
+
+  /// 改变图片地址
+  final VoidCallback? onDoubleTap;
+
+  /// 图片单机事件
+  final VoidCallback? onTap;
+
+  /// 是否是选择状态
+  final bool isPureImage;
+
+  ///是否显示左上角序号
+  final bool? ifShowIndex;
+
+  ///图像宽度
+  final double contentWidth;
+
+  ///图像高度
+  final double contentHeight;
+
+  ///序号
+  final int serialNo;
+
+  ///图片文字描述
+  final String? description;
+
+  FConsultationContentImage({
+    Key? key,
+    this.isMeasure = false,
+    this.onDoubleTap,
+    this.onTap,
+    this.isPureImage = false,
+    this.ifShowIndex = true,
+    this.serialNo = 0,
+    this.description = '',
+    this.contentHeight = 200,
+    this.contentWidth = 300,
+    this.consultationFileInfo,
+    this.fileDataType,
+  }) : super(key: key);
+
+  @override
+  FWidget build(BuildContext context) {
+    if (fileDataType == null) {
+      fileDataType = consultationFileInfo?.fileDataType;
+    }
+
+    if (isPureImage) {
+      return FContainer(
+        color: Colors.black,
+        child: FImage.network(
+          consultationFileInfo?.previewImageUrl ?? "",
+          width: contentWidth,
+          height: contentHeight,
+          errorBuilder: ((context, error, stackTrace) {
+            return Container(
+              child: Text(i18nBook.common.error.t),
+            );
+          }),
+        ),
+      );
+    } else
+      return _buildFContentImage(
+        fileDataType!,
+        consultationFileInfo?.previewImageUrl ?? "",
+      );
+  }
+
+  FWidget _buildFContentImage(
+    RemedicalFileDataTypeEnum fileDataType,
+    String previewUrl,
+  ) {
+    switch (fileDataType) {
+      case RemedicalFileDataTypeEnum.Image:
+      case RemedicalFileDataTypeEnum.ThirdVidSingle:
+      case RemedicalFileDataTypeEnum.VinnoVidSingle:
+        return _buildImageCard(
+          previewUrl,
+        );
+      case RemedicalFileDataTypeEnum.ThirdVidMovie:
+      case RemedicalFileDataTypeEnum.VinnoVidMovie:
+        return _buildVidMovieCard(
+          previewUrl,
+        );
+      default:
+        return FContainer(
+          child: FText(i18nBook.common.error.t),
+        );
+    }
+  }
+
+  FWidget _buildImageCard(
+    String previewUrl,
+  ) {
+    return FInkWell(
+      onDoubleTap: () {
+        onDoubleTap?.call();
+      },
+      onTap: () {
+        onTap?.call();
+      },
+      child: Container(
+        width: 190,
+        height: 160,
+        color: Colors.black,
+        child: Stack(
+          children: [
+            Center(
+              child: Image.network(
+                previewUrl,
+                errorBuilder: ((context, error, stackTrace) {
+                  return Container(
+                    child: Text(i18nBook.common.error.t),
+                  );
+                }),
+              ),
+            ),
+            if (ifShowIndex!) _buildIndex(),
+            FPositioned(
+              bottom: 5,
+              left: 5,
+              child: _buildApplication(),
+            ),
+          ],
+        ),
+      ),
+    );
+  }
+
+  FWidget _buildVidMovieCard(String previewUrl) {
+    return FContainer(
+      width: 190,
+      height: 160,
+      color: Colors.black,
+      child: FStack(
+        children: [
+          FCenter(
+            child: FImage.network(
+              previewUrl,
+              errorBuilder: ((context, error, stackTrace) {
+                return Container(
+                  child: Text(i18nBook.common.error.t),
+                );
+              }),
+            ),
+          ),
+          FInkWell(
+            onDoubleTap: () {
+              onDoubleTap?.call();
+            },
+            onTap: () {
+              onTap?.call();
+            },
+            child: Center(
+              child: Container(
+                child: Icon(
+                  Icons.play_circle_outline_rounded,
+                  color: Colors.white,
+                  size: 50,
+                ),
+              ),
+            ),
+          ),
+          if (ifShowIndex!) _buildIndex(),
+          FPositioned(
+            bottom: 5,
+            left: 5,
+            child: _buildApplication(),
+          ),
+        ],
+      ),
+    );
+  }
+
+  ///创建序号
+  FWidget _buildIndex() {
+    return FPositioned(
+      left: 5,
+      child: FText(
+        (serialNo).toString(),
+        style: TextStyle(
+          color: Colors.white,
+        ),
+      ),
+    );
+  }
+
+  ///构建描述字段
+  FWidget _buildApplication() {
+    return FText(
+      description ?? "",
+      style: TextStyle(
+        color: Colors.white,
+        fontSize: 10,
+        overflow: TextOverflow.ellipsis,
+      ),
+    );
+  }
+}