import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/lab/components/operate_button/index.dart';
import 'package:flyinsono/lab/manager/page_manager.dart';
import 'package:flyinsono/lab/pages/lab_data/controller.dart';
import 'package:flyinsono/lab/pages/lab_export/entitys/export_init_arguments.dart';
import 'package:flyinsono/lab/router/lab_route_names.dart';
import 'package:get/get.dart';
import 'package:fis_common/index.dart';

class OperateBar extends GetView<LabDataController> {
  const OperateBar({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 90,
      // color: LabColors.base100,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Flexible(
            child: OperateButton(
              operateName: '查看/编辑',
              iconData: Icons.drive_file_rename_outline_rounded,
              onClick: () {
                controller.editRecord();
              },
            ),
          ),
          Flexible(
            child: OperateButton(
              operateName: '删除',
              iconData: Icons.delete_outline_rounded,
              onClick: () {
                controller.deleteRecord();
              },
            ),
          ),
          Flexible(
            child: OperateButton(
              operateName: '批量分析',
              iconData: Icons.bar_chart_rounded,
              onClick: () {
                controller.enterBatchAnalysis();
                // controller.openNewTab(LabRouteNames.BatchAnalysis, "批量分析");
              },
            ),
          ),
          // Flexible(
          //   child: OperateButton(
          //     operateName: '图像拼接',
          //     iconData: Icons.image_rounded,
          //     onClick: () {
          //       controller.openNewTab(LabRouteNames.ImageStitching, "图像拼接");
          //     },
          //   ),
          // ),
          // Flexible(
          //   child: OperateButton(
          //     operateName: '3D URM',
          //     iconData: Icons.layers_rounded,
          //     onClick: () {
          //       controller.openNewTab(LabRouteNames.Urm3d, "3D URM");
          //     },
          //   ),
          // ),
          if (FPlatform.isWindows || kDebugMode) ...[
            Flexible(
              child: OperateButton(
                operateName: '导出',
                iconData: Icons.file_upload_outlined,
                onClick: () {
                  PageManager.ins.openNewTab(
                    LabRouteNames.Export,
                    "数据导出",
                    args: LabExportInitArguments(
                      labExportPatientList: controller.selectedPatientList,
                      projectCode: controller.selectedDataSourceId,
                    ),
                  );
                },
                moreOperateButtons: [
                  MoreOperateButton(
                    icon: Icons.file_upload_outlined,
                    name: '批量导出',
                    onClick: () {
                      PageManager.ins.openNewTab(
                        LabRouteNames.Export,
                        "批量导出",
                        args: LabExportInitArguments(
                          labExportPatientList: controller
                              .patientClassifyData[
                                  controller.selectedClassifyIndex]
                              .data,
                          projectCode: controller.selectedDataSourceId,
                        ),
                      );
                      // TODO 弹窗弹窗预选样品/病人，作为参数传入导出页
                      // controller.openNewTab(LabRouteNames.Export, "批量导出");
                    },
                  ),
                ],
              ),
            ),
          ],
          if (kDebugMode)
            Flexible(
              child: OperateButton(
                operateName: '测试',
                iconData: Icons.build,
                onClick: () {
                  controller.debugForEmptyImageList();
                },
                moreOperateButtons: [
                  MoreOperateButton(
                    icon: Icons.bug_report,
                    name: '空图列表',
                    onClick: () {
                      controller.debugForEmptyImageList();
                    },
                  ),
                  MoreOperateButton(
                    icon: Icons.bug_report,
                    name: '首页',
                    onClick: () {
                      controller.debugForHomePage();
                    },
                  ),
                ],
              ),
            ),
        ],
      ),
    );
  }
}
