
import 'package:hmg_patient_app/core/model/pharmacy/categorise_parent_model.dart';
import 'package:hmg_patient_app/core/model/pharmacy/pharmacy_categorise.dart';
import 'package:hmg_patient_app/core/viewModels/pharmacy_categorise_view_model.dart';
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:hmg_patient_app/pages/sub_categorise_page.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/widgets/data_display/text.dart';
import 'package:hmg_patient_app/widgets/others/app_scaffold_pharmacy_widget.dart';
import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
import 'package:hmg_patient_app/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'base/base_view.dart';
import 'package:provider/provider.dart';




class SubCategoriseModalsheet extends StatefulWidget {
  String? id;
  String? titleName;

  SubCategoriseModalsheet({this.id, this.titleName});
  @override
  _SubCategoriseModalsheetState createState() => _SubCategoriseModalsheetState(id: id, titleName: titleName);

}

class _SubCategoriseModalsheetState extends State<SubCategoriseModalsheet> {
  String? id;
  String? titleName;
//  List<CategoriseParentModel> categoriesList = [];
  _SubCategoriseModalsheetState({this.id, this.titleName});

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);
    return BaseView<PharmacyCategoriseViewModel>(
        onModelReady: (model) => model.getCategoriseParent(i: id),
        builder: (_, model, wi) => AppScaffold(
           //   appBarTitle: titleName,
              appBarTitle: TranslationBase.of(context).categorise,
              isBottomBar: true,
              isShowAppBar: true,
              isPharmacy: true,
              backgroundColor: Colors.white,
              isShowDecPage: false,
              showPharmacyCart: false,
              showHomeAppBarIcon: false,
              baseViewModel: model,
             body: Container(
             color: Colors.white,
               child: Center(
                 child: ListView.builder(
              scrollDirection: Axis.vertical,
              itemCount: model.categoriseParent.length,
              itemBuilder: (BuildContext context, int index) {
                   return Container(
                    child: Padding(
                    padding: EdgeInsets.all(4.0),
                      child: InkWell(
                       child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Texts(projectViewModel.isArabic
                              ? model.categoriseParent[index].namen
                              : model.categoriseParent[index].name),
                          SizedBox(
                            height: 10,
                          ),
                          Divider(
                            thickness: 0.6,
                            color: Colors.black12,
                          )
                        ],
                      ),
                      onTap: () {
                        Navigator.push(
                          context,
                          FadePage(
                              page: SubCategorisePage(
                                title:  projectViewModel
                                    .isArabic
                                    ? model.categoriseParent[index].namen
                                    : model.categoriseParent[index].name,
                              //  title: model.categoriseParent[index].name,
                                id: model.categoriseParent[index].id,
                                parentId: id,
                              )),
                        );
                      },
                    ),
                  ),
                );
              }),
        ),
      ),

      ),
    );
  }
//  getCatName() {
//
//    if (widget.id == '1' )
//      return Texts("text1");
//    else if (widget.id == '2' )
//      return Texts("text2");
//    else if (widget.id == '3')
//      return Texts("text3");
//    else if (widget.id == '4' )
//      return Texts("text4");
//  }


}