import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/laboratory_result_widget.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class LaboratoryResultPage extends StatelessWidget {
  final PatientLabOrders patientLabOrders;

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

  @override
  Widget build(BuildContext context) {
    return BaseView<LabsViewModel>(
      onModelReady: (model) => model.getLaboratoryResult(
          invoiceNo: patientLabOrders.invoiceNo,
          clinicID: patientLabOrders.clinicID,
          projectID: patientLabOrders.projectID,
          orderNo: patientLabOrders.orderNo),
      builder: (_, model, widget) => AppScaffold(
        isShowAppBar: true,
        appBarTitle: 'Laboratory result',
        baseViewModel: model,
        body: Scaffold(
          body: ListView.builder(
            itemBuilder: (context, index) => LaboratoryResultWidget(
              onTap: () => model.sendLabReportEmail(patientLabOrder: patientLabOrders),
              billNo: patientLabOrders.invoiceNo,
              details: model.patientLabSpecialResult[index].resultDataHTML,
              orderNo: patientLabOrders.orderNo,
              patientLabOrder: patientLabOrders,
            ),
            itemCount: model.patientLabSpecialResult.length,
          ),
        ),
      ),
    );
  }
}
