import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/models/patient/lab_orders/lab_orders_res_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/doctor/lab_result_widget.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/card_with_bgNew_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class LabResult extends StatefulWidget {
  final LabOrdersResModel labOrders;

  LabResult({Key key, this.labOrders});

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

class _LabResultState extends State<LabResult> {
  @override
  Widget build(BuildContext context) {
    return BaseView<PatientViewModel>(
      onModelReady: (model) => model.getLabResult(widget.labOrders),
      builder: (_, model, w) => AppScaffold(
        baseViewModel: model,
        appBarTitle: TranslationBase.of(context).labOrders,
        body: model.labResultList.length == 0
            ? DrAppEmbeddedError(
                error: TranslationBase.of(context).errorNoLabOrders)
            : Container(
                margin: EdgeInsets.fromLTRB(SizeConfig.realScreenWidth * 0.05,
                    0, SizeConfig.realScreenWidth * 0.05, 0),
                child: ListView(
                  children: <Widget>[
                    CardWithBgWidgetNew(
                      widget: Column(
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: <Widget>[
                              AppText(
                                TranslationBase.of(context).orderNo,
                                fontSize: 2 * SizeConfig.textMultiplier,
                                color: Colors.grey[800],
                              ),
                              AppText(
                                ' ${widget.labOrders.orderNo}',
                                fontSize: 2 * SizeConfig.textMultiplier,
                                color: Colors.grey[800],
                              ),
                            ],
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: <Widget>[
                              AppText(
                                TranslationBase.of(context).invoiceNo,
                                fontSize: 2 * SizeConfig.textMultiplier,
                                color: Colors.grey[800],
                              ),
                              AppText(
                                ' ${widget.labOrders.invoiceNo}',
                                fontSize: 2 * SizeConfig.textMultiplier,
                                color: Colors.grey[800],
                              ),
                            ],
                          ),

                        ],
                      ),
                    ),
                    CardWithBgWidgetNew(
                        widget: LabResultWidget(
                      labResult: model.labResultList,
                    ))
                  ],
                ),
              ),
      ),
    );
  }
}
