diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 05bc4b52..3da1ff68 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -396,8 +396,9 @@ const Map localizedValues = { "PaymentOnline": {"en": "Service", "ar": "الالكتروني"}, "OnlineCheckIn": {"en": "Online Check-In", "ar": "مدفوعات معلقة"}, "MyBalances": {"en": "My Balances", "ar": "رصيدي"}, + "MyWallet": {"en": "My Wallet", "ar": "محفظتى"}, "BalanceAmount": {"en": "Wallet Amount", "ar": "مبلغ المحفظة"}, - "TotalBalance": {"en": "Total Amount", "ar": "المبلغ الإجمالي"}, + "TotalBalance": {"en": "Total Balance", "ar": "إجمالي الرصيد"}, "CreateAdvancedPayment": {"en": "Recharge Wallet", "ar": "شحن المحفظة"}, "AdvancePayment": {"en": "Advance Payment", "ar": "الدفع مقدما"}, "AdvancePaymentLabel": {"en": "You can create and add an Advanced Payment for your account or other accounts.", "ar": "يمكنك تحويل مبلغ لحسابك لدى المجموعة أو لحساب احد المراجعين"}, diff --git a/lib/pages/AlHabibMedicalService/E-Referral/dialogs/select_country_ingo_Dialog.dart b/lib/pages/AlHabibMedicalService/E-Referral/dialogs/select_country_ingo_Dialog.dart index d58fd29f..8046346f 100644 --- a/lib/pages/AlHabibMedicalService/E-Referral/dialogs/select_country_ingo_Dialog.dart +++ b/lib/pages/AlHabibMedicalService/E-Referral/dialogs/select_country_ingo_Dialog.dart @@ -4,6 +4,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; // ignore: must_be_immutable + +// todo 'sikander' remove this file when usage known class SelectCountryDialog extends StatefulWidget { final Function(dynamic) onValueSelected; dynamic selectedCountry; diff --git a/lib/pages/AlHabibMedicalService/E-Referral/dialogs/select_search_criteria_dialog.dart b/lib/pages/AlHabibMedicalService/E-Referral/dialogs/select_search_criteria_dialog.dart deleted file mode 100644 index e970f208..00000000 --- a/lib/pages/AlHabibMedicalService/E-Referral/dialogs/select_search_criteria_dialog.dart +++ /dev/null @@ -1,139 +0,0 @@ -import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/EReferral/search_criteria_model.dart'; -import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -// ignore: must_be_immutable -class SelectSearchCriteriaDialog extends StatefulWidget { - List searchCriteria = [ - SearchCriteriaModel(name: "Identification Number",nameAr:"رقم الهوية",value: 1), - SearchCriteriaModel(name: "Referral Number",nameAr:"رقم الإحالة",value: 2), - ]; - final Function(SearchCriteriaModel) onValueSelected; - SearchCriteriaModel selectedCriteria; - ProjectViewModel projectViewModel; - - SelectSearchCriteriaDialog( - {Key key, this.onValueSelected, this.selectedCriteria, this.projectViewModel}); - - @override - _SelectSearchCriteriaDialogState createState() => _SelectSearchCriteriaDialogState(); -} - -class _SelectSearchCriteriaDialogState extends State { - @override - void initState() { - super.initState(); - widget.selectedCriteria = widget.selectedCriteria ?? widget.searchCriteria[0]; - } - - @override - Widget build(BuildContext context) { - return SimpleDialog( - children: [ - Column( - children: [ - Text(TranslationBase.of(context).searchCriteria), - Divider(), - ...List.generate( - widget.searchCriteria.length, - (index) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 2, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - widget.selectedCriteria = widget.searchCriteria[index]; - }); - }, - child: ListTile( - title: Text(widget.projectViewModel.isArabic ? widget.searchCriteria[index].nameAr : widget.searchCriteria[index].name), - leading: Radio( - value: widget.searchCriteria[index], - groupValue: widget.selectedCriteria, - activeColor: Colors.red[800], - onChanged: (value) { - setState(() { - widget.selectedCriteria = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - ], - ), - ), - SizedBox( - height: 5.0, - ), - Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Center( - child: Texts( - TranslationBase.of(context).cancel.toUpperCase(), - color: Colors.red, - ), - ), - ), - ), - ), - ), - Container( - width: 1, - height: 30, - color: Colors.grey[500], - ), - Expanded( - flex: 1, - child: InkWell( - onTap: () { - widget.onValueSelected(widget.selectedCriteria); - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Texts( - TranslationBase.of(context).ok, - fontWeight: FontWeight.w400, - )), - ), - ), - ), - ], - ) - ], - ) - ], - ); - } -} - - - - diff --git a/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart b/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart index b3fffa4b..5751dcfe 100644 --- a/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart +++ b/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart @@ -4,17 +4,17 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/EReferral/ import 'package:diplomaticquarterapp/core/viewModels/all_habib_medical_services/e_referral_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/E-Referral/referral_details.dart'; +import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/h20_setting.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/errors/app_embedded_error.dart'; -import 'package:diplomaticquarterapp/widgets/my_rich_text.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; +import 'package:diplomaticquarterapp/widgets/my_rich_text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -23,7 +23,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'dialogs/select_country_ingo_Dialog.dart'; -import 'dialogs/select_search_criteria_dialog.dart'; class SearchForReferralsPage extends StatefulWidget { SearchForReferralsPage({Key key}); @@ -79,74 +78,31 @@ class _SearchForReferralsPageState extends State { SizedBox( height: 10, ), - // InkWell( - // onTap: () => selectSearchCriteriaDialog(), - // 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(getSearchCriteriaName()), Icon(Icons.arrow_drop_down)], - // ), - // ), - // ), - 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: () => selectSearchCriteriaDialog(projectViewModel), - child: Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).selectSearchCriteria, - style: TextStyle( - fontSize: 11, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.44, - ), - ), - Text( - getSearchCriteriaName(projectViewModel), - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontWeight: FontWeight.w400, - color: Color(0xff2B353E), - letterSpacing: -0.44, - ), - ), - ], - ), - ), - Icon(Icons.arrow_drop_down), - ], + CommonDropDownView(TranslationBase.of(context).selectSearchCriteria, getSearchCriteriaName(projectViewModel), () { + List searchCriteria = [ + SearchCriteriaModel(name: "Identification Number", nameAr: "رقم الهوية", value: 1), + SearchCriteriaModel(name: "Referral Number", nameAr: "رقم الإحالة", value: 2), + ]; + List list = []; + for (int i = 0; i < searchCriteria.length; i++) { + list.add(RadioSelectionDialogModel(projectViewModel.isArabic ? searchCriteria[i].nameAr : searchCriteria[i].name, searchCriteria[i].value)); + } + showDialog( + context: context, + child: RadioSelectionDialog( + listData: list, + selectedIndex: selectedCriteria.value, + onValueSelected: (index) { + selectedCriteria = searchCriteria[index - 1]; + setState(() {}); + }, ), - ), - ), - SizedBox( - height: 12, - ), - - inputWidget(selectedCriteria.value == 1 ? TranslationBase.of(context).enterIdentificationNumber : TranslationBase.of(context).referralNumber, "", _searchTextController, isInputTypeNum: true), - - SizedBox( - height: 12, - ), + ); + }).withBorderedContainer, + SizedBox(height: 12), + inputWidget(selectedCriteria.value == 1 ? TranslationBase.of(context).enterIdentificationNumber : TranslationBase.of(context).referralNumber, "", _searchTextController, + isInputTypeNum: true), + SizedBox(height: 12), PhoneNumberSelectorWidget(onNumberChange: (value) { setState(() { mobileNo = value; @@ -179,9 +135,7 @@ class _SearchForReferralsPageState extends State { // }, // code: _selectedCountry == null ? "11" : _selectedCountry["code"], // ), - SizedBox( - height: 12, - ), + SizedBox(height: 12), if ((model.state == ViewState.Idle && model.allReferral.length == 0)) Center(child: Text(TranslationBase.of(context).noSearchResult)), if ((model.state == ViewState.ErrorLocal)) AppEmbeddedError(error: model.error), model.allReferral.length > 0 @@ -293,92 +247,65 @@ class _SearchForReferralsPageState extends State { return "Country"; } - void selectSearchCriteriaDialog(ProjectViewModel projectViewModel) { - showDialog( - context: context, - child: SelectSearchCriteriaDialog( - selectedCriteria: selectedCriteria, - projectViewModel: projectViewModel, - onValueSelected: (value) { - setState(() { - selectedCriteria = value; - }); - }, - ), - ); - } - 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, - ), + return 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, ), - TextField( - enabled: isEnable, - scrollPadding: EdgeInsets.zero, - keyboardType: isInputTypeNum ? TextInputType.number : TextInputType.text, - controller: _controller, - maxLines: lines, - onChanged: (value) => {setState(() {})}, - style: TextStyle( + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: 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, + 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), - ], - ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], ), - ); + ).withBorderedContainer; } String getSearchCriteriaName(ProjectViewModel projectViewModel) { diff --git a/lib/pages/Blood/blood_donation.dart b/lib/pages/Blood/blood_donation.dart index be58b644..8fb12f33 100644 --- a/lib/pages/Blood/blood_donation.dart +++ b/lib/pages/Blood/blood_donation.dart @@ -227,17 +227,18 @@ class _BloodDonationPageState extends State { child: InkWell( onTap: () { showDialog( - context: context, - builder: (_) => AssetGiffyDialog( - title: Text( - "", - style: TextStyle(fontSize: 22.0, fontWeight: FontWeight.w600), - ), - image: Image.asset('assets/images/BloodChrt_EN.png'), - buttonCancelText: Text(TranslationBase.of(context).cancel), - buttonCancelColor: Colors.grey, - onlyCancelButton: true, - )); + context: context, + builder: (_) => AssetGiffyDialog( + title: Text( + "", + style: TextStyle(fontSize: 22.0, fontWeight: FontWeight.w600), + ), + image: Image.asset('assets/images/BloodChrt_EN.png'), + buttonCancelText: Text(TranslationBase.of(context).cancel), + buttonCancelColor: Colors.grey, + onlyCancelButton: true, + ), + ); }, child: Container(width: 250, height: 200, child: Image.asset('assets/images/BloodChrt_EN.png'), color: Colors.white), ), diff --git a/lib/pages/Blood/dialogs/SelectBloodDialog.dart b/lib/pages/Blood/dialogs/SelectBloodDialog.dart deleted file mode 100644 index 23e9e753..00000000 --- a/lib/pages/Blood/dialogs/SelectBloodDialog.dart +++ /dev/null @@ -1,328 +0,0 @@ -import 'package:diplomaticquarterapp/pages/Blood/blood_donation.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - - -class SelectBloodDialog extends StatefulWidget { - - final Blood bloodType; - final Function(Blood) onValueSelected; - - SelectBloodDialog({Key key, this.bloodType, this.onValueSelected}); - - - - @override - _SelectBloodDialogState createState() => _SelectBloodDialogState(this.bloodType); -} - -class _SelectBloodDialogState extends State { - _SelectBloodDialogState(this.bloodType); - Blood bloodType; - @override - Widget build(BuildContext context) { - return SimpleDialog( - children: [ - Container( - child: Column( - children: [ - Divider(), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - bloodType = Blood.Oplus; - }); - }, - child: ListTile( - title: Text("O+"), - leading: Radio( - value: Blood.Oplus, - groupValue: bloodType, - activeColor: Colors.red[800], - onChanged: (Blood value) { - setState(() { - bloodType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - bloodType = Blood.Ominus; - }); - }, - child: ListTile( - title: Text("O-"), - leading: Radio( - value: Blood.Ominus, - groupValue: bloodType, - activeColor: Colors.red[800], - onChanged: (Blood value) { - setState(() { - bloodType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - bloodType = Blood.ABminus; - }); - }, - child: ListTile( - title: Text("AB-"), - leading: Radio( - value: Blood.ABminus, - groupValue: bloodType, - activeColor: Colors.red[800], - onChanged: (Blood value) { - setState(() { - bloodType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - bloodType = Blood.ABplus; - }); - }, - child: ListTile( - title: Text("AB+"), - leading: Radio( - value: Blood.ABplus, - groupValue: bloodType, - activeColor: Colors.red[800], - onChanged: (Blood value) { - setState(() { - bloodType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - bloodType = Blood.Aplus; - }); - }, - child: ListTile( - title: Text("A+"), - leading: Radio( - value: Blood.Aplus, - groupValue: bloodType, - activeColor: Colors.red[800], - onChanged: (Blood value) { - setState(() { - bloodType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - bloodType = Blood.Aminus; - }); - }, - child: ListTile( - title: Text("A-"), - leading: Radio( - value: Blood.Aminus, - groupValue: bloodType, - activeColor: Colors.red[800], - onChanged: (Blood value) { - setState(() { - bloodType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - bloodType = Blood.Bplus; - }); - }, - child: ListTile( - title: Text("B+"), - leading: Radio( - value: Blood.Bplus, - groupValue: bloodType, - activeColor: Colors.red[800], - onChanged: (Blood value) { - setState(() { - bloodType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - bloodType = Blood.Bminus; - }); - }, - child: ListTile( - title: Text("B-"), - leading: Radio( - value: Blood.Bminus, - groupValue: bloodType, - activeColor: Colors.red[800], - onChanged: (Blood value) { - setState(() { - bloodType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - SizedBox( - height: 5.0, - ), - Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Center( - child: Texts( - TranslationBase.of(context).cancel.toUpperCase(), - color: Colors.red, - ), - ), - ), - ), - ), - ), - Container( - width: 1, - height: 30, - color: Colors.grey[500], - ), - Expanded( - flex: 1, - child: InkWell( - onTap: () { - widget.onValueSelected(bloodType); - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Texts( - TranslationBase.of(context).ok, - fontWeight: FontWeight.w400, - ), - ), - ), - ), - ), - ], - ) - ], - ), - ) - ], - ); - } -} diff --git a/lib/pages/DrawerPages/family/my-family.dart b/lib/pages/DrawerPages/family/my-family.dart index 18450954..1d2b470b 100644 --- a/lib/pages/DrawerPages/family/my-family.dart +++ b/lib/pages/DrawerPages/family/my-family.dart @@ -26,6 +26,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -666,14 +667,15 @@ class _MyFamily extends State with TickerProviderStateMixin { } deleteFamily(family, context) { - ConfirmDialog dialog = new ConfirmDialog( - context: context, - confirmMessage: TranslationBase.of(context).removeFamilyMember, - okText: TranslationBase.of(context).confirm, - cancelText: TranslationBase.of(context).cancel_nocaps, - okFunction: () => {ConfirmDialog.closeAlertDialog(context), removeFamily(family, context)}, - cancelFunction: () => {}); - dialog.showAlertDialog(context); + showDialog( + context: context, + child: ConfirmWithMessageDialog( + message: TranslationBase.of(context).removeFamilyMember, + onTap: () { + removeFamily(family, context); + }, + ), + ); } removeFamily(GetAllSharedRecordsByStatusList family, context) { diff --git a/lib/pages/medical/balance/advance_payment_page.dart b/lib/pages/medical/balance/advance_payment_page.dart index 338aff23..6ade52bd 100644 --- a/lib/pages/medical/balance/advance_payment_page.dart +++ b/lib/pages/medical/balance/advance_payment_page.dart @@ -8,7 +8,6 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/medical/balance/dialogs/SelectHospitalDialog.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -16,7 +15,7 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; @@ -24,9 +23,6 @@ import 'package:flutter/material.dart'; import '../../../core/model/my_balance/AdvanceModel.dart'; import 'confirm_payment_page.dart'; -import 'dialogs/SelectBeneficiaryDialog.dart'; -import 'dialogs/SelectPatientFamilyDialog.dart'; -import 'dialogs/SelectPatientInfoDialog.dart'; import 'new_text_Field.dart'; enum BeneficiaryType { MyAccount, MyFamilyFiles, OtherAccount, NON } @@ -87,16 +83,48 @@ class _AdvancePaymentPageState extends State { Text( TranslationBase.of(context).advancePaymentLabel, style: TextStyle( - fontSize: 14, + fontSize: 16, fontWeight: FontWeight.w600, - letterSpacing: -0.46, + letterSpacing: -0.64, ), ), - SizedBox( - height: 12, - ), + SizedBox(height: 12), InkWell( - onTap: () => confirmSelectBeneficiaryDialog(model), + onTap: () { + List list = [ + RadioSelectionDialogModel(TranslationBase.of(context).myAccount, 0), + RadioSelectionDialogModel(TranslationBase.of(context).myFamilyFiles, 1), + RadioSelectionDialogModel(TranslationBase.of(context).otherAccount, 2), + ]; + showDialog( + context: context, + child: RadioSelectionDialog( + listData: list, + selectedIndex: + beneficiaryType == BeneficiaryType.MyAccount ? 0 : (beneficiaryType == BeneficiaryType.MyFamilyFiles ? 1 : (beneficiaryType == BeneficiaryType.OtherAccount ? 2 : -1)), + onValueSelected: (index) { + var type; + if (index == 0) { + type = BeneficiaryType.MyAccount; + } else if (index == 1) { + type = BeneficiaryType.MyFamilyFiles; + } else { + type = BeneficiaryType.OtherAccount; + } + + setState(() { + if (type == BeneficiaryType.MyAccount) { + _fileTextController.text = model.user.patientID.toString(); + advanceModel.depositorName = model.user.firstName + " " + model.user.lastName; + } else + _fileTextController.text = ""; + + beneficiaryType = type; + }); + }, + ), + ); + }, child: Container( padding: EdgeInsets.all(8), width: double.infinity, @@ -118,10 +146,7 @@ class _AdvancePaymentPageState extends State { ), ), ), - if (beneficiaryType == BeneficiaryType.MyFamilyFiles) - SizedBox( - height: 12, - ), + if (beneficiaryType == BeneficiaryType.MyFamilyFiles) SizedBox(height: 12), if (beneficiaryType == BeneficiaryType.MyFamilyFiles) InkWell( onTap: () { @@ -152,18 +177,13 @@ class _AdvancePaymentPageState extends State { ), ), ), - SizedBox( - height: 12, - ), + SizedBox(height: 12), NewTextFields( hintText: TranslationBase.of(context).fileNumber, controller: _fileTextController, readOnly: beneficiaryType == BeneficiaryType.OtherAccount ? false : true, ), - if (beneficiaryType == BeneficiaryType.OtherAccount) - SizedBox( - height: 12, - ), + if (beneficiaryType == BeneficiaryType.OtherAccount) SizedBox(height: 12), if (beneficiaryType == BeneficiaryType.OtherAccount) InkWell( onTap: () { @@ -197,9 +217,7 @@ class _AdvancePaymentPageState extends State { ), ), ), - SizedBox( - height: 12, - ), + SizedBox(height: 12), InkWell( onTap: () => confirmSelectHospitalDialog(model.hospitals), child: Container( @@ -223,9 +241,7 @@ class _AdvancePaymentPageState extends State { ), ), ), - SizedBox( - height: 12, - ), + SizedBox(height: 12), NewTextFields( hintText: TranslationBase.of(context).amount, keyboardType: TextInputType.numberWithOptions(signed: false, decimal: true), @@ -235,9 +251,7 @@ class _AdvancePaymentPageState extends State { }); }, ), - SizedBox( - height: 12, - ), + SizedBox(height: 12), if (model.user != null) NewTextFields( hintText: TranslationBase.of(context).depositorEmail, @@ -246,9 +260,7 @@ class _AdvancePaymentPageState extends State { email = value; }, ), - SizedBox( - height: 12, - ), + SizedBox(height: 12), NewTextFields( hintText: TranslationBase.of(context).notes, controller: _notesTextController, @@ -334,73 +346,70 @@ class _AdvancePaymentPageState extends State { ); } - void confirmSelectBeneficiaryDialog(MyBalanceViewModel model) { - showDialog( - context: context, - child: SelectBeneficiaryDialog( - beneficiaryType: beneficiaryType, - onValueSelected: (value) { - setState(() { - if (value == BeneficiaryType.MyAccount) { - _fileTextController.text = model.user.patientID.toString(); - advanceModel.depositorName = model.user.firstName + " " + model.user.lastName; - } else - _fileTextController.text = ""; - - beneficiaryType = value; - }); - }, - ), - ); - } + int _selectedHospitalIndex = -1; void confirmSelectHospitalDialog(List hospitals) { + List list = [ + for (int i = 0; i < hospitals.length; i++) RadioSelectionDialogModel(hospitals[i].name + ' ${hospitals[i].distanceInKilometers} ' + TranslationBase.of(context).km, i), + ]; showDialog( context: context, - child: SelectHospitalDialog( - hospitals: hospitals, - selectedHospital: _selectedHospital, - onValueSelected: (value) { - setState(() { - _selectedHospital = value; - }); + child: RadioSelectionDialog( + listData: list, + selectedIndex: _selectedHospitalIndex, + isScrollable: true, + onValueSelected: (index) { + _selectedHospitalIndex = index; + _selectedHospital = hospitals[index]; + setState(() {}); }, ), ); } + int _selectedPatientIndex = -1; + void confirmSelectPatientDialog(List patientInfoList) { + List list = [ + for (int i = 0; i < patientInfoList.length; i++) RadioSelectionDialogModel(patientInfoList[i].fullName, i), + ]; showDialog( context: context, - child: SelectPatientInfoDialog( - patientInfoList: patientInfoList, - selectedPatientInfo: _selectedPatientInfo, - onValueSelected: (value) { - setState(() { - advanceModel.depositorName = value.fullName; - _selectedPatientInfo = value; - }); + child: RadioSelectionDialog( + listData: list, + isScrollable: true, + selectedIndex: _selectedPatientIndex, + onValueSelected: (index) { + _selectedPatientIndex = index; + _selectedPatientInfo = patientInfoList[index]; + advanceModel.depositorName = _selectedPatientInfo.fullName; + setState(() {}); }, ), ); } + int _selectedFamilyMemberIndex = -1; + void confirmSelectFamilyDialog(List getAllSharedRecordsByStatusList) { - if (getAllSharedRecordsByStatusList.isNotEmpty) + if (getAllSharedRecordsByStatusList.isNotEmpty) { + List list = [ + for (int i = 0; i < getAllSharedRecordsByStatusList.length; i++) RadioSelectionDialogModel(getAllSharedRecordsByStatusList[i].patientName, i), + ]; showDialog( context: context, - child: SelectPatientFamilyDialog( - getAllSharedRecordsByStatusList: getAllSharedRecordsByStatusList, - selectedPatientFamily: selectedPatientFamily, - onValueSelected: (value) { - setState(() { - selectedPatientFamily = value; - _fileTextController.text = selectedPatientFamily.responseID.toString(); - advanceModel.depositorName = value.patientName; - }); + child: RadioSelectionDialog( + listData: list, + isScrollable: true, + selectedIndex: _selectedFamilyMemberIndex, + onValueSelected: (index) { + _selectedFamilyMemberIndex = index; + selectedPatientFamily = getAllSharedRecordsByStatusList[index]; + setState(() {}); }, ), ); + } } String getBeneficiaryType() { diff --git a/lib/pages/medical/balance/dialogs/SelectBeneficiaryDialog.dart b/lib/pages/medical/balance/dialogs/SelectBeneficiaryDialog.dart deleted file mode 100644 index 526ffaf6..00000000 --- a/lib/pages/medical/balance/dialogs/SelectBeneficiaryDialog.dart +++ /dev/null @@ -1,204 +0,0 @@ -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import '../../../../Constants.dart'; -import '../advance_payment_page.dart'; - -class SelectBeneficiaryDialog extends StatefulWidget { - final BeneficiaryType beneficiaryType; - final Function(BeneficiaryType) onValueSelected; - - SelectBeneficiaryDialog({Key key, this.beneficiaryType, this.onValueSelected}); - - @override - _SelectBeneficiaryDialogState createState() => _SelectBeneficiaryDialogState(this.beneficiaryType); -} - -class _SelectBeneficiaryDialogState extends State { - _SelectBeneficiaryDialogState(this.beneficiaryType); - - BeneficiaryType beneficiaryType; - - @override - Widget build(BuildContext context) { - return SimpleDialog( - children: [ - Container( - child: Column( - children: [ - Divider(), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - beneficiaryType = BeneficiaryType.MyAccount; - }); - }, - child: ListTile( - title: Text( - TranslationBase.of(context).myAccount, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - leading: Radio( - value: BeneficiaryType.MyAccount, - groupValue: beneficiaryType, - activeColor: secondaryColor, - onChanged: (BeneficiaryType value) { - setState(() { - beneficiaryType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - beneficiaryType = BeneficiaryType.MyFamilyFiles; - }); - }, - child: ListTile( - title: Text( - TranslationBase.of(context).myFamilyFiles, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - leading: Radio( - value: BeneficiaryType.MyFamilyFiles, - groupValue: beneficiaryType, - activeColor: Color(0xffC5272D), - onChanged: (BeneficiaryType value) { - setState(() { - beneficiaryType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - beneficiaryType = BeneficiaryType.OtherAccount; - }); - }, - child: ListTile( - title: Text( - TranslationBase.of(context).otherAccount, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - leading: Radio( - value: BeneficiaryType.OtherAccount, - groupValue: beneficiaryType, - activeColor: Color(0xffC5272D), - onChanged: (BeneficiaryType value) { - setState(() { - beneficiaryType = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Center( - child: Text( - TranslationBase.of(context).cancel.toUpperCase(), - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - color: Color(0xffC5272D), - ), - ), - ), - ), - ), - ), - ), - Container( - width: 1, - height: 30, - color: Colors.grey[500], - ), - Expanded( - flex: 1, - child: InkWell( - onTap: () { - widget.onValueSelected(beneficiaryType); - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Text( - TranslationBase.of(context).ok.toUpperCase(), - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - ), - ), - ), - ), - ], - ) - ], - ), - ) - ], - ); - } -} diff --git a/lib/pages/medical/balance/dialogs/SelectCiteisDialog.dart b/lib/pages/medical/balance/dialogs/SelectCiteisDialog.dart index 19e4fea4..d0f991ac 100644 --- a/lib/pages/medical/balance/dialogs/SelectCiteisDialog.dart +++ b/lib/pages/medical/balance/dialogs/SelectCiteisDialog.dart @@ -7,6 +7,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +// todo 'sikander' remove this file when usage known class SelectCiteisDialog extends StatefulWidget { final List hospitals; final Function(CitiesModel) onValueSelected; diff --git a/lib/pages/medical/balance/dialogs/SelectHospitalDialog.dart b/lib/pages/medical/balance/dialogs/SelectHospitalDialog.dart deleted file mode 100644 index fd47ea1b..00000000 --- a/lib/pages/medical/balance/dialogs/SelectHospitalDialog.dart +++ /dev/null @@ -1,145 +0,0 @@ -import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import '../../../../Constants.dart'; - -class SelectHospitalDialog extends StatefulWidget { - final List hospitals; - final Function(HospitalsModel) onValueSelected; - HospitalsModel selectedHospital; - - SelectHospitalDialog({Key key, this.hospitals, this.onValueSelected, this.selectedHospital}); - - @override - _SelectHospitalDialogState createState() => _SelectHospitalDialogState(); -} - -class _SelectHospitalDialogState extends State { - @override - void initState() { - super.initState(); - widget.selectedHospital = widget.selectedHospital ?? widget.hospitals[0]; - } - - @override - Widget build(BuildContext context) { - return SimpleDialog( - children: [ - Column( - children: [ - Divider(), - ...List.generate( - widget.hospitals.length, - (index) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 2, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - widget.selectedHospital = widget.hospitals[index]; - }); - }, - child: ListTile( - title: Text( - widget.hospitals[index].name + ' ${widget.hospitals[index].distanceInKilometers} ' + TranslationBase.of(context).km, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - leading: Radio( - value: widget.hospitals[index], - groupValue: widget.selectedHospital, - activeColor: secondaryColor, - onChanged: (value) { - setState(() { - widget.selectedHospital = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - ], - ), - ), - SizedBox( - height: 5.0, - ), - Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Center( - child: Text( - TranslationBase.of(context).cancel.toUpperCase(), - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - color: Colors.red - ), - ), - ), - ), - ), - ), - ), - Container( - width: 1, - height: 30, - color: Colors.grey[500], - ), - Expanded( - flex: 1, - child: InkWell( - onTap: () { - widget.onValueSelected(widget.selectedHospital); - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Text( - TranslationBase.of(context).ok, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - ), - ), - ), - ), - ], - ) - ], - ) - ], - ); - } -} diff --git a/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart b/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart deleted file mode 100644 index d4b2e8fb..00000000 --- a/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart +++ /dev/null @@ -1,152 +0,0 @@ -import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import '../../../../Constants.dart'; - -class SelectPatientFamilyDialog extends StatefulWidget { - final List getAllSharedRecordsByStatusList; - final Function(GetAllSharedRecordsByStatusList) onValueSelected; - GetAllSharedRecordsByStatusList selectedPatientFamily; - - List getAllSharedRecordsByStatusApprovedList = new List(); - - SelectPatientFamilyDialog({Key key, this.getAllSharedRecordsByStatusList, this.onValueSelected, this.selectedPatientFamily}); - - @override - _SelectPatientFamilyDialogState createState() => _SelectPatientFamilyDialogState(); -} - -class _SelectPatientFamilyDialogState extends State { - @override - void initState() { - super.initState(); - widget.selectedPatientFamily = widget.selectedPatientFamily ?? widget.getAllSharedRecordsByStatusList[0]; - - if (widget.getAllSharedRecordsByStatusList.isNotEmpty) - widget.getAllSharedRecordsByStatusList.forEach((element) { - if (element.status == 3) widget.getAllSharedRecordsByStatusApprovedList.add(element); - }); - } - - @override - Widget build(BuildContext context) { - return SimpleDialog( - children: [ - Column( - children: [ - Divider(), - ...List.generate( - widget.getAllSharedRecordsByStatusApprovedList.length, - (index) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 2, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - widget.selectedPatientFamily = widget.getAllSharedRecordsByStatusApprovedList[index]; - }); - }, - child: ListTile( - title: Text( - widget.getAllSharedRecordsByStatusApprovedList[index].patientName, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - leading: Radio( - value: widget.getAllSharedRecordsByStatusApprovedList[index], - groupValue: widget.selectedPatientFamily, - activeColor: secondaryColor, - onChanged: (value) { - setState(() { - widget.selectedPatientFamily = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - ], - ), - ), - SizedBox( - height: 5.0, - ), - Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Center( - child: Text( - TranslationBase.of(context).cancel.toUpperCase(), - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - color: Colors.red, - ), - ), - ), - ), - ), - ), - ), - Container( - width: 1, - height: 30, - color: Colors.grey[500], - ), - Expanded( - flex: 1, - child: InkWell( - onTap: () { - widget.onValueSelected(widget.selectedPatientFamily); - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Text( - TranslationBase.of(context).ok, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - ), - ), - ), - ), - ], - ) - ], - ) - ], - ); - } -} diff --git a/lib/pages/medical/balance/dialogs/SelectPatientInfoDialog.dart b/lib/pages/medical/balance/dialogs/SelectPatientInfoDialog.dart deleted file mode 100644 index 759a6874..00000000 --- a/lib/pages/medical/balance/dialogs/SelectPatientInfoDialog.dart +++ /dev/null @@ -1,146 +0,0 @@ -import 'package:diplomaticquarterapp/core/model/my_balance/patient_info.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import '../../../../Constants.dart'; - -class SelectPatientInfoDialog extends StatefulWidget { - final List patientInfoList; - - final Function(PatientInfo) onValueSelected; - PatientInfo selectedPatientInfo; - - SelectPatientInfoDialog({Key key, this.patientInfoList, this.onValueSelected, this.selectedPatientInfo}); - - @override - _SelectPatientInfoDialogState createState() => _SelectPatientInfoDialogState(); -} - -class _SelectPatientInfoDialogState extends State { - @override - void initState() { - super.initState(); - widget.selectedPatientInfo = widget.selectedPatientInfo ?? widget.patientInfoList[0]; - } - - @override - Widget build(BuildContext context) { - return SimpleDialog( - children: [ - Column( - children: [ - Divider(), - ...List.generate( - widget.patientInfoList.length, - (index) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 2, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - widget.selectedPatientInfo = widget.patientInfoList[index]; - }); - }, - child: ListTile( - title: Text( - widget.patientInfoList[index].fullName, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - leading: Radio( - value: widget.patientInfoList[index], - groupValue: widget.selectedPatientInfo, - activeColor: secondaryColor, - onChanged: (value) { - setState(() { - widget.selectedPatientInfo = value; - }); - }, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - ], - ), - ), - SizedBox( - height: 5.0, - ), - Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Center( - child: Text( - TranslationBase.of(context).cancel.toUpperCase(), - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - color: Colors.red, - ), - ), - ), - ), - ), - ), - ), - Container( - width: 1, - height: 30, - color: Colors.grey[500], - ), - Expanded( - flex: 1, - child: InkWell( - onTap: () { - widget.onValueSelected(widget.selectedPatientInfo); - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Text( - TranslationBase.of(context).ok.toUpperCase(), - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - ), - ), - ), - ), - ], - ) - ], - ) - ], - ); - } -} diff --git a/lib/pages/medical/balance/my_balance_page.dart b/lib/pages/medical/balance/my_balance_page.dart index 8c98ebc8..640b18f9 100644 --- a/lib/pages/medical/balance/my_balance_page.dart +++ b/lib/pages/medical/balance/my_balance_page.dart @@ -1,14 +1,16 @@ import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; +import 'package:diplomaticquarterapp/core/model/my_balance/patient_advance_balance_amount.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/my_balance_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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:flutter/widgets.dart'; +import 'package:flutter_svg/svg.dart'; import 'advance_payment_page.dart'; @@ -24,118 +26,156 @@ class MyBalancePage extends StatelessWidget { builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, - appBarTitle: TranslationBase.of(context).myBalances, + appBarTitle: TranslationBase.of(context).myWallet, imagesInfo: imagesInfo, description: TranslationBase.of(context).infoMyBalance, showNewAppBar: true, showNewAppBarTitle: true, backgroundColor: CustomColors.appBackgroudGreyColor, - body: SingleChildScrollView( - child: Container( - margin: EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).balanceAmount, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - ), - ), - SizedBox( - height: 15, - ), - Container( - padding: EdgeInsets.all(8), - width: double.infinity, - height: 65, - decoration: BoxDecoration( - color: Colors.red[700], - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(7), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${model.totalAdvanceBalanceAmount ?? 0} ' + TranslationBase.of(context).sar, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, - color: Colors.white, - ), - ), - Text( - TranslationBase.of(context).totalBalance, - style: TextStyle( - fontSize: 14, - letterSpacing: -0.46, - color: Colors.white, + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + padding: EdgeInsets.all(21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.fromLTRB(14, 12, 10, 12), + decoration: BoxDecoration( + color: Color(0xff2B353E), + borderRadius: BorderRadius.all( + Radius.circular(10.0), ), ), - ], - ), - ), - SizedBox( - height: 9, - ), - ...List.generate( - model.patientAdvanceBalanceAmountList.length, - (index) => Container( - padding: EdgeInsets.all(8), - height: 65, - margin: EdgeInsets.only(top: 8), - decoration: BoxDecoration( - color: Colors.white, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(12), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${model.patientAdvanceBalanceAmountList[index].patientAdvanceBalanceAmount} ' + TranslationBase.of(context).sar, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.46, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + SvgPicture.asset( + "assets/images/new/services/balance_credit.svg", + height: 40, + width: 40, + color: Colors.white, + ), + SizedBox(height: 6), + Text( + TranslationBase.of(context).totalBalance, + style: TextStyle( + fontSize: 16, + letterSpacing: -0.96, + fontWeight: FontWeight.bold, + color: Colors.white, + //height: 16/22 + ), + ), + ], + ), ), - ), - Text( - model.patientAdvanceBalanceAmountList[index].projectDescription, - style: TextStyle( - fontSize: 14, - letterSpacing: -0.46, + Container( + padding: EdgeInsets.fromLTRB(14, 10, 12, 10), + decoration: BoxDecoration( + color: Color(0xff3f4850), + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + double.parse(model.totalAdvanceBalanceAmount?.toString() ?? "0").toStringAsFixed(2), + style: TextStyle( + fontSize: 28, + fontWeight: FontWeight.bold, + letterSpacing: -3.2, + height: 40 / 35, + color: Colors.white, + ), + ), + Text( + TranslationBase.of(context).sar, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + letterSpacing: -0.96, + color: Colors.white, + ), + ), + ], + ), ), - ), - ], + ], + ), ), - ), + SizedBox(height: 12), + ListView.separated( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (cxt, index) { + PatientAdvanceBalanceAmount balanceAmount = model.patientAdvanceBalanceAmountList[index]; + double amount = double.parse(balanceAmount.patientAdvanceBalanceAmount?.toString() ?? "0"); + return Container( + padding: EdgeInsets.fromLTRB(14, 18, 14, 18), + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + boxShadow: [ + BoxShadow( + color: Color(0xff000000).withOpacity(.05), + //spreadRadius: 5, + blurRadius: 27, + offset: Offset(0, -3), + ), + ], + color: Colors.white), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text( + balanceAmount.projectDescription, + style: TextStyle( + fontSize: 16, + letterSpacing: -0.64, + fontWeight: amount > 0 ? FontWeight.bold : FontWeight.w500, + color: Color(0xff2E303A), + ), + ), + ), + Text( + amount.toStringAsFixed(2) + " " + TranslationBase.of(context).sar, + style: TextStyle( + fontSize: 16, + letterSpacing: -0.64, + fontWeight: amount > 0 ? FontWeight.bold : FontWeight.w500, + color: Color(0xff2E303A), + ), + ), + ], + ), + ); + }, + separatorBuilder: (cxt, index) => SizedBox(height: 12), + itemCount: model.patientAdvanceBalanceAmountList.length), + ], ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.13, - ) - ], + ), ), - ), - ), - bottomSheet: Container( - // height: MediaQuery.of(context).size.height * 0.12, - height: 70.0, - color: Colors.white, - width: double.infinity, - padding: EdgeInsets.all(12), - child: DefaultButton( - // textColor: Colors.white, - // color: CustomColors.accentColor, - TranslationBase.of(context).createAdvancedPayment, - () { - Navigator.push(context, FadePage(page: AdvancePaymentPage())); - }, - ), + DefaultButton( + TranslationBase.of(context).createAdvancedPayment, + () { + Navigator.push(context, FadePage(page: AdvancePaymentPage())); + }, + ).insideContainer, + ], ), ), ); diff --git a/lib/pages/medical/my_trackers/Weight/AddWeightPage.dart b/lib/pages/medical/my_trackers/Weight/AddWeightPage.dart index 9eb3e1a5..5ef8c69c 100644 --- a/lib/pages/medical/my_trackers/Weight/AddWeightPage.dart +++ b/lib/pages/medical/my_trackers/Weight/AddWeightPage.dart @@ -9,7 +9,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart'; -import 'package:diplomaticquarterapp/widgets/dialogs/RadioStringDialog.dart'; + import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -280,24 +280,6 @@ class _AddWeightPageState extends State { return " ${timeWeightDate.hour}:${timeWeightDate.minute}"; } - void confirmSelectMeasureTimeDialog(List list) { - showDialog( - context: context, - child: RadioStringDialog( - radioList: list, - title: TranslationBase.of(context).measureUnit, - selectedValue: measureTimeSelectedType, - onValueSelected: (value) { - setState(() { - measureTimeSelectedType = value; - weightUnit = list.indexOf(value); - validateForm(); - }); - }, - ), - ); - } - void validateForm() { if (_weightValueController.text.length > 0 && measureTimeSelectedType != null) { setState(() { diff --git a/lib/pages/medical/my_trackers/blood_pressure/AddBloodPressurePage.dart b/lib/pages/medical/my_trackers/blood_pressure/AddBloodPressurePage.dart index 77bb45b7..a4c0b943 100644 --- a/lib/pages/medical/my_trackers/blood_pressure/AddBloodPressurePage.dart +++ b/lib/pages/medical/my_trackers/blood_pressure/AddBloodPressurePage.dart @@ -6,10 +6,8 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:diplomaticquarterapp/widgets/dialogs/RadioStringDialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -119,9 +117,6 @@ class _AddBloodPressurePageState extends State { }, ), ); - return; - - confirmSelectMeasureTimeDialog(projectViewModel.isArabic ? measureTimeArList : measureTimeEnList); }, child: Container( padding: EdgeInsets.all(12), @@ -277,24 +272,6 @@ class _AddBloodPressurePageState extends State { return " ${timeSugarDate.hour}:${timeSugarDate.minute}"; } - void confirmSelectMeasureTimeDialog(List list) { - showDialog( - context: context, - child: RadioStringDialog( - radioList: list, - title: TranslationBase.of(context).selectArm, - selectedValue: measureTimeSelectedType, - onValueSelected: (value) { - setState(() { - measureTimeSelectedType = value; - measuredArm = list.indexOf(value); - validateForm(); - }); - }, - ), - ); - } - void validateForm() { print("_bloodSystolicValueController " + _bloodSystolicValueController.text.length.toString()); if (_bloodSystolicValueController.text.length > 0 && _bloodDiastolicValueController.text.length > 0) { diff --git a/lib/pages/medical/my_trackers/blood_suger/AddBloodSugarPage.dart b/lib/pages/medical/my_trackers/blood_suger/AddBloodSugarPage.dart index 82375322..8e47e4e8 100644 --- a/lib/pages/medical/my_trackers/blood_suger/AddBloodSugarPage.dart +++ b/lib/pages/medical/my_trackers/blood_suger/AddBloodSugarPage.dart @@ -8,8 +8,8 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:diplomaticquarterapp/widgets/dialogs/RadioStringDialog.dart'; -import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -41,6 +41,8 @@ class _AddBloodSugarPageState extends State { String measureUnitSelectedType = 'mg/dlt'; int measuredTime = 1; bool isButtonDisabled = true; + + int _selectedMeasureUnitIndex = 0; final List measureUnitList = ['mg/dlt', 'mol/L']; final List measureTimeEnList = [ 'Before Breakfast', @@ -66,6 +68,7 @@ class _AddBloodSugarPageState extends State { "صائم", "آخر", ]; + int _selectedMeasureTimeIndex; String measureTimeSelectedType; @override @@ -88,212 +91,198 @@ class _AddBloodSugarPageState extends State { Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return AppScaffold( - isShowAppBar: true, - showNewAppBar: true, - showNewAppBarTitle: true, - appBarTitle: widget.isUpdate ? TranslationBase.of(context).update : TranslationBase.of(context).add, - body: SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: Container( - margin: EdgeInsets.all(15), - child: Column( - children: [ - SizedBox( - height: 15, - ), - NewTextFields( - hintText: TranslationBase.of(context).sugarAdd, - controller: _bloodSugarValueController, - keyboardType: TextInputType.number, - onChanged: (value) => validateForm(), - fontWeight: FontWeight.normal, - fontSize: 14, - ), - SizedBox( - height: 8, - ), - InkWell( - onTap: () { - confirmSelectMeasureUnitDialog(); - }, - 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(measureUnitSelectedType), - Icon( - Icons.arrow_drop_down, - color: Colors.grey, - ) - ], + isShowAppBar: true, + showNewAppBar: true, + showNewAppBarTitle: true, + appBarTitle: widget.isUpdate ? TranslationBase.of(context).update : TranslationBase.of(context).add, + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + padding: EdgeInsets.all(21), + child: Column( + children: [ + NewTextFields( + hintText: TranslationBase.of(context).sugarAdd, + controller: _bloodSugarValueController, + keyboardType: TextInputType.number, + onChanged: (value) => validateForm(), + fontWeight: FontWeight.normal, + fontSize: 14, + ), + SizedBox(height: 12), + InkWell( + onTap: () { + confirmSelectMeasureUnitDialog(); + }, + 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(measureUnitSelectedType), + Icon( + Icons.arrow_drop_down, + color: Colors.grey, + ) + ], + ), ), ), - ), - SizedBox( - height: 8, - ), - InkWell( - onTap: () { - DatePicker.showDatePicker(context, showTitleActions: true, minTime: DateTime(DateTime.now().year - 1, 1, 1), maxTime: DateTime.now(), onConfirm: (date) { - setState(() { - bloodSugarDate = date; - }); - }, currentTime: bloodSugarDate, 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(TranslationBase.of(context).date), - Texts(getDate()), - ], + SizedBox(height: 12), + InkWell( + onTap: () { + DatePicker.showDatePicker(context, showTitleActions: true, minTime: DateTime(DateTime.now().year - 1, 1, 1), maxTime: DateTime.now(), onConfirm: (date) { + setState(() { + bloodSugarDate = date; + }); + }, currentTime: bloodSugarDate, 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(TranslationBase.of(context).date), + Texts(getDate()), + ], + ), ), ), - ), - SizedBox( - height: 8, - ), - InkWell( - onTap: () { - DatePicker.showTimePicker(context, showTitleActions: true, onConfirm: (date) { - setState(() { - timeSugarDate = date; - }); - }, currentTime: timeSugarDate, 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(TranslationBase.of(context).time), Texts(getTime())], + SizedBox(height: 12), + InkWell( + onTap: () { + DatePicker.showTimePicker(context, showTitleActions: true, onConfirm: (date) { + setState(() { + timeSugarDate = date; + }); + }, currentTime: timeSugarDate, 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(TranslationBase.of(context).time), Texts(getTime())], + ), ), ), - ), - SizedBox( - height: 8, - ), - InkWell( - onTap: () { - confirmSelectMeasureTimeDialog(projectViewModel.isArabic ? measureTimeArList : measureTimeEnList); - }, - 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(measureTimeSelectedType ?? TranslationBase.of(context).other), - Icon( - Icons.arrow_drop_down, - color: Colors.grey, - ) - ], + SizedBox(height: 12), + InkWell( + onTap: () { + confirmSelectMeasureTimeDialog(projectViewModel.isArabic ? measureTimeArList : measureTimeEnList); + }, + 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(measureTimeSelectedType ?? TranslationBase.of(context).other), + Icon( + Icons.arrow_drop_down, + color: Colors.grey, + ) + ], + ), ), ), - ), - widget.isUpdate - ? Container( - padding: EdgeInsets.all(10), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - InkWell( - child: Texts( - TranslationBase.of(context).delete, - decoration: TextDecoration.underline, - fontWeight: FontWeight.bold, - color: Colors.red[900], - ), - onTap: () { - ConfirmDialog dialog = new ConfirmDialog( + widget.isUpdate + ? Container( + padding: EdgeInsets.all(10), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + child: Texts( + TranslationBase.of(context).delete, + decoration: TextDecoration.underline, + fontWeight: FontWeight.bold, + color: Colors.red[900], + ), + onTap: () { + showDialog( context: context, - confirmMessage: TranslationBase.of(context).removeMeasure, - okText: TranslationBase.of(context).ok, - cancelText: TranslationBase.of(context).cancel, - okFunction: () async { - ConfirmDialog.closeAlertDialog(context); - - GifLoaderDialogUtils.showMyDialog(context); - widget.bloodSugarViewMode.deactivateDiabeticStatus(lineItemNo: widget.lineItemNo).then((value) { - GifLoaderDialogUtils.hideDialog(context); - if (widget.bloodSugarViewMode.state == ViewState.ErrorLocal) + child: ConfirmWithMessageDialog( + message: TranslationBase.of(context).removeMeasure, + onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + widget.bloodSugarViewMode.deactivateDiabeticStatus(lineItemNo: widget.lineItemNo).then((value) { + GifLoaderDialogUtils.hideDialog(context); + if (widget.bloodSugarViewMode.state == ViewState.ErrorLocal) + AppToast.showErrorToast(message: widget.bloodSugarViewMode.error); + else + Navigator.pop(context); + }).catchError((e) { + GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: widget.bloodSugarViewMode.error); - else - Navigator.pop(context); - }).catchError((e) { - GifLoaderDialogUtils.hideDialog(context); - AppToast.showErrorToast(message: widget.bloodSugarViewMode.error); - }); - }, - cancelFunction: () => {}); - dialog.showAlertDialog(context); - }, - ) - ], - )) - : Container() - ], + }); + }, + ), + ); + }, + ) + ], + ), + ) + : Container() + ], + ), ), ), - ), - bottomSheet: Container( - color: Theme.of(context).scaffoldBackgroundColor, - child: Padding( - padding: const EdgeInsets.all(20.0), - child: DefaultButton( - TranslationBase.of(context).save.toUpperCase(), - isButtonDisabled - ? null - : () async { - if (_bloodSugarValueController.text.isNotEmpty) { - GifLoaderDialogUtils.showMyDialog(context); - if (widget.isUpdate) { - await widget.bloodSugarViewMode.updateDiabtecResult( - month: bloodSugarDate, - hour: timeSugarDate, - diabtecUnit: measureUnitSelectedType, - measuredTime: measuredTime, - lineItemNo: widget.lineItemNo, - bloodSugerResult: _bloodSugarValueController.text.toString()); - - GifLoaderDialogUtils.hideDialog(context); - if (widget.bloodSugarViewMode.state == ViewState.ErrorLocal) - AppToast.showErrorToast(message: widget.bloodSugarViewMode.error); - else - Navigator.pop(context); - } else { - await widget.bloodSugarViewMode.addDiabtecResult( + DefaultButton( + TranslationBase.of(context).save, + isButtonDisabled + ? null + : () async { + if (_bloodSugarValueController.text.isNotEmpty) { + GifLoaderDialogUtils.showMyDialog(context); + if (widget.isUpdate) { + await widget.bloodSugarViewMode.updateDiabtecResult( + month: bloodSugarDate, + hour: timeSugarDate, diabtecUnit: measureUnitSelectedType, measuredTime: measuredTime, - bloodSugerResult: _bloodSugarValueController.text.toString(), - bloodSugerDateChart: '${bloodSugarDate.year}-${bloodSugarDate.month}-${bloodSugarDate.day} ${timeSugarDate.hour}:${timeSugarDate.minute}:00', - ); + lineItemNo: widget.lineItemNo, + bloodSugerResult: _bloodSugarValueController.text.toString()); - GifLoaderDialogUtils.hideDialog(context); - if (widget.bloodSugarViewMode.state == ViewState.Error) - AppToast.showErrorToast(message: widget.bloodSugarViewMode.error); - else - Navigator.pop(context); - } + GifLoaderDialogUtils.hideDialog(context); + if (widget.bloodSugarViewMode.state == ViewState.ErrorLocal) + AppToast.showErrorToast(message: widget.bloodSugarViewMode.error); + else + Navigator.pop(context); + } else { + await widget.bloodSugarViewMode.addDiabtecResult( + diabtecUnit: measureUnitSelectedType, + measuredTime: measuredTime, + bloodSugerResult: _bloodSugarValueController.text.toString(), + bloodSugerDateChart: '${bloodSugarDate.year}-${bloodSugarDate.month}-${bloodSugarDate.day} ${timeSugarDate.hour}:${timeSugarDate.minute}:00', + ); + + GifLoaderDialogUtils.hideDialog(context); + if (widget.bloodSugarViewMode.state == ViewState.Error) + AppToast.showErrorToast(message: widget.bloodSugarViewMode.error); + else + Navigator.pop(context); } - }, - disabledColor: Colors.grey, - ), - ), - )); + } + }, + disabledColor: Colors.grey, + ).insideContainer, + ], + ), + ); } String getDate() { @@ -305,33 +294,41 @@ class _AddBloodSugarPageState extends State { } void confirmSelectMeasureUnitDialog() { + List list = [ + RadioSelectionDialogModel("mg/dlt", 0), + RadioSelectionDialogModel("mol/L", 1), + ]; + showDialog( context: context, - child: RadioStringDialog( - radioList: measureUnitList, - title: TranslationBase.of(context).measureUnit, - selectedValue: measureUnitSelectedType, - onValueSelected: (value) { - setState(() { - measureUnitSelectedType = value; - }); + child: RadioSelectionDialog( + listData: list, + selectedIndex: _selectedMeasureUnitIndex, + onValueSelected: (index) { + _selectedMeasureUnitIndex = index; + measureUnitSelectedType = list[index].title; + setState(() {}); }, ), ); } - void confirmSelectMeasureTimeDialog(List list) { + void confirmSelectMeasureTimeDialog(List dataList) { + List list = [ + for (int i = 0; i < dataList.length; i++) RadioSelectionDialogModel(dataList[i], i), + ]; + showDialog( context: context, - child: RadioStringDialog( - radioList: list, - title: TranslationBase.of(context).measureTime, - selectedValue: measureTimeSelectedType, - onValueSelected: (value) { - setState(() { - measureTimeSelectedType = value; - measuredTime = list.indexOf(value); - }); + child: RadioSelectionDialog( + listData: list, + selectedIndex: _selectedMeasureTimeIndex, + isScrollable: true, + onValueSelected: (index) { + _selectedMeasureTimeIndex = index; + measureTimeSelectedType = list[index].title; + measuredTime = index; + setState(() {}); }, ), ); diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index eb1c1961..3608bcb0 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -795,6 +795,8 @@ class TranslationBase { String get myBalances => localizedValues['MyBalances'][locale.languageCode]; + String get myWallet => localizedValues['MyWallet'][locale.languageCode]; + String get balanceAmount => localizedValues['BalanceAmount'][locale.languageCode]; String get totalBalance => localizedValues['TotalBalance'][locale.languageCode]; diff --git a/lib/widgets/dialogs/RadioStringDialog.dart b/lib/widgets/dialogs/RadioStringDialog.dart deleted file mode 100644 index 49a16142..00000000 --- a/lib/widgets/dialogs/RadioStringDialog.dart +++ /dev/null @@ -1,139 +0,0 @@ -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -class RadioStringDialog extends StatefulWidget { - final List radioList; - final Function(String) onValueSelected; - final String title; - String selectedValue; - - RadioStringDialog({Key key, this.radioList, this.onValueSelected, this.selectedValue, this.title}); - - @override - _RadioStringDialogState createState() => _RadioStringDialogState(); -} - -class _RadioStringDialogState extends State { - @override - void initState() { - super.initState(); - widget.selectedValue = widget.selectedValue ?? widget.radioList[0]; - } - - @override - Widget build(BuildContext context) { - return SimpleDialog( - title: Container( - width: double.infinity, - child: Center( - child: Texts( - widget.title, - textAlign: TextAlign.center, - ))), - children: [ - Container( - height: widget.radioList.length > 3 ? MediaQuery.of(context).size.height * 0.6 : null, - child: SingleChildScrollView( - child: Column( - children: [ - Divider(), - ...List.generate( - widget.radioList.length, - (index) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // SizedBox( - // height: 2, - // ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - widget.selectedValue = widget.radioList[index]; - }); - }, - child: ListTile( - title: Texts( - widget.radioList[index], - fontSize: 14, - ), - leading: Radio( - value: widget.radioList[index], - groupValue: widget.selectedValue, - activeColor: Colors.red[800], - onChanged: (value) { - setState(() { - widget.selectedValue = value; - }); - }, - ), - ), - ), - ) - ], - ), - ], - ), - ), - SizedBox( - height: 5.0, - ), - ], - ), - ), - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Center( - child: Texts( - TranslationBase.of(context).cancel.toUpperCase(), - color: Colors.red, - ), - ), - ), - ), - ), - ), - Container( - width: 1, - height: 30, - color: Colors.grey[500], - ), - Expanded( - flex: 1, - child: InkWell( - onTap: () { - widget.onValueSelected(widget.selectedValue); - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Texts( - TranslationBase.of(context).ok, - fontWeight: FontWeight.w400, - ), - ), - ), - ), - ), - ], - ) - ], - ); - } -}