import 'package:fis_jsonrpc/rpc.dart';
import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/managers/interfaces/report.dart';
import 'package:flyinsono/pages/remedical/report/report_edit/widgets/cloud_image_item.dart';
import 'package:get/get.dart';

class CloudConsultationImages extends FStatelessWidget {
  final List<RemedicalInfoDTO> images;
  final String patientCode;
  final String currentConsultationCode;
  final double _imageWidth = 190;
  int _index = 0;
  CloudConsultationImages(
      this.images, this.patientCode, this.currentConsultationCode);

  @override
  FWidget build(BuildContext context) {
    return FContainer(
      margin: EdgeInsets.only(
        left: 10,
        top: 5,
      ),
      child: FWrap(
        spacing: 8.0, // 主轴(水平)方向间距
        runSpacing: 8.0, // 纵轴（垂直）方向间距
        direction: Axis.horizontal,
        alignment: WrapAlignment.start,
        children: List<FWidget>.generate(
          images.length,
          (i) {
            var imageInfo = images[i];
            final image = CloudImageItem(
              _index + 1,
              imageInfo,
              onDoubleTap: () {
                Get.find<IReportManager>().enterVidMeasurePage(
                  imageUrl: imageInfo.terminalImages?.imageUrl ?? '',
                  imageindex: i,
                  remedicalCode: imageInfo.remedicalCode ?? '',
                  patientCode: patientCode,
                  recordCode: currentConsultationCode,
                );
              },
              imageWidth: _imageWidth,
            );
            _index++;
            return image;
          },
        ),
      ),
    );
  }
}
