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 AllDischargeSummary extends StatefulWidget {
  final Function? changeCurrentTab;
  final PatiantInformtion? patient;
  final bool isVidaPlusProject;

  const AllDischargeSummary({this.changeCurrentTab, this.patient, this.isVidaPlusProject = false});

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

class _AllDischargeSummaryState extends State<AllDischargeSummary> {
  int pageIndex = 1;

  @override
  Widget build(BuildContext context) {
    return BaseView<DischargeSummaryViewModel>(
      onModelReady: (model) {
        model.getAllDischargeSummary(
          patientId: widget.patient!.patientId!,
          admissionNo: widget.isVidaPlusProject? widget.patient?.admissionID ?? -1 :int.parse(widget.patient!.admissionNo!),

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