import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/profile/discharge_summary_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/screens/doctor/doctor_replay/doctor_reply_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart';
import 'package:flutter/material.dart';

import 'discharge_Summary_widget.dart';

class PendingDischargeSummary extends StatefulWidget {
  final Function changeCurrentTab;
  final PatiantInformtion patient;

  const PendingDischargeSummary({Key key, this.changeCurrentTab, this.patient})
      : super(key: key);

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

class _PendingDischargeSummaryState extends State<PendingDischargeSummary> {
  int pageIndex = 1;

  @override
  Widget build(BuildContext context) {
    return BaseView<DischargeSummaryViewModel>(
      onModelReady: (model) {
        model.getPendingDischargeSummary(
            patientId: widget.patient.patientId,
            admissionNo: int.parse(widget.patient.admissionNo),

        );
      },
      builder: (_, model, w) => AppScaffold(
        baseViewModel: model,
        isShowAppBar: false,
        body: model.pendingDischargeSummaryList.isEmpty
            ? ErrorMessage(
                error: TranslationBase.of(context)
                    .noItem) // DrAppEmbeddedError(error: TranslationBase.of(context).noItem)
            : Column(
                children: [
                  Expanded(
                    child: Container(
                      padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
                      child: ListView.builder(
                          scrollDirection: Axis.vertical,
                          itemCount: model.pendingDischargeSummaryList.length,
                          shrinkWrap: true,
                          itemBuilder: (BuildContext ctxt, int index) {
                            return Column(
                              children: [
                                InkWell(
                                  child: DischargeSummaryWidget(
                                      dischargeSummary: model
                                          .pendingDischargeSummaryList[index]),
                                ),
                              ],
                            );
                          }),
                    ),
                  ),
                ],
              ),
      ),
    );
  }
}
