import 'package:diplomaticquarterapp/core/model/er/PatientER.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:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/core/enum/Ambulate.dart';

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

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

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

//TODO it should be dynamic fix it
class _SummaryState extends State<Summary> {
  @override
  Widget build(BuildContext context) {
    return 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.patientERTransportationMethod.title}',bold: true,),
                  SizedBox(height: 8,),

                  Texts(TranslationBase.of(context).directions,color: Colors.grey,),
                  Texts('From Hospital',bold: true,),
                  SizedBox(height: 8,),

                  Texts('Pickup Location',color: Colors.grey,),
                  Texts('SZR Medical Center',bold: true,),
                  SizedBox(height: 8,),

                  Texts('Drop off location',color: Colors.grey,),
                  Texts('6199, Al Ameen wlfn  nif',bold: true,),
                  SizedBox(height: 8,),

                  Texts('Select Ambulate',color: Colors.grey,),
                  Texts('${widget.patientER.ambulate.getAmbulateTitle(context)}',bold: true,),
                  SizedBox(height: 8,),

                  Texts('Note',color: Colors.grey,),
                  Texts('${widget.patientER.requesterNote?? '---'}',bold: true,),
                  SizedBox(height: 8,),
                ],
              ),
            ),
            SizedBox(height: 20,),
            Texts(TranslationBase.of(context).RRTSummary,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('Total amount payable:'),
                  Texts('SR ${widget.patientER.patientERTransportationMethod.totalPrice}')
                ],
              ),
            ),

            SizedBox(height: 45,),
            Container(
              padding: EdgeInsets.all(15),
              width: double.maxFinite,
              height: 76,
              child:SecondaryButton(
                color: Colors.grey[800],
                textColor: Colors.white,
                label: TranslationBase.of(context).send,
                onTap: () async {
                  await widget.amRequestViewModel.insertERPressOrder(patientER: widget.patientER);

                }
              ),
            )
          ],
        ),
      ),
    );
  }
}
