From 1a6802ce24e1f6290850d32f8e48d8cebde50235 Mon Sep 17 00:00:00 2001 From: "Mirza.Shafique" Date: Sun, 24 Oct 2021 16:31:52 +0300 Subject: [PATCH] Child Vaccine 3 --- lib/config/localized_values.dart | 2 +- .../all_habib_medical_service_page.dart | 3 +- .../ChildVaccines/add_newchild_page.dart | 445 ++++++++++-------- .../ChildVaccines/new/child_initial_page.dart | 149 ++++++ .../ChildVaccines/new/child_vaccine_page.dart | 2 +- lib/pages/landing/widgets/services_view.dart | 3 +- 6 files changed, 416 insertions(+), 188 deletions(-) create mode 100644 lib/pages/ChildVaccines/new/child_initial_page.dart diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index d9080ddb..7726b595 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1116,7 +1116,7 @@ const Map localizedValues = { "childName": {"en": "'CHILD NAME'", "ar": "إسم الطفل"}, "recordDeleted": {"en": "'Record Deleted'", "ar": "تم حذف السجل"}, "msg_email_address_up_to_date": { - "en": " Please ensure that the email address is up-to-date and proceed to view the schedule.", + "en": "Please ensure that the email address is up-to-date and proceed to view the schedule.", "ar": " يرجى التأكد من تحديث عنوان البريد الإلكتروني والمتابعة لعرض الجدول" }, "add-new-child": {"en": "ADD NEW CHILD", "ar": "إضافة طفل جديد"}, diff --git a/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart b/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart index 8f130d93..ffb974e1 100644 --- a/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart +++ b/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart @@ -15,6 +15,7 @@ import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/parking_page.da import 'package:diplomaticquarterapp/pages/Blood/blood_donation.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/child_vaccines_page.dart'; +import 'package:diplomaticquarterapp/pages/ChildVaccines/new/child_initial_page.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/new/child_vaccine_page.dart'; import 'package:diplomaticquarterapp/pages/ContactUs/findus/findus_page.dart'; import 'package:diplomaticquarterapp/pages/Covid-DriveThru/covid-drivethru-location.dart'; @@ -278,7 +279,7 @@ class _AllHabibMedicalServiceState extends State { ServicesContainer( onTap: () => Navigator.push( context, - FadePage(page: ChildVaccinePage()), + FadePage(page: ChildInitialPage()), ), imageLocation: 'assets/images/new-design/children_vaccines_icon.png', title: TranslationBase.of(context).childVaccine, diff --git a/lib/pages/ChildVaccines/add_newchild_page.dart b/lib/pages/ChildVaccines/add_newchild_page.dart index edbd0745..496488d7 100644 --- a/lib/pages/ChildVaccines/add_newchild_page.dart +++ b/lib/pages/ChildVaccines/add_newchild_page.dart @@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/add_new_chil import 'package:diplomaticquarterapp/pages/Blood/new_text_Field.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/medical/active_medications/DayCheckBoxDialog.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -27,15 +28,7 @@ class AddNewChildPage extends StatefulWidget { String dateAdd; List _scheduleList = List(); - List daysOfWeek = [ - DayOfWeek.Monday, - DayOfWeek.Tuesday, - DayOfWeek.Wednesday, - DayOfWeek.Thursday, - DayOfWeek.Friday, - DayOfWeek.Saturday, - DayOfWeek.Sunday - ]; + List daysOfWeek = [DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday, DayOfWeek.Sunday]; DateTime startDay; DateTime endDay; @@ -43,13 +36,11 @@ class AddNewChildPage extends StatefulWidget { //AddNewChildPage({Key key, this.frequency, this.days, this.itemDescription}) : super(key: key); AddNewChildPage({Key key, this.frequency, this.days, this.itemDescription}) { startDay = DateTime.now(); - endDay = - DateTime.now(); //endDay = DateTime.now().add(Duration(days: days)); + endDay = DateTime.now(); //endDay = DateTime.now().add(Duration(days: days)); int hour = 24; //(24 / frequency).round(); int durations = 24 ~/ hour; for (int count = 0; count < durations; count++) { - _scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month, - DateTime.now().day, (hour * count))); + _scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, (hour * count))); } } @@ -81,197 +72,210 @@ class _AddNewChildPageState extends State { @override Widget build(BuildContext context) { - var size = MediaQuery.of(context).size; return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarTitle: TranslationBase.of(context).vaccination, - body: SingleChildScrollView( - physics: ScrollPhysics(), - child: Container( - margin: EdgeInsets.all(12), - child: Column( - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 20, - ), - Texts( - TranslationBase.of(context).vaccinationAddChildMsg, - //+model.user.firstName, - textAlign: TextAlign.center, - ), - SizedBox( - height: 12, - ), - NewTextFields( - hintText: TranslationBase.of(context).firstName, - controller: _firstTextController, - ), - SizedBox( - height: 12, - ), - NewTextFields( - hintText: TranslationBase.of(context).middleName, - controller: _secondTextController, - ), - SizedBox( - height: 12, - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).gender, - textAlign: TextAlign.end, - ), - ], - ), - Container( - width: double.infinity, - height: size.height * 0.12, + showNewAppBar: true, + body: Container( + child: Column( + children: [ + Expanded( + child: Padding( padding: EdgeInsets.all(12), - child: Row( - crossAxisAlignment: CrossAxisAlignment.stretch, - mainAxisAlignment: MainAxisAlignment.center, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Expanded( - child: Container( - color: Colors.white, - child: SecondaryButton( - textColor: - checkedValue == 1 ? Colors.white : Colors.black, - color: checkedValue == 1 ? Colors.red : Colors.white, - label: TranslationBase.of(context).male, - onTap: () { - setState(() { - checkedValue = 1; - print("checkedValue=" + checkedValue.toString()); - }); + Text( + TranslationBase.of(context).vaccinationAddChildMsg, + //+model.user.firstName, + style: TextStyle( + fontSize: 16, + letterSpacing: -0.64, + fontWeight: FontWeight.w600, + ), + ), + SizedBox( + height: 12, + ), + inputWidget(TranslationBase.of(context).firstName, "", _firstTextController), + SizedBox( + height: 12, + ), + inputWidget(TranslationBase.of(context).middleName, "", _secondTextController), - // bloodDetails. - }, - ), + SizedBox( + height: 12, + ), + Text( + TranslationBase.of(context).selectGender, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.48, ), ), - Expanded( - child: Container( - color: Colors.white, - child: SecondaryButton( - textColor: - checkedValue == 2 ? Colors.white : Colors.black, - color: checkedValue == 2 ? Colors.red : Colors.white, - label: TranslationBase.of(context).female, - // - onTap: () { + Row( + children: [ + Expanded( + child: Row( + children: [ + Radio( + value: checkedValue, + groupValue: 1, + onChanged: (v) { + setState(() { + checkedValue = 1; + }); + }), + Text( + TranslationBase.of(context).male, + style: TextStyle( + fontSize: 12, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ) + ], + ), + ), + Expanded( + child: Row( + children: [ + Radio( + value: checkedValue, + groupValue: 2, + onChanged: (v) { + setState(() { + checkedValue = 2; + }); + }), + Text( + TranslationBase.of(context).female, + style: TextStyle( + fontSize: 12, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ) + ], + ), + ), + ], + ), + + //========== + SizedBox( + height: 6, + ), + + InkWell( + onTap: () { + DatePicker.showDatePicker( + context, + showTitleActions: true, + // minTime: DateTime( + // DateTime.now().year, DateTime.now().month - 1, 1), + minTime: DateTime(1, 1, 1), + maxTime: DateTime.now(), + onConfirm: (date) { setState(() { - checkedValue = 2; - print("checkedValue=" + checkedValue.toString()); + widget.startDay = date; }); - // bloodDetails.city=_selectedHospital.toString(); - - // bloodDetails. }, + currentTime: widget.startDay, + // locale: projectViewModel.localeType + ); + }, + child: Container( + width: double.infinity, + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).dob, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + Text( + //getStartDay() + // DateUtil.yearMonthDay(DateTime.now()) + getStartDay(), + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + ), + ], + ), + Icon( + Icons.calendar_today, + color: Color(0xff575757), + size: 18, + ) + ], ), ), - ) + ), + SizedBox( + height: 12, + ), + + //========= ], ), ), - //========== - SizedBox( - height: 6, - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).dob, - textAlign: TextAlign.end, - ), - ], - ), - InkWell( - onTap: () { - DatePicker.showDatePicker( - context, - showTitleActions: true, - // minTime: DateTime( - // DateTime.now().year, DateTime.now().month - 1, 1), - minTime: DateTime(1, 1, 1), - maxTime: DateTime.now(), - onConfirm: (date) { - setState(() { - widget.startDay = date; - }); - }, - currentTime: widget.startDay, - // locale: projectViewModel.localeType - ); - }, - child: Container( - padding: EdgeInsets.all(12), - width: double.infinity, - height: 65, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts(//getStartDay() - // DateUtil.yearMonthDay(DateTime.now()) - getStartDay()), - Icon( - Icons.calendar_today, - color: Colors.black, - ) - ], - ), - ), - ), - SizedBox( - height: 12, - ), - Container( - height: MediaQuery.of(context).size.height * 0.12, - 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).add, - // - onTap: () async { - newChild.babyName = _firstTextController.text + - " " + - _secondTextController.text; - newChild.gender = checkedValue.toString(); - newChild.strDOB = getStartDay(); - newChild.tempValue = true; - newChild.isLogin = true; + ), + Container( + width: double.infinity, + padding: EdgeInsets.all(16), + color: Colors.white, + child: SecondaryButton( + textColor: Colors.white, + color: checkedValue == false ? Colors.white24 : CustomColors.accentColor, + label: TranslationBase.of(context).add, + // + onTap: () async { + newChild.babyName = _firstTextController.text + " " + _secondTextController.text; + newChild.gender = checkedValue.toString(); + newChild.strDOB = getStartDay(); + newChild.tempValue = true; + newChild.isLogin = true; - await model.createNewBabyOrders(newChild: newChild); - if (model.isAdded) { - AppToast.showSuccessToast(message: TranslationBase.of(context).childAddedSuccessfully); - Navigator.pop(context, model.isAdded); - } else { - //TODO handling error - } - }, - ), + await model.createNewBabyOrders(newChild: newChild); + if (model.isAdded) { + AppToast.showSuccessToast(message: TranslationBase.of(context).childAddedSuccessfully); + Navigator.pop(context, model.isAdded); + } else { + //TODO handling error + } + }, ), - //========= - ], - ), + ), + ], ), ), // bottomSheet: @@ -313,4 +317,77 @@ class _AddNewChildPageState extends State { ), ); } + + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, + {VoidCallback suffixTap, bool isEnable = true, bool hasSelection = false, int lines, bool isInputTypeNum = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: isInputTypeNum ? TextInputType.number : TextInputType.text, + controller: _controller, + maxLines: lines, + onChanged: (value) => {setState(() {})}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + suffixIconConstraints: BoxConstraints(minWidth: 50), + suffixIcon: suffixTap == null ? null : IconButton(icon: Icon(Icons.mic, color: Color(0xff2E303A)), onPressed: suffixTap), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], + ), + ), + ); + } } diff --git a/lib/pages/ChildVaccines/new/child_initial_page.dart b/lib/pages/ChildVaccines/new/child_initial_page.dart new file mode 100644 index 00000000..6069f814 --- /dev/null +++ b/lib/pages/ChildVaccines/new/child_initial_page.dart @@ -0,0 +1,149 @@ +import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; +import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/user_information_view_model.dart'; +import 'package:diplomaticquarterapp/pages/ChildVaccines/child_page.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/input/text_field.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 'child_vaccine_page.dart'; + +class ChildInitialPage extends StatefulWidget { + @override + _ChildVaccinesPageState createState() => _ChildVaccinesPageState(); +} + +class _ChildVaccinesPageState extends State with SingleTickerProviderStateMixin { + TextEditingController titleController = TextEditingController(); + var checkedValue = false; + String addEmail = ""; + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getUserInformationRequestOrders(), + builder: (_, model, w) => AppScaffold( + isShowAppBar: true, + isShowDecPage: true, + showNewAppBarTitle: true, + showNewAppBar: true, + description: TranslationBase.of(context).childVaccineInfo, + imagesInfo: [ + ImagesInfo( + imageEn: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/child-vaccines/en/0.png', + imageAr: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/child-vaccines/ar/0.png'), + ImagesInfo( + imageEn: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/child-vaccines/en/1.png', + imageAr: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/child-vaccines/ar/1.png') + ], + appBarTitle: TranslationBase.of(context).vaccination, + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).welcomeBack, + style: TextStyle( + fontSize: 16, + letterSpacing: -0.64, + fontWeight: FontWeight.w600, + ), + ), + SizedBox( + height: 16, + ), + Text( + TranslationBase.of(context).msg_email_address_up_to_date, + style: TextStyle( + fontSize: 16, + letterSpacing: -0.64, + fontWeight: FontWeight.w600, + ), + ), + SizedBox( + height: 20, + ), + TextFields( + fillColor: Colors.red, + hintText: model.user != null ? model.user.emailAddress : "", + controller: titleController, + fontSize: 14, + hintColor: Colors.black, + fontWeight: FontWeight.w600, + suffixIcon: checkedValue ? Icons.check_box : Icons.check_box_outline_blank, + onSuffixTap: () { + setState(() { + checkedValue = !checkedValue; + }); + }, + onChanged: (text) { + addEmail = text; + model.user.emailAddress == addEmail ? checkedValue = false : checkedValue = true; + }, + validator: (value) { + if (value == null) { + return model.user.emailAddress; + } else { + return model.user.emailAddress; + } + }, + ), + ], + ), + ), + mFlex(1), + Container( + width: double.infinity, + color: Colors.white, + padding: EdgeInsets.all(16), + child: Column( + children: [ + if (checkedValue) + SecondaryButton( + textColor: Colors.white, + color: checkedValue == false ? Colors.white24 : CustomColors.green, + label: TranslationBase.of(context).updateEmail, + // + onTap: () { + model.user.emailAddress = addEmail.toString(); + AppToast.showSuccessToast(message: TranslationBase.of(context).updateEmailMsg); + // bloodDetails.city=_selectedHospital.toString(); + + // bloodDetails. + }, + ), + if (checkedValue) mHeight(16), + SecondaryButton( + textColor: Colors.white, + color: CustomColors.accentColor, + label: TranslationBase.of(context).viewListChildren, + // + onTap: () => Navigator.push( + context, + FadePage( + page: ChildVaccinePage(), + ), + ), + ), + ], + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/ChildVaccines/new/child_vaccine_page.dart b/lib/pages/ChildVaccines/new/child_vaccine_page.dart index 2a876cfa..71e1ea3f 100644 --- a/lib/pages/ChildVaccines/new/child_vaccine_page.dart +++ b/lib/pages/ChildVaccines/new/child_vaccine_page.dart @@ -56,7 +56,7 @@ class _ChildPageState extends State with SingleTickerProviderS ); }, child: Container( - margin: EdgeInsets.only(left: 16, right: 16), + margin: EdgeInsets.only(left: 16, right: 16,top: index==0?16:0,bottom: index==model.babyInformationModelList.length-1?16:0), decoration: BoxDecoration( shape: BoxShape.rectangle, borderRadius: BorderRadius.all(Radius.circular(12)), diff --git a/lib/pages/landing/widgets/services_view.dart b/lib/pages/landing/widgets/services_view.dart index 2eae79d3..37e7cd74 100644 --- a/lib/pages/landing/widgets/services_view.dart +++ b/lib/pages/landing/widgets/services_view.dart @@ -14,6 +14,7 @@ import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/parking_page.da import 'package:diplomaticquarterapp/pages/Blood/blood_donation.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/child_vaccines_page.dart'; +import 'package:diplomaticquarterapp/pages/ChildVaccines/new/child_initial_page.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/new/child_vaccine_page.dart'; import 'package:diplomaticquarterapp/pages/ContactUs/contact_us_page.dart'; import 'package:diplomaticquarterapp/pages/Covid-DriveThru/covid-drivethru-location.dart'; @@ -103,7 +104,7 @@ class ServicesView extends StatelessWidget { } else if (index == 14) { Navigator.push( context, - FadePage(page: ChildVaccinePage()), + FadePage(page: ChildInitialPage()), ); } else if (index == 15) { Navigator.pop(context);