import 'package:doctor_app_flutter/core/viewModel/pednding_orders_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/patients/profile/patient-profile-app-bar.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart';
import 'package:flutter/material.dart';

class PendingOrdersScreen extends StatelessWidget {
  const PendingOrdersScreen({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final routeArgs = ModalRoute.of(context).settings.arguments as Map;
    PatiantInformtion patient = routeArgs['patient'];
    patient = routeArgs['patient'];
    String patientType = routeArgs['patientType'];
    bool isInpatient = routeArgs['isInpatient'];
    return BaseView<PendingOrdersViewModel>(
      onModelReady: (model) => model.getPendingOrders(
          patientId: patient.patientMRN,
          admissionNo: int.parse(patient.admissionNo)),
      builder:
          (BuildContext context, PendingOrdersViewModel model, Widget child) =>
              AppScaffold(
        appBar: PatientProfileAppBar(
          patient,
          isInpatient: isInpatient,
        ),
        isShowAppBar: true,
        baseViewModel: model,
        appBarTitle: "Pending Orders",
        body: model.pendingOrdersList == null ||
                model.pendingOrdersList.length == 0
            ? DrAppEmbeddedError(
                error: TranslationBase.of(context).noDataAvailable)
            : Container(
                child: ListView.builder(
                    itemCount: model.pendingOrdersList.length,
                    itemBuilder: (BuildContext ctxt, int index) {
                      return Padding(
                        padding: EdgeInsets.all(8.0),
                        child: Container(
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.all(
                              Radius.circular(10.0),
                            ),
                            border: Border.all(
                                color: Color(0xFF707070), width: 0.30),
                          ),
                          child: Padding(
                            padding: EdgeInsets.all(8.0),
                            child:
                                AppText(model.pendingOrdersList[index].notes),
                          ),
                        ),
                      );
                    })),
      ),
    );
  }
}
