import 'package:fis_i18n/i18n.dart';
import 'package:fis_jsonrpc/rpc.dart';
import 'package:fis_ui/base_define/page.dart';
import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/architecture/define.dart';
import 'package:flyinsono/pages/remedical/consultation/controller.dart';
import 'package:get/get.dart';

///关联检查操作对话框
class AssociateExamsOperationDialog extends FisView<ConsultationController>
    implements FPage {
  AssociateExamsOperationDialog({
    Key? key,
    required this.setValidPatientRequest,
    this.pageName = 'AssociateExamsOperationDialog',
  }) : super(key: key);
  @override
  final String pageName;
  final SetValidPatientRequest setValidPatientRequest;

  @override
  FWidget build(BuildContext context) {
    return FSimpleDialog(
      title: FText(
        i18nBook.remedical.selectOperation.t,
        style: TextStyle(
          color: Colors.white,
          fontSize: 18,
        ),
      ),
      okString: i18nBook.common.confirm.t,
      cancelString: i18nBook.common.cancel.t,
      insetPadding: EdgeInsets.symmetric(vertical: 150),
      children: [
        FSizedBox(
          height: 30,
        ),
        //关联检查的卡片布局内容
        _buildCard(
          i18nBook.remedical.associateCheck.t,
          i18nBook.remedical.associateCheckToCase.t,
          () {
            Get.back();
            controller.cancelCheck(setValidPatientRequest, this);
            // if() {
            // controller.cancelCheck(setValidPatientRequest,this);
            // }
          },
        ),
        //关联图片的卡片布局内容
        _buildCard(
          i18nBook.remedical.moveImage.t,
          i18nBook.remedical.moveImageToCheck.t,
          () {
            Get.back();
            controller.inspectionRecordsController.association(
              setValidPatientRequest.newPatientCode!,
              setValidPatientRequest.oldPatientCode!,
            );
          },
        ),
        FSizedBox(
          height: 30,
        ),
      ],
    );
  }

  FWidget _buildCard(
    String title,
    String subTitle,
    Function() onPressed,
  ) {
    return FContainer(
      margin: EdgeInsets.symmetric(
        horizontal: 15,
      ),
      padding: EdgeInsets.all(
        15,
      ),
      alignment: Alignment.centerLeft,
      child: FOutlinedButton(
        name: "$title",
        onPressed: () => onPressed(),
        style: ButtonStyle(
          padding: MaterialStateProperty.all(
            EdgeInsets.symmetric(
              vertical: 25,
              horizontal: 15,
            ),
          ),
        ),
        businessParent: this,
        child: FCenter(
          child: FContainer(
            width: 500,
            child: FColumn(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisSize: MainAxisSize.max,
              children: [
                FText(
                  '$title',
                  textAlign: TextAlign.left,
                  style: TextStyle(
                    fontWeight: FontWeight.bold,
                    color: Colors.black,
                  ),
                ),
                const FSizedBox(height: 5),
                FText(
                  '$subTitle',
                  style: TextStyle(
                    color: Colors.grey,
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
