import 'package:doctor_app_flutter/core/model/labs/patient_lab_orders.dart';
import 'package:doctor_app_flutter/core/viewModel/labs_view_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'laboratory_result_widget.dart';

class LaboratoryResultPage extends StatefulWidget {
  final PatientLabOrders patientLabOrders;
  final PatiantInformtion patient;

  LaboratoryResultPage({Key key, this.patientLabOrders, this.patient});

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

class _LaboratoryResultPageState extends State<LaboratoryResultPage> {
  @override
  Widget build(BuildContext context) {
    return BaseView<LabsViewModel>(
      onModelReady: (model) => model.getLaboratoryResult(
          invoiceNo: widget.patientLabOrders.invoiceNo,
          clinicID: widget.patientLabOrders.clinicID,
          projectID: widget.patientLabOrders.projectID,
          orderNo: widget.patientLabOrders.orderNo,
          patient: widget.patient),
      builder: (_, model, w) => AppScaffold(
        isShowAppBar: true,
        appBarTitle: TranslationBase.of(context).labResults,
        baseViewModel: model,
        body: Scaffold(
          body: ListView.builder(
            itemBuilder: (context, index) => LaboratoryResultWidget(
              onTap: () async {

              },
              billNo: widget.patientLabOrders.invoiceNo,
              details: model.patientLabSpecialResult[index].resultDataHTML,
              orderNo: widget.patientLabOrders.orderNo,
              patientLabOrder: widget.patientLabOrders,
              patient: widget.patient,
            ),
            itemCount: model.patientLabSpecialResult.length,
          ),
        ),
      ),
    );
  }
}
