import 'package:diplomaticquarterapp/core/model/insurance/insurance_approval.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart';
import 'package:diplomaticquarterapp/widgets/my_rich_text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class InsuranceApprovalDetail extends StatelessWidget {
  final InsuranceApprovalModel insuranceApprovalModel;

  InsuranceApprovalDetail({Key key, this.insuranceApprovalModel}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);

    return AppScaffold(
      isShowAppBar: true,
      showNewAppBar: true,
      showNewAppBarTitle: true,
      appBarTitle: TranslationBase.of(context).insuranceApproval,
      description: TranslationBase.of(context).infoApprovals,
      infoList: TranslationBase.of(context).infoApprovalPoints,
      body: SingleChildScrollView(
        physics: BouncingScrollPhysics(),
        padding: EdgeInsets.all(21),
        child: Container(
          padding: EdgeInsets.fromLTRB(16, 12, 16, 12),
          decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(10.0)),
              boxShadow: [
                BoxShadow(
                  color: Color(0xff000000).withOpacity(.05),
                  blurRadius: 27,
                  offset: Offset(0, -3),
                ),
              ],
              color: Colors.white),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                insuranceApprovalModel.approvalStatusDescption,
                style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: insuranceApprovalModel.status == 9 ? Color(0xff359846) : Color(0xffD02127), letterSpacing: -0.4, height: 18 / 10),
              ),
              Text(
                insuranceApprovalModel.doctorName,
                style: TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w600,
                  color: Color(0xff2E303A),
                  letterSpacing: -0.64,
                ),
              ),
              SizedBox(height: 6),
              Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  LargeAvatar(
                    name: insuranceApprovalModel.doctorName,
                    url: insuranceApprovalModel.doctorImageURL,
                    width: 48,
                    height: 48,
                  ),
                  SizedBox(width: 12),
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        MyRichText(TranslationBase.of(context).clinic + ":", insuranceApprovalModel?.clinicName ?? "", projectViewModel.isArabic),
                        MyRichText(TranslationBase.of(context).approvalNo, insuranceApprovalModel?.approvalNo.toString() ?? "", projectViewModel.isArabic),
                        MyRichText(TranslationBase.of(context).unusedCount, insuranceApprovalModel?.unUsedCount.toString() ?? "", projectViewModel.isArabic),
                        MyRichText(TranslationBase.of(context).companyName, insuranceApprovalModel?.companyName ?? "", projectViewModel.isArabic),
                        SizedBox(height: 6),
                        MyRichText(TranslationBase.of(context).receiptOn, DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(insuranceApprovalModel.receiptOn)) ?? "",
                            projectViewModel.isArabic),
                        MyRichText(TranslationBase.of(context).expiryOn, DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(insuranceApprovalModel.expiryDate)) ?? "",
                            projectViewModel.isArabic),
                      ],
                    ),
                  ),
                ],
              ),
              SizedBox(height: 21),
              Table(columnWidths: {
                0: FlexColumnWidth(1.8),
                1: FlexColumnWidth(1),
                2: FlexColumnWidth(1),
              }, children: [
                TableRow(
                  children: [
                    Utils.tableColumnTitle(TranslationBase.of(context).procedure),
                    Utils.tableColumnTitle(TranslationBase.of(context).status),
                    Utils.tableColumnTitle(TranslationBase.of(context).usageStatus)
                  ],
                ),
                TableRow(
                  children: [
                    Utils.tableColumnValue(insuranceApprovalModel?.apporvalDetails?.procedureName ?? '', isLast: true, mProjectViewModel: projectViewModel),
                    Utils.tableColumnValue(insuranceApprovalModel?.apporvalDetails?.status ?? '', isLast: true, mProjectViewModel: projectViewModel),
                    Utils.tableColumnValue(insuranceApprovalModel?.apporvalDetails?.isInvoicedDesc ?? '', isLast: true, mProjectViewModel: projectViewModel),
                  ],
                ),
              ])
            ],
          ),
        ),
      ),
    );
  }
}
