import 'package:diplomaticquarterapp/core/enum/Ambulate.dart';
import 'package:diplomaticquarterapp/core/model/er/PatientER.dart';
import 'package:diplomaticquarterapp/core/model/er/PatientER_RC.dart';
import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class Summary extends StatefulWidget {
  final Function changeCurrentTab;
  final PatientER patientER;
  final PatientER_RC patientER_RC;
  final AmRequestViewModel amRequestViewModel;

  Summary({Key key, this.changeCurrentTab, this.patientER, this.patientER_RC, this.amRequestViewModel});

  @override
  _SummaryState createState() => _SummaryState();
}

class _SummaryState extends State<Summary> {
  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      isShowDecPage: false,
      isShowAppBar: false,
      body: SingleChildScrollView(
        child: Container(
          margin: EdgeInsets.only(left: 12, right: 12),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Texts(TranslationBase.of(context).rrtSummary),
              SizedBox(
                height: 5,
              ),
              Container(
                width: double.infinity,
                padding: EdgeInsets.all(10),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(12),
                ),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Texts(
                      TranslationBase.of(context).transportMethod,
                      color: Colors.grey,
                    ),
                    Texts(
                      '${widget.patientER_RC.patientERTransportationMethod.text}',
                      bold: true,
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Texts(
                      TranslationBase.of(context).directions,
                      color: Colors.grey,
                    ),
                    Texts(
                      widget.patientER_RC.transportationDetails.direction == 0 ? TranslationBase.of(context).toHospital : TranslationBase.of(context).fromHospital,
                      bold: true,
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Texts(
                      TranslationBase.of(context).pickupLocation,
                      color: Colors.grey,
                    ),
                    Texts(
                      '${widget.patientER_RC.transportationDetails.pickupLocationName}',
                      bold: true,
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Texts(
                      TranslationBase.of(context).dropoffLocation,
                      color: Colors.grey,
                    ),
                    Texts(
                      '${widget.patientER_RC.transportationDetails.dropoffLocationName}',
                      bold: true,
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Texts(
                      TranslationBase.of(context).selectAmbulate,
                      color: Colors.grey,
                    ),
                    Texts(
                      '${widget.patientER_RC.transportationDetails.ambulate}',
                      bold: true,
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Texts(
                      TranslationBase.of(context).notes,
                      color: Colors.grey,
                    ),
                    Texts(
                      '${widget.patientER_RC.transportationDetails.notes ?? '---'}',
                      bold: true,
                    ),
                    SizedBox(
                      height: 8,
                    ),
                  ],
                ),
              ),
              SizedBox(
                height: 20,
              ),
              Texts(
                TranslationBase.of(context).billAmount,
                textAlign: TextAlign.start,
              ),
              SizedBox(
                height: 5,
              ),
              Container(
                height: 55,
                padding: EdgeInsets.all(10),
                decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [Texts(TranslationBase.of(context).patientShareTotal + ':'), Texts(TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.priceTotal}')],
                ),
              ),
              SizedBox(height: 130),
            ],
          ),
        ),
      ),
      bottomSheet: Container(
        padding: EdgeInsets.all(15),
        width: double.maxFinite,
        height: 90,
        child: SecondaryButton(
            color: Colors.grey[800],
            textColor: Colors.white,
            label: TranslationBase.of(context).send,
            onTap: () async {
              await widget.amRequestViewModel.insertERPressOrder(patientER: widget.patientER_RC);
            }),
      ),
    );
  }
}
