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/pages/Blood/new_text_Field.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 BillAmount extends StatefulWidget {
  final Function changeCurrentTab;
  final PatientER patientER;
  final PatientER_RC patientER_RC;
  final AmRequestViewModel amRequestViewModel;

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

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

class _BillAmountState extends State<BillAmount> {
  Ambulate _ambulate = Ambulate.None;
  String note = "";

  @override
  void initState() {
    // if (widget.patientER_RC.transportationDetails.ambulate != null) {
    //   setState(() {
    //     _ambulate = widget.patientER.ambulate;
    //     note = widget.patientER.requesterNote;
    //   });
    // }
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      isShowDecPage: false,
      isShowAppBar: false,
      body: SingleChildScrollView(
        physics: BouncingScrollPhysics(),
        child: Container(
          margin: EdgeInsets.only(left: 12, right: 12),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Texts(TranslationBase.of(context).billAmount),
              SizedBox(
                height: 10,
              ),
              Table(
                border: TableBorder.symmetric(inside: BorderSide(width: 1.0, color: Colors.grey[300]), outside: BorderSide(width: 1.0, color: Colors.grey[300])),
                children: [
                  TableRow(
                    children: [
                      Container(
                        height: MediaQuery.of(context).size.height * 0.09,
                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(10.0),
                          ),
                        ),
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Texts(
                            TranslationBase.of(context).patientShareB,
                            textAlign: TextAlign.start,
                            color: Colors.black,
                            fontSize: 15,
                          ),
                        ),
                      ),
                      Container(
                        height: MediaQuery.of(context).size.height * 0.09,
                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.only(
                            topRight: Radius.circular(10.0),
                          ),
                        ),
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Texts(
                            TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.price}',
                            color: Colors.black,
                            textAlign: TextAlign.start,
                            fontSize: 15,
                          ),
                        ),
                      ),
                    ],
                  ),
                  TableRow(
                    children: [
                      Container(
                        color: Colors.white,
                        height: MediaQuery.of(context).size.height * 0.09,
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Texts(
                            TranslationBase.of(context).patientShareTax,
                            color: Colors.black,
                            fontSize: 15,
                            textAlign: TextAlign.start,
                          ),
                        ),
                      ),
                      Container(
                        height: MediaQuery.of(context).size.height * 0.09,
                        color: Colors.white,
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Texts(
                            TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.priceVAT}',
                            color: Colors.black,
                            fontSize: 15,
                            textAlign: TextAlign.start,
                          ),
                        ),
                      ),
                    ],
                  ),
                  TableRow(
                    children: [
                      Container(
                        height: MediaQuery.of(context).size.height * 0.09,
                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.only(
                            bottomLeft: Radius.circular(10.0),
                          ),
                        ),
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Texts(
                            TranslationBase.of(context).patientShareTotal,
                            color: Colors.black,
                            fontSize: 15,
                            textAlign: TextAlign.start,
                            bold: true,
                          ),
                        ),
                      ),
                      Container(
                        height: MediaQuery.of(context).size.height * 0.09,
                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.only(
                            bottomRight: Radius.circular(10.0),
                          ),
                        ),
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Texts(
                            TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.priceTotal}',
                            color: Colors.black,
                            fontSize: 15,
                            textAlign: TextAlign.start,
                          ),
                        ),
                      ),
                    ],
                  ),
                ],
              ),
              SizedBox(
                height: 10,
              ),
              Texts(
                TranslationBase.of(context).selectAmbulate,
                bold: true,
              ),
              SizedBox(
                height: 5,
              ),
              Row(
                children: [
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        setState(() {
                          _ambulate = Ambulate.Wheelchair;
                        });
                      },
                      child: Container(
                        decoration: BoxDecoration(
                          shape: BoxShape.rectangle,
                          borderRadius: BorderRadius.circular(8),
                          border: Border.all(color: Colors.grey, width: 0.5),
                          color: Colors.white,
                        ),
                        child: ListTile(
                          title: Text(TranslationBase.of(context).wheelchair),
                          leading: Radio(
                            value: Ambulate.Wheelchair,
                            groupValue: _ambulate,
                            onChanged: (value) {
                              setState(() {
                                _ambulate = value;
                              });
                            },
                          ),
                        ),
                      ),
                    ),
                  ),
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        setState(() {
                          _ambulate = Ambulate.Walker;
                        });
                      },
                      child: Container(
                        decoration: BoxDecoration(
                          shape: BoxShape.rectangle,
                          borderRadius: BorderRadius.circular(8),
                          border: Border.all(color: Colors.grey, width: 0.5),
                          color: Colors.white,
                        ),
                        child: ListTile(
                          title: Text(TranslationBase.of(context).walker),
                          leading: Radio(
                            value: Ambulate.Walker,
                            groupValue: _ambulate,
                            onChanged: (value) {
                              setState(() {
                                _ambulate = value;
                              });
                            },
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              SizedBox(
                height: 5,
              ),
              Row(
                children: [
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        setState(() {
                          _ambulate = Ambulate.Stretcher;
                        });
                      },
                      child: Container(
                        decoration: BoxDecoration(
                          shape: BoxShape.rectangle,
                          borderRadius: BorderRadius.circular(8),
                          border: Border.all(color: Colors.grey, width: 0.5),
                          color: Colors.white,
                        ),
                        child: ListTile(
                          title: Text(TranslationBase.of(context).stretcher),
                          leading: Radio(
                            value: Ambulate.Stretcher,
                            groupValue: _ambulate,
                            onChanged: (value) {
                              setState(() {
                                _ambulate = value;
                              });
                            },
                          ),
                        ),
                      ),
                    ),
                  ),
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        setState(() {
                          _ambulate = Ambulate.None;
                        });
                      },
                      child: Container(
                        decoration: BoxDecoration(
                          shape: BoxShape.rectangle,
                          borderRadius: BorderRadius.circular(8),
                          border: Border.all(color: Colors.grey, width: 0.5),
                          color: Colors.white,
                        ),
                        child: ListTile(
                          title: Text(TranslationBase.of(context).none),
                          leading: Radio(
                            value: Ambulate.None,
                            groupValue: _ambulate,
                            onChanged: (value) {
                              setState(() {
                                _ambulate = value;
                              });
                            },
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              SizedBox(
                height: 12,
              ),
              NewTextFields(
                hintText: TranslationBase.of(context).notes,
                initialValue: note,
                onChanged: (value) {
                  setState(() {
                    note = value;
                  });
                },
              ),
              SizedBox(
                height: 100,
              ),
            ],
          ),
        ),
      ),
      bottomSheet: Container(
        padding: EdgeInsets.all(15),
        width: double.maxFinite,
        height: 90,
        child: SecondaryButton(
          color: Colors.grey[800],
          textColor: Colors.white,
          onTap: () {
            setState(() {
              widget.patientER_RC.transportationDetails.ambulate = _ambulate.selectAmbulateNumber();
              widget.patientER_RC.transportationDetails.notes = note;
              // widget.patientER.selectedAmbulate = _ambulate.selectAmbulateNumber();
              widget.changeCurrentTab(3);
            });
          },
          label: TranslationBase.of(context).next,
        ),
      ),
    );
  }
}
