import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/er/EdOnlineViewModel.dart';
import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.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:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class EdPaymentInformationPage extends StatefulWidget {
  final HospitalsModel selectedHospital;

  const EdPaymentInformationPage({Key key, this.selectedHospital}) : super(key: key);
  @override
  _EdPaymentInformationPageState createState() =>
      _EdPaymentInformationPageState();
}

class _EdPaymentInformationPageState extends State<EdPaymentInformationPage> {
  @override
  Widget build(BuildContext context) {
    return BaseView<EdOnlineViewModel>(
      onModelReady: (model) => model.getPatientPaymentInformation(),
      builder: (_, model, w) => AppScaffold(
        baseViewModel: model,
        body: SingleChildScrollView(
          physics: BouncingScrollPhysics(),
          child: Column(
            children: [
              Container(
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(10.0),
                    color: Colors.white),
                margin: EdgeInsets.fromLTRB(0.0, 30.0, 0.0, 5.0),
                padding: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 20.0),
                child: Column(
                  children: <Widget>[
                    Container(
                      alignment: Alignment.center,
                      margin:
                          EdgeInsets.only(left: 0.0, right: 20.0, top: 30.0),
                      child: Text(TranslationBase.of(context).testFee,
                          style: TextStyle(
                              color: Colors.black,
                              fontSize: 22.0,
                              fontWeight: FontWeight.bold)),
                    ),
                    if(model.erPatientShareModel!=null)
                    Table(
                      children: [
                        TableRow(children: [
                          TableCell(
                              child:
                                  Texts(TranslationBase.of(context).testFee)),
                          TableCell(
                              child: Texts(model
                                  .erPatientShareModel.patientShare
                                  .toStringAsFixed(2))),
                        ]),
                        TableRow(children: [
                          TableCell(
                              child: Texts(
                                  TranslationBase.of(context).patientTaxToDo)),
                          TableCell(
                              child: Texts(model
                                  .erPatientShareModel.patientTaxAmount
                                  .toStringAsFixed(2))),
                        ]),
                        TableRow(children: [
                          TableCell(
                              child: Texts(TranslationBase.of(context)
                                  .patientShareTotalToDo)),
                          TableCell(
                              child: Texts(model
                                  .erPatientShareModel.patientShareWithTax
                                  .toStringAsFixed(2))),
                        ]),
                      ],
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
        bottomSheet: Container(
          height: 76,
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: SecondaryButton(
              color: Theme.of(context).primaryColor,
              label: TranslationBase.of(context).next.toUpperCase(),
              onTap: () {
                Navigator.push(context, FadePage(page: PaymentMethod())).then(
                  (value) {
                    //TODO Haroun call API here
                  },
                );
              },
            ),
          ),
        ),
      ),
    );
  }



}
