From 907d90b98758ba036c27d411bad7872aa9596d68 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 5 Aug 2021 09:57:45 +0300 Subject: [PATCH] login ui and forgot password ui added. --- lib/config/localized_values.dart | 8 +- lib/pages/login/confirm-login.dart | 2 +- lib/pages/login/forgot-password.dart | 67 ++++++++- lib/pages/login/login-type.dart | 42 +----- lib/pages/login/login.dart | 149 ++++++++++++++++++ lib/pages/settings/general_setting.dart | 4 +- lib/uitl/translations_delegate_base.dart | 4 + lib/widgets/habib_logo_widget.dart | 42 ++++++ lib/widgets/mobile-no/mobile_no.dart | 183 +++++++++++++++++++---- 9 files changed, 427 insertions(+), 74 deletions(-) create mode 100644 lib/widgets/habib_logo_widget.dart diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 1e3ead26..aaabb852 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -112,13 +112,15 @@ const Map localizedValues = { "logintyperadio": {"en": "Choose from below options to login to your medical file.", "ar": "اختر من الخيارات أدناه لتسجيل الدخول إلى ملفك الطبي."}, "registernow": {"en": "Register Now", "ar": "تسجيل الان"}, "nationalID": {"en": "Enter the Identification Number", "ar": "أدخل رقم الهوية الوطنية او الاقامة"}, + "national-id-number": {"en": "National ID Number", "ar": "رقم الهوية الوطنيةالاقامة"}, + "medical-file-number": {"en": "Medical File Number", "ar": "رقم الملف الطبي"}, "national-id": {"en": "National ID", "ar": "رقم الهوية"}, "fileNo": {"en": "File Number", "ar": "رقم الملف"}, "fileno": {"en": "File No", "ar": "رقم الملف"}, "forgotFileNo": {"en": "Forgot file Number?", "ar": "نسيت رقم الملف الطبي؟"}, "forgotFileNoTitle": {"en": "Forgot medical file", "ar": "نسيت رقم الملف"}, - "enter-national-id": {"en": "Please enter mobile number and identification number", "ar": "الرجاء إدخال رقم الجوال ورقم الهوية"}, + "enter-national-id": {"en": "Please Enter Mobile Number and National ID Number", "ar": "الرجاء إدخال رقم الجوال ورقم الهوية"}, "profile-info": {"en": "Please enter profile information", "ar": "الرجاء إدخال معلومات الملف الشخصي"}, "submit": {"en": "Submit", "ar": "ارسال"}, "forgot-desc": {"en": "Enter the mobile number to receive the Medical file Number via SMS", "ar": "أدخل رقم الجوال المسجل لاستلام رقم الملف عن طريق الرسائل النصية"}, @@ -400,6 +402,8 @@ const Map localizedValues = { "ConfirmThePayment": {"en": "Confirm The Payment", "ar": "تأكيد عملية الدفع"}, "DepositorName": {"en": "Depositor Name", "ar": "اسم المودع *"}, "MobileNumber": {"en": "Mobile Number", "ar": "رقم الجوال"}, + "phone-number": {"en": "Phone Number", "ar": "رقم الجوال"}, + "country": {"en": "Country", "ar": "دولة"}, "Ok": {"en": "Ok", "ar": "حسنا"}, "WaterConsumedInWeek": {"en": "Water consumed in a week", "ar": "معدل شرب الماء خلال الاسبوع"}, "WaterConsumedInMonth": {"en": "Water consumed in a month", "ar": "معدل شرب الماء خلال الشهر"}, @@ -1282,7 +1286,7 @@ const Map localizedValues = { "errorExpectedArrivalTimes": {"en": "Please Expected arrival time", "ar": "يرجى ادخال الوقت المتوقع للوصول"}, "expectedArrivalTime": {"en": "Expected arrival time", "ar": "الوقت المتوقع للوصول"}, "add-address": {"en": "Add new address", "ar": "اضف عنوان جديد"}, - "enter-file": {"en": "Please enter the mobile number and the medical file number", "ar": "الرجاء إدخال رقم الجوال ورقم الملف الطبي"}, + "enter-file": {"en": "Please Enter Mobile Number and Medical File Number", "ar": "الرجاء إدخال رقم الجوال ورقم الملف الطبي"}, "referralRequesterInformation": {"en": "Referral requester information", "ar": "معلومات طالب الإحالة"}, "enterReferralRequesterName": {"en": "Enter Referral Requester Name*", "ar": "أدخل اسم مقدم طلب الإحالة *"}, "selectRelationship": {"en": "Select Relationship", "ar": "حدد العلاقة"}, diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index 6643dae8..677f08a5 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -231,7 +231,7 @@ class _ConfirmLogin extends State { }, child: Text( TranslationBase.of(context).useAnotherAccount, - style: TextStyle(fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48, height: 35 / 16), + style: TextStyle(fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48), ), color: Color(0xffD02127), shape: RoundedRectangleBorder( diff --git a/lib/pages/login/forgot-password.dart b/lib/pages/login/forgot-password.dart index 0bc93081..39f04f57 100644 --- a/lib/pages/login/forgot-password.dart +++ b/lib/pages/login/forgot-password.dart @@ -5,6 +5,7 @@ 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/dialogs/alert_dialog.dart'; +import 'package:diplomaticquarterapp/widgets/habib_logo_widget.dart'; import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/otp/sms-popup.dart'; @@ -26,6 +27,68 @@ class _ForgotPassword extends State { @override Widget build(BuildContext context) { con = context; + + return Scaffold( + backgroundColor: Color(0xfff8f8f8), + resizeToAvoidBottomPadding: false, + appBar: AppBar( + backgroundColor: Colors.transparent, + leading: IconButton( + icon: Icon(Icons.arrow_back_ios), + color: Color(0xff2B353E), + onPressed: () => Navigator.pop(context), + ), + ), + body: Padding( + padding: EdgeInsets.only(bottom: 20, left: 21, right: 21), + child: Column(children: [ + Expanded( + child: ListView( + padding: EdgeInsets.zero, + physics: BouncingScrollPhysics(), + children: [ + SizedBox(height: 12), + HabibLogoWidget(), + SizedBox(height: 50), + Text( + TranslationBase.of(context).forgotDesc, + style: TextStyle(fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), + ), + SizedBox(height: 20), + PhoneNumberSelectorWidget(onNumberChange: (value) { + setState(() { + mobileNo = value; + }); + }, onCountryChange: (value) { + setState(() { + countryCode = value; + }); + }), + ], + ), + ), + SizedBox( + height: 43, + width: double.infinity, + child: FlatButton( + onPressed: () { + sendPatientIDBySMS(); + }, + child: Text( + TranslationBase.of(context).submit, + style: TextStyle(fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48), + ), + // color: Color(0xffD02127), + color: (mobileNo.length >= 9) == true ? Color(0xffD02127) : Color(0xff575757), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6), + ), + ), + ), + ]), + ), + ); + return AppScaffold( appBarTitle: TranslationBase.of(context).forgotFileNoTitle, isShowAppBar: true, @@ -79,9 +142,7 @@ class _ForgotPassword extends State { sendPatientIDBySMS(); // print(mobileNo.text); }, - color: mobileNo.length >= 9 == true - ? Colors.grey[900] - : Colors.grey, + color: mobileNo.length >= 9 == true ? Colors.grey[900] : Colors.grey, textColor: Colors.white, )), ], diff --git a/lib/pages/login/login-type.dart b/lib/pages/login/login-type.dart index 38b5eb39..6c4425e0 100644 --- a/lib/pages/login/login-type.dart +++ b/lib/pages/login/login-type.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; +import 'package:diplomaticquarterapp/widgets/habib_logo_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -39,38 +40,7 @@ class LoginType extends StatelessWidget { physics: BouncingScrollPhysics(), children: [ SizedBox(height: 12), - Row( - children: [ - SvgPicture.asset( - "assets/images/new/hmg_icon.svg", - height: 62, - width: 62, - ), - SizedBox(width: 10), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text( - TranslationBase.of(context).welcomeTo, - style: TextStyle(fontSize: 12, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.72, height: 23 / 12), - ), - Text( - TranslationBase.of(context).drSulaimanText, - style: TextStyle(fontSize: 24, fontFamily: "Poppins", fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 23 / 24), - ), - Text( - TranslationBase.of(context).patientApp, - style: TextStyle(fontSize: 12, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xffD02127), letterSpacing: -0.72), - ), - SizedBox(height: 2), - ], - ), - ) - ], - ), + HabibLogoWidget(), SizedBox(height: 50), Text( TranslationBase.of(context).logintypeRadio, @@ -82,8 +52,8 @@ class LoginType extends StatelessWidget { padding: EdgeInsets.only(top: 25), shrinkWrap: true, children: [ - getButton(context, TranslationBase.of(context).idNo, 'assets/images/new/national_id.svg', 1), - getButton(context, TranslationBase.of(context).fileNo, 'assets/images/new/medical_file.svg', 2), + getButton(context, TranslationBase.of(context).nationalIdNumber, 'assets/images/new/national_id.svg', 1), + getButton(context, TranslationBase.of(context).medicalFileNumber, 'assets/images/new/medical_file.svg', 2), ], ), SizedBox(height: 20), @@ -103,11 +73,11 @@ class LoginType extends StatelessWidget { width: double.infinity, child: FlatButton( onPressed: () { - Navigator.of(context).pushNamed(LOGIN_TYPE); + Navigator.of(context).push(FadePage(page: Register())); }, child: Text( TranslationBase.of(context).registerNow, - style: TextStyle(fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48, height: 35 / 16), + style: TextStyle(fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48), ), color: Color(0xffD02127), shape: RoundedRectangleBorder( diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 998bf1c2..41b3d91e 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -22,12 +22,14 @@ import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; +import 'package:diplomaticquarterapp/widgets/habib_logo_widget.dart'; import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.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/rendering.dart'; import 'package:provider/provider.dart'; import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart'; import '../../Constants.dart'; @@ -73,6 +75,65 @@ class _Login extends State { Widget build(BuildContext context) { projectViewModel = Provider.of(context); toDoProvider = Provider.of(context); + + return Scaffold( + backgroundColor: Color(0xfff8f8f8), + resizeToAvoidBottomPadding: false, + appBar: AppBar( + backgroundColor: Colors.transparent, + leading: IconButton( + icon: Icon(Icons.arrow_back_ios), + color: Color(0xff2B353E), + onPressed: () => Navigator.pop(context), + ), + ), + body: Padding( + padding: EdgeInsets.only(bottom: 20, left: 21, right: 21), + child: Column(children: [ + Expanded( + child: ListView( + padding: EdgeInsets.zero, + physics: BouncingScrollPhysics(), + children: [ + SizedBox(height: 12), + HabibLogoWidget(), + SizedBox(height: 50), + Text( + loginType == 1 ? TranslationBase.of(context).enterNationalId : TranslationBase.of(context).enterFile, + style: TextStyle(fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), + ), + SizedBox(height: 20), + // inputWidget("Country", "Saudi Arabia", isEnable: false, hasSelection: true), + // SizedBox(height: 12), + // inputWidget("Phone Number", "5xxxxxxxx", prefix: countryCode), + PhoneNumberSelectorWidget(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), + SizedBox(height: 12), + inputWidget(loginType == 1 ? TranslationBase.of(context).nationalIdNumber : TranslationBase.of(context).medicalFileNumber, "Xxxxxxxxx", nationalIDorFile), + ], + ), + ), + SizedBox( + height: 43, + width: double.infinity, + child: FlatButton( + onPressed: () { + this.startLogin(); + }, + child: Text( + TranslationBase.of(context).login, + style: TextStyle(fontSize: 16, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48), + ), + // color: Color(0xffD02127), + color: isButtonDisabled == true ? Color(0xff575757) : Color(0xffD02127), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6), + ), + ), + ), + ]), + ), + ); + return AppScaffold( appBarTitle: TranslationBase.of(context).login, isShowAppBar: true, @@ -144,6 +205,92 @@ class _Login extends State { ); } + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = 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, + fontFamily: "Poppins", + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + controller: _controller, + onChanged: (value) => {validateForm()}, + style: TextStyle( + fontSize: 14, + fontFamily: "Poppins", + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + fontFamily: "Poppins", + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + fontFamily: "Poppins", + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], + ), + ), + ); + } + startLogin() { if (isButtonDisabled == false) { checkUserAuthentication(); @@ -151,6 +298,7 @@ class _Login extends State { } void validateForm() { + print("mobileNo:${mobileNo}"); if (util.validateIDBox(nationalIDorFile.text, loginType) == true && util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) { setState(() { isButtonDisabled = false; @@ -160,6 +308,7 @@ class _Login extends State { isButtonDisabled = true; }); } + print("isButtonDisabled:${isButtonDisabled}"); } checkUserAuthentication() { diff --git a/lib/pages/settings/general_setting.dart b/lib/pages/settings/general_setting.dart index 8f2519aa..fa9fdf28 100644 --- a/lib/pages/settings/general_setting.dart +++ b/lib/pages/settings/general_setting.dart @@ -285,11 +285,11 @@ class _GeneralSettings extends State getTheme(value) async { if (value == 1) { return invertThemes( - fontName: Provider.of(context, listen: false).isArabic ? 'Cairo' : 'WorkSans' + fontName: Provider.of(context, listen: false).isArabic ? 'Cairo' : 'Poppins' ); } else if (value == 3) { return bwThemes( - fontName: Provider.of(context, listen: false).isArabic ? 'Cairo' : 'WorkSans' + fontName: Provider.of(context, listen: false).isArabic ? 'Cairo' : 'Poppins' ); } else { return defaultTheme( diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 6f82ca8d..4401b614 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -138,6 +138,8 @@ class TranslationBase { String get registerNow => localizedValues['registernow'][locale.languageCode]; String get nationalID => localizedValues['nationalID'][locale.languageCode]; + String get medicalFileNumber => localizedValues['medical-file-number'][locale.languageCode]; + String get nationalIdNumber => localizedValues['national-id-number'][locale.languageCode]; String get idNo => localizedValues['national-id'][locale.languageCode]; @@ -505,6 +507,8 @@ class TranslationBase { String get confirmThePayment => localizedValues['ConfirmThePayment'][locale.languageCode]; String get depositorName => localizedValues['DepositorName'][locale.languageCode]; String get mobileNumber => localizedValues['MobileNumber'][locale.languageCode]; + String get phoneNumber => localizedValues['phone-number'][locale.languageCode]; + String get country => localizedValues['country'][locale.languageCode]; String get ok => localizedValues['Ok'][locale.languageCode]; String get waterConsumedInWeek => localizedValues['WaterConsumedInWeek'][locale.languageCode]; String get waterConsumedInMonth => localizedValues['WaterConsumedInMonth'][locale.languageCode]; diff --git a/lib/widgets/habib_logo_widget.dart b/lib/widgets/habib_logo_widget.dart new file mode 100644 index 00000000..6754767a --- /dev/null +++ b/lib/widgets/habib_logo_widget.dart @@ -0,0 +1,42 @@ +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; + +class HabibLogoWidget extends StatelessWidget { + HabibLogoWidget({Key key}) : super(key: key); + @override + Widget build(BuildContext context) { + return Row( + children: [ + SvgPicture.asset( + "assets/images/new/hmg_icon.svg", + height: 62, + width: 62, + ), + SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text( + TranslationBase.of(context).welcomeTo, + style: TextStyle(fontSize: 12, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.72, height: 23 / 12), + ), + Text( + TranslationBase.of(context).drSulaimanText, + style: TextStyle(fontSize: 24, fontFamily: "Poppins", fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 23 / 24), + ), + Text( + TranslationBase.of(context).patientApp, + style: TextStyle(fontSize: 12, fontFamily: "Poppins", fontWeight: FontWeight.w600, color: Color(0xffD02127), letterSpacing: -0.72), + ), + SizedBox(height: 2), + ], + ), + ) + ], + ); + } +} diff --git a/lib/widgets/mobile-no/mobile_no.dart b/lib/widgets/mobile-no/mobile_no.dart index 6e89f529..fe4d00bd 100644 --- a/lib/widgets/mobile-no/mobile_no.dart +++ b/lib/widgets/mobile-no/mobile_no.dart @@ -1,11 +1,158 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/mobile_number.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../Constants.dart'; +class PhoneNumberSelectorWidget extends StatefulWidget { + final Function onNumberChange; + final Function onCountryChange; + PhoneNumberSelectorWidget({ + Key key, + this.onNumberChange, + this.onCountryChange, + }) : super(key: key); + + @override + _PhoneNumberSelectorWidgetState createState() { + return _PhoneNumberSelectorWidgetState(); + } +} + +class _PhoneNumberSelectorWidgetState extends State { + var _selectedType = '+966'; + String countryCode = '+966'; + List counties = []; + ProjectViewModel projectProvider; + @override + void initState() { + for (var element in countriesData) counties.add(Countries.fromJson(element)); + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + projectProvider = Provider.of(context); + String countryName = ""; + for (var element in counties) { + if (element.code == countryCode) { + countryName = projectProvider.isArabic == true ? element.nameAr : element.name; + } + } + + return Column( + children: [ + inputWidget(TranslationBase.of(context).country, countryName, isEnable: false, hasSelection: true), + SizedBox(height: 12), + inputWidget(TranslationBase.of(context).phoneNumber, "5xxxxxxxx", prefix: countryCode), + ], + ); + } + + Widget inputWidget(String _labelText, String _hintText, {String prefix, bool isEnable = true, bool hasSelection = 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: PopupMenuButton( + tooltip: "", + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontFamily: "Poppins", + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + onChanged: (value) => widget.onNumberChange(value), + style: TextStyle( + fontSize: 14, + fontFamily: "Poppins", + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + fontFamily: "Poppins", + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + prefix, + style: TextStyle( + fontSize: 14, + fontFamily: "Poppins", + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], + ), + itemBuilder: (_) => >[ + if (hasSelection) + for (var country in counties) PopupMenuItem(child: Text(projectProvider.isArabic == true ? country.nameAr : country.name), value: country.code) + ], + onSelected: (countryCode) { + setState(() { + this.countryCode = countryCode; + _selectedType = countryCode; + }); + widget.onCountryChange(countryCode); + }, + )); + } +} + class MobileNo extends StatefulWidget { final bool disabled; @@ -18,16 +165,7 @@ class MobileNo extends StatefulWidget { final Function onNumberChange; final Function onCountryChange; - MobileNo( - {this.disabled = false, - this.marginTop = 0, - this.marginRight = 0, - this.marginBottom = 0, - this.controller, - this.marginLeft = 0, - this.onNumberChange, - this.onCountryChange, - this.margin = 0}); + MobileNo({this.disabled = false, this.marginTop = 0, this.marginRight = 0, this.marginBottom = 0, this.controller, this.marginLeft = 0, this.onNumberChange, this.onCountryChange, this.margin = 0}); @override _MobileNo createState() => _MobileNo(); @@ -82,13 +220,10 @@ class _MobileNo extends State { _selectedType = value; }) }, - items: counties.map>( - (Countries value) { + items: counties.map>((Countries value) { return DropdownMenuItem( value: value.code, - child: Text(projectProvider.isArabic == true - ? value.nameAr - : value.name), + child: Text(projectProvider.isArabic == true ? value.nameAr : value.name), ); }).toList())))), ), @@ -96,10 +231,7 @@ class _MobileNo extends State { ), Container( padding: EdgeInsets.all(5), - decoration: BoxDecoration( - color: Colors.white, - border: Border.all(color: Colors.grey), - borderRadius: BorderRadius.circular(10)), + decoration: BoxDecoration(color: Colors.white, border: Border.all(color: Colors.grey), borderRadius: BorderRadius.circular(10)), child: Row(children: [ Expanded( flex: 1, @@ -116,13 +248,7 @@ class _MobileNo extends State { Expanded( flex: 4, child: Container( - margin: widget.margin != null - ? EdgeInsets.all(widget.margin) - : EdgeInsets.only( - top: widget.marginTop, - right: widget.marginRight, - bottom: widget.marginBottom, - left: widget.marginLeft), + margin: widget.margin != null ? EdgeInsets.all(widget.margin) : EdgeInsets.only(top: widget.marginTop, right: widget.marginRight, bottom: widget.marginBottom, left: widget.marginLeft), child: TextField( controller: widget.controller, keyboardType: TextInputType.number, @@ -134,10 +260,7 @@ class _MobileNo extends State { // }, onChanged: (value) => widget.onNumberChange(value), - decoration: InputDecoration( - counterText: "", - border: InputBorder.none, - hintText: '5xxxxxxxx'), + decoration: InputDecoration(counterText: "", border: InputBorder.none, hintText: '5xxxxxxxx'), ), ), )