import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/delete_baby_model.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/child_vaccines_view_model.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/add_newchild_page.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/vaccinationtable_page.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:flutter_flexible_toast/flutter_flexible_toast.dart'; import 'ChidDetailsWidget.dart'; import 'dialogs/delete_child.dart'; class ChildPage extends StatefulWidget { final List_UserInformationModel informationModel; const ChildPage({Key key, this.informationModel}) : super(key: key); @override _ChildPageState createState() => _ChildPageState(); } class _ChildPageState extends State with SingleTickerProviderStateMixin { DeleteBaby deleteBaby = DeleteBaby(); @override Widget build(BuildContext context) { var checkedValue = true; return BaseView( onModelReady: (model) => model.getNewUserOrders(), builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarTitle: TranslationBase.of(context).vaccination, baseViewModel: model, body: SingleChildScrollView( child: Container( margin: EdgeInsets.only(left: 10, right: 10, top: 10), child: Column( children: [ GridView.builder( shrinkWrap: true, primary: false, physics: NeverScrollableScrollPhysics(), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: MediaQuery.of(context).size.width / (MediaQuery.of(context).size.height / 1.45), ), itemCount: model.babyInformationModelList.length, itemBuilder: (BuildContext context, int index) { return ChildDetailsWidget( model: model, babyInfo: model.babyInformationModelList[index], informationModel: widget.informationModel, onTapDelete: () { showDialog( context: context, child: DeleteChild(onTap: () async { await model.deleteBabyOrders(babyInfo: model.babyInformationModelList[index]); if (model.isDeleted) { AppToast.showSuccessToast( message: TranslationBase.of(context).emailSuccess, toastLength: Toast.LENGTH_LONG); } else { AppToast.showSuccessToast(message: model.error); } }), ); }, ); }, ), SizedBox( height: 15, ), ], ), ), ), bottomSheet: Container( height: MediaQuery.of(context).size.height * 0.10, width: double.infinity, padding: EdgeInsets.all(15), child: SecondaryButton( textColor: Colors.white, color: checkedValue == false ? Colors.white24 : Color.fromRGBO( 63, 72, 74, 1, ), label: TranslationBase.of(context).addChild, // onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => AddNewChildPage(), ), ).then((value) { if (value!=null) model.getNewUserOrders(); }); }, ), ), ), ); } }