123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- 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;
- ///插件
- final FWidget? plugin;
- 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,
- this.plugin,
- }) : super(key: key);
- @override
- FWidget build(BuildContext context) {
- if (fileDataType == null) {
- fileDataType = consultationFileInfo?.fileDataType;
- }
- FWidget child;
- if (isPureImage) {
- child = 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 {
- child = _buildFContentImage(
- fileDataType!,
- consultationFileInfo?.previewImageUrl ?? "",
- );
- }
- return FStack(
- children: [
- FPositioned(child: child),
- FPositioned(
- right: 10,
- top: 5,
- child: plugin ?? FSizedBox(),
- ),
- ],
- );
- }
- 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,
- ),
- );
- }
- }
|