import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/inpatient_services/inpatient_services_view_model.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
import 'package:provider/provider.dart';

class GeneralInstructionsPage extends StatelessWidget {
  const GeneralInstructionsPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.bgScaffoldColor,
      body: CollapsingListView(
        title: "General Instructions",
        child: Padding(
          padding: EdgeInsets.all(24.h),
          child: Container(
            decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
              color: AppColors.whiteColor,
              borderRadius: 24.r,
              hasShadow: true,
            ),
            child: Consumer<InpatientServicesViewModel>(builder: (context, inpatientServicesVM, child) {
              return inpatientServicesVM.isGeneralInstructionsLoading
                  ? ListView.builder(
                      padding: EdgeInsets.zero,
                      shrinkWrap: true,
                      itemCount: 5,
                      itemBuilder: (context, index) {
                        return Column(
                          children: [
                            "Lorem <i>ipsum dolor sit</i> amet, consectetur <b>adipiscing elit</b>".toText16().toShimmer2(),
                            SizedBox(
                              height: 16.h,
                            ),
                          ],
                        ).paddingSymmetrical(24.h, 16.h);
                      },
                    )
                  : inpatientServicesVM.getGeneralInstructionsList.isNotEmpty
                      ? ListView.builder(
                          padding: EdgeInsets.zero,
                          shrinkWrap: true,
                          itemCount: inpatientServicesVM.getGeneralInstructionsList.length,
                          itemBuilder: (context, index) {
                            final instruction = inpatientServicesVM.getGeneralInstructionsList[index];
                            return "• ${instruction.text}".toText16(weight: FontWeight.w500).paddingSymmetrical(24.h, 16.h);
                          },
                        )
                      : Utils.getNoDataWidget(context);
            }),
          ),
        ),
      ),
    );
  }
}
