import 'package:doctor_app_flutter/core/viewModel/profile/discharge_summary_view_model.dart';
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.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/error_message.dart';
import 'package:flutter/material.dart';

import 'discharge_Summary_widget.dart';

class PendingDischargeSummary extends StatefulWidget {
  final Function? changeCurrentTab;
  final PatiantInformtion? patient;
  final bool isVidaPlusProject;

  const PendingDischargeSummary({Key? key, this.changeCurrentTab, this.patient, this.isVidaPlusProject = false})
      : 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!,
          clinicId: widget.patient?.clinicId,
          admissionNo: widget.isVidaPlusProject? widget.patient?.admissionID ?? -1 :int.parse(widget.patient!.admissionNo!),
        );
      },
      builder: (_, model, w) => AppScaffold(
        baseViewModel: model,
        isShowAppBar: false,
        body: model.pendingDischargeSummaryList.isEmpty
            ? Center(
                child: ErrorMessage(
                    error: TranslationBase.of(context).noDataAvailable),
              ) // DrAppEmbeddedError(error: TranslationBase.of(context).noItem)
            : Column(
                children: [
                  Padding(
                    padding: EdgeInsets.all(12.0),
                    child: Column(
                      children: [
                        Row(
                          children: [
                            AppText(
                              TranslationBase.of(context).discharge,
                              fontSize: 15.0,
                              fontWeight: FontWeight.w600,
                              fontFamily: 'Poppins',
                            ),
                          ],
                        ),
                        Row(
                          children: [
                            AppText(
                              TranslationBase.of(context).summary,
                              fontSize: 25.0,
                              fontWeight: FontWeight.w700,
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                  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]),
                                ),
                              ],
                            );
                          }),
                    ),
                  ),
                ],
              ),
      ),
    );
  }
}
