import "package:fis_i18n/i18n.dart";
import "package:fis_ui/base_define/page.dart";
import "package:fis_ui/index.dart";
import "package:fis_ui/values/font_sizes.dart";
import "package:flutter/material.dart";
import "package:flyinsono/architecture/define.dart";
import "package:flyinsono/views/desktop/real_time_consultation/index.dart";
import "package:get/get.dart";
import "package:path/path.dart";

///会诊开始通知界面
class ConsultationStartNoticePage
    extends FisView<RealTimeConsultationController> implements FPage {
  const ConsultationStartNoticePage(
      {this.pageName = 'ConsultationStartNoticePage', Key? key})
      : super(key: key);
  @override
  final String pageName;
  FWidget build(BuildContext context) {
    return _DesktopLayout(this);
  }
}

class _DesktopLayout extends FisView<RealTimeConsultationController>
    implements FWidget {
  ///父级节点
  final FPage businessParent;
  _DesktopLayout(this.businessParent);
  NoticeInfo noticeInfo = new NoticeInfo();
  @override
  FWidget build(BuildContext context) {
    noticeInfo.personName = "test";
    noticeInfo.consultationTime = DateTime.now().toString();
    noticeInfo.expert = "test expert";
    return mainContent(businessParent, controller, noticeInfo);
  }
}

FWidget mainContent(FPage businessParent,
    RealTimeConsultationController controller, NoticeInfo noticeInfo) {
  return FSimpleDialog(
    title: FText(
      i18nBook.realTimeConsultation.notice.t,
      style: TextStyle(
        color: Colors.white,
        fontSize: FFontSizes.H5,
      ),
    ),
    okString: i18nBook.common.confirm.t,
    cancelString: i18nBook.common.cancel.t,
    backgroundColor: Color.fromRGBO(230, 230, 230, 1),
    children: [
      FContainer(
        width: 400,
        height: 200,
        padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20),
        color: Colors.white,
        child: FCenter(
          child: FColumn(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              FText(
                i18nBook.realTimeConsultation.noticeContent.t,
                style: TextStyle(
                    fontSize: FFontSizes.H5,
                    fontWeight: FontWeight.bold,
                    overflow: TextOverflow.ellipsis),
              ),
              _createRow(i18nBook.common.fullName.t, noticeInfo.personName),
              _createRow(i18nBook.realTimeConsultation.consultationHours.t,
                  noticeInfo.consultationTime),
              _createRow(i18nBook.realTimeConsultation.competentExperts.t,
                  noticeInfo.expert),
            ],
          ),
        ),
      ),
    ],
    bottomButton: FContainer(
      alignment: Alignment.center,
      padding: EdgeInsets.symmetric(vertical: 15),
      child: FElevatedButton(
        name: "consultationStartNoticeConfirm",
        businessParent: businessParent,
        child: FText(i18nBook.realTimeConsultation.iknow.t),
        onPressed: () => navigator?.pop(context),
        style: ButtonStyle(
          padding: MaterialStateProperty.all(
            EdgeInsets.symmetric(
              vertical: 15,
              horizontal: 25,
            ),
          ),
        ),
      ),
    ),
  );
}

FWidget _createRow(String title, String detail) {
  return FRow(
    children: [
      FContainer(
        width: 80,
        child: FText(
          title,
          style: TextStyle(
              fontSize: FFontSizes.H6,
              fontWeight: FontWeight.bold,
              overflow: TextOverflow.ellipsis),
        ),
      ),
      FSizedBox(
        width: 50,
      ),
      FText(
        detail,
        style:
            TextStyle(fontSize: FFontSizes.H6, overflow: TextOverflow.ellipsis),
      ),
    ],
  );
}

class NoticeInfo {
  String personName = '';
  String consultationTime = '';
  String expert = '';
}
