From a95c272daf5df42b91623a05a2ec6b4f9d3dd1a2 Mon Sep 17 00:00:00 2001 From: Aamir Muhammad Date: Wed, 9 Jul 2025 16:46:35 +0300 Subject: [PATCH 1/2] lottie & bottom sheet --- lib/pages/login/register_new.dart | 4 +- lib/pages/login/welcome.dart | 434 +++++--------------- lib/uitl/utils.dart | 52 +-- lib/widgets/others/app_scaffold_widget.dart | 6 +- pubspec.yaml | 2 + 5 files changed, 126 insertions(+), 372 deletions(-) diff --git a/lib/pages/login/register_new.dart b/lib/pages/login/register_new.dart index 05cd500c..967caa41 100644 --- a/lib/pages/login/register_new.dart +++ b/lib/pages/login/register_new.dart @@ -55,7 +55,7 @@ class _RegisterNew extends State { appBarTitle: TranslationBase.of(context).register, isShowDecPage: false, isShowAppBar: true, - isshowBackButton: false, + isshowBackButton: true, showNewAppBar: true, backgroundColor: Color(0xffF8F8F8), showNewAppBarTitle: false, @@ -64,7 +64,7 @@ class _RegisterNew extends State { appBarIcons: [], dropDownList: [], dropDownIndexChange: (value) { - Utils.changeAppLanguage(projectViewModel: context.read(), context: context); + Utils.changeAppLanguage(context: context); }, body: SingleChildScrollView( child: Container( diff --git a/lib/pages/login/welcome.dart b/lib/pages/login/welcome.dart index a4a4c2c6..ba9aa73f 100644 --- a/lib/pages/login/welcome.dart +++ b/lib/pages/login/welcome.dart @@ -2,6 +2,7 @@ import 'package:flutter/gestures.dart'; import 'package:hmg_patient_app/analytics/google-analytics.dart'; import 'package:hmg_patient_app/config/config.dart'; import 'package:hmg_patient_app/config/shared_pref_kay.dart'; +import 'package:hmg_patient_app/config/size_config.dart'; import 'package:hmg_patient_app/core/service/AuthenticatedUserObject.dart'; import 'package:hmg_patient_app/core/viewModels/appointment_rate_view_model.dart'; import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; @@ -101,99 +102,68 @@ class _WelcomeLogin extends State { @override Widget build(BuildContext context) { projectViewModel = context.read(); - - return SafeArea( - child: AppScaffold( - appBarTitle: TranslationBase.of(context).welcome, - isShowDecPage: false, - isShowAppBar: true, - isshowBackButton: false, - showNewAppBar: true, - backgroundColor: Color(0xffF8F8F8), - showNewAppBarTitle: false, - showDropDown: true, - isShowLanguageChanger: true, - appBarIcons: [], - dropDownList: [], - dropDownIndexChange: (value) { - Utils.changeAppLanguage(projectViewModel: projectViewModel, context: context); - }, - dropdownIndexValue: Utils.selectedLanguage, - body: Column( + return AppScaffold( + appBarTitle: TranslationBase.of(context).welcome, + isShowDecPage: false, + isShowAppBar: true, + isshowBackButton: false, + showNewAppBar: true, + backgroundColor: Color(0xffF8F8F8), + showNewAppBarTitle: false, + showDropDown: true, + isShowLanguageChanger: true, + appBarIcons: [], + dropDownList: [], + dropDownIndexChange: (value) { + Utils.changeAppLanguage(context: context); + }, + body: Padding( + padding: EdgeInsets.symmetric(horizontal: 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: ListView( - padding: EdgeInsets.only(left: 21, right: 21), - physics: BouncingScrollPhysics(), - children: [ - SizedBox(height: 30), - Row( - children: [ - SvgPicture.asset( - "assets/images/new/hmg_icon.svg", - height: 62, - width: 62, - ), - ], - ), - // Example of using toDoProvider: - // if (toDoProvider.count > 0) Text("To-Do items: ${toDoProvider.count}"), - ], + Utils.showLottie(context: context, assetPath: 'assets/anims/lottie/login.json'), + // SvgPicture.asset("assets/images/new/hmg_icon.svg", height: 62, width: 62), + Spacer(flex: 1), + Text( + TranslationBase.of(context).welcomeToDrSulaiman, + style: TextStyle( + fontSize: 36, + fontFamily: (projectViewModel.currentLanguage == 'ar' ? 'Cairo' : 'Poppins'), + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.4, + height: 47 / 36, ), ), - Spacer(), - Container( - padding: EdgeInsets.only(top: 30, bottom: 0, right: 21, left: 21), - child: Text( - TranslationBase.of(context).welcomeToDrSulaiman, - style: TextStyle( - fontSize: 36, - fontFamily: (projectViewModel.currentLanguage == 'ar' ? 'Cairo' : 'Poppins'), - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.4, - height: 47 / 36, - ), - ), - ), - Container( - padding: EdgeInsets.only(top: 16, bottom: 10, right: 21, left: 21), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Directionality( - textDirection: TextDirection.ltr, // Consider making this dynamic based on language - child: inputWidget( - "National ID. or File No", - "1xxxxxxxx", - nationIdController, // Assumed to be a TextEditingController in your State class - isEnable: true, - prefix: null, - hasSelection: false, - isBorderAllowed: false, - isAllowLeadingIcon: true, - leadingIcon: "assets/images/svg/student-card.svg", - ), - ), - ], - ), - ), - SizedBox( - height: 15, + SizedBox(height: 20), + Directionality( + textDirection: TextDirection.ltr, + child: inputWidget("National ID. or File No", "1xxxxxxxx", nationIdController, + isEnable: true, prefix: null, hasSelection: false, isBorderAllowed: false, isAllowLeadingIcon: true, leadingIcon: "assets/images/svg/student-card.svg"), ), + SizedBox(height: 15), + Spacer(flex: 1), + ], + ), + ), + bottomSheet: Container( + decoration: BoxDecoration(color: Color(0xffF8F8F8)), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ Row( mainAxisSize: MainAxisSize.min, children: [ Expanded( child: Padding( - padding: const EdgeInsets.all(10.0), + padding: const EdgeInsets.symmetric(horizontal: 24), child: CustomButton( text: TranslationBase.of(context).login, icon: "assets/images/svg/login1.svg", onPressed: () { bool isValid = validateIqama(nationIdController.text); print("Iqama is valid: $isValid"); - if (isValid) { showModalBottomSheet( context: context, @@ -201,10 +171,7 @@ class _WelcomeLogin extends State { isDismissible: false, backgroundColor: Colors.transparent, builder: (bottomSheetContext) => Padding( - // Use a different context name - padding: EdgeInsets.only( - bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom, - ), + padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom), child: SingleChildScrollView( child: GenericBottomSheet( countryCode: "966", @@ -265,277 +232,60 @@ class _WelcomeLogin extends State { ), ], ), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - RichText( - textAlign: TextAlign.center, - text: TextSpan( - style: TextStyle( - color: Colors.black, - fontSize: 16, - height: 26 / 16, - fontFamily: 'poppins', - fontWeight: FontWeight.w500, - ), - children: [ - TextSpan( - text: TranslationBase.of(context).dontHaveAccount, + SizedBox( + height: 10, + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 16.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RichText( + textAlign: TextAlign.center, + text: TextSpan( + style: TextStyle( + color: Colors.black, + fontSize: 16, + height: 26 / 16, + fontFamily: 'poppins', + fontWeight: FontWeight.w500, ), - TextSpan(text: " "), - TextSpan( - text: TranslationBase.of(context).registerNow, - style: const TextStyle( - color: Colors.red, - fontSize: 16, - height: 26 / 16, - fontFamily: 'poppins', - fontWeight: FontWeight.w500, + children: [ + TextSpan( + text: TranslationBase.of(context).dontHaveAccount, ), - recognizer: TapGestureRecognizer() - ..onTap = () { - Navigator.of(context).push(FadePage(page: RegisterNew())); - locator().loginRegistration.visited_alhabib_group(true); - }, - ), - ], + TextSpan(text: " "), + TextSpan( + text: TranslationBase.of(context).registerNow, + style: const TextStyle( + color: Colors.red, + fontSize: 16, + height: 26 / 16, + fontFamily: 'poppins', + fontWeight: FontWeight.w500, + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + Navigator.of(context).push(FadePage(page: RegisterNew())); + locator().loginRegistration.visited_alhabib_group(true); + }, + ), + ], + ), ), - ), - ], + ], + ), ), SizedBox( - height: 10, - ), + height: 30, + ) ], ), ), ); } - // Widget build(BuildContext context) { - // projectViewModel = Provider.of(context); - // projectViewModel.isArabic ? _selectedLanguage = 0 : 1; - // toDoProvider = Provider.of(context); - // return AppScaffold( - // appBarTitle: TranslationBase.of(context).welcome, - // isShowDecPage: false, - // isShowAppBar: true, - // isshowBackButton: false, - // showNewAppBar: true, - // backgroundColor: Color(0xffF8F8F8), - // showNewAppBarTitle: false, - // showDropDown: true, - // isShowLanguageChanger: true, - // appBarIcons: [], - // dropDownList: [ - // TranslationBase.of(context).arabicChange, - // TranslationBase.of(context).english, - // ], - // dropDownIndexChange: (value) { - // _selectedLanguage = value!; - // if (projectViewModel.isArabic) { - // projectViewModel.changeLanguage('en'); - // locator().hamburgerMenu.logMenuItemClick('change language to english'); - // } else { - // projectViewModel.changeLanguage('ar'); - // locator().hamburgerMenu.logMenuItemClick('change language to arabic'); - // } - // }, - // dropdownIndexValue: _selectedLanguage, - // body: Column( - // children: [ - // Expanded( - // child: ListView( - // padding: EdgeInsets.only(left: 21, right: 21), - // physics: BouncingScrollPhysics(), - // children: [ - // SizedBox(height: 30), - // Row( - // children: [ - // SvgPicture.asset( - // "assets/images/new/hmg_icon.svg", - // height: 62, - // width: 62, - // ), - // ], - // ), - // ], - // ), - // ), - // Spacer(), - // Expanded( - // child: Container( - // padding: EdgeInsets.only(top: 30, bottom: 0, right: 21, left: 21), - // child: Text( - // // TranslationBase.of(context).welcome, - // "Welcome to Dr. Sulaiman Al Habib Medical Group", - // style: TextStyle(fontSize: 36, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.4, height: 47 / 36), - // ), - // ), - // ), - // Container( - // padding: EdgeInsets.only(top: 16, bottom: 10, right: 21, left: 21), - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.stretch, - // children: [ - // Directionality( - // textDirection: TextDirection.ltr, - // child: inputWidget( - // "National ID. or File No", - // "1xxxxxxxx", - // nationIdController, - // isEnable: true, - // prefix: null, - // hasSelection: false, - // isBorderAllowed: false, - // isAllowLeadingIcon: true, - // leadingIcon: "assets/images/svg/student-card.svg", - // ), - // ), - // ], - // ), - // ), - // SizedBox( - // height: 15, - // ), - // Row( - // mainAxisSize: MainAxisSize.min, - // children: [ - // Expanded( - // child: Container( - // padding: EdgeInsets.only(top: 0, bottom: 16, right: 21, left: 21), - // child: DefaultButton( - // TranslationBase.of(context).login, - // () { - // bool isValid = validateIqama(nationIdController.text); - // print("Iqama is valid: $isValid"); - // - // if (isValid) { - // showModalBottomSheet( - // context: context, - // isScrollControlled: true, - // isDismissible: false, - // backgroundColor: Colors.transparent, - // builder: (context) => Padding( - // padding: EdgeInsets.only( - // bottom: MediaQuery.of(context).viewInsets.bottom, - // ), - // child: SingleChildScrollView( - // child: GenericBottomSheet( - // countryCode: "966", // Default is +966 as in your example - // initialPhoneNumber: "", // - // textController: phoneController, - // buttons: [ - // Padding( - // padding: const EdgeInsets.only(bottom: 10), - // child: CustomButton( - // text: "Send me OTP on SMS", - // onPressed: () { - // onOtpBtnPressed(OTPType.sms); - // }, - // backgroundColor: Colors.red, - // borderColor: Colors.red, - // textColor: Colors.white, - // icon: "assets/images/svg/message.svg", - // ), - // ), - // Row( - // crossAxisAlignment: CrossAxisAlignment.center, - // mainAxisAlignment: MainAxisAlignment.center, - // children: [ - // Padding( - // padding: const EdgeInsets.symmetric(horizontal: 8), - // child: AppText( - // "OR", - // fontSize: 16, - // fontFamily: 'poppins', - // color: Color(0xFF2E3039), - // fontWeight: FontWeight.w500, - // ), - // ), - // ], - // ), - // Padding( - // padding: const EdgeInsets.only(bottom: 10), - // child: CustomButton( - // text: "Send me OTP on WhatsApp", - // onPressed: () { - // onOtpBtnPressed(OTPType.whatsapp); - // }, - // backgroundColor: Colors.white, - // borderColor: Color(0xFF2E3039), - // textColor: Color(0xFF2E3039), - // icon: "assets/images/svg/whatsapp.svg", - // ), - // ), - // ], - // ), - // ), - // )); - // } else { - // Utils.showErrorToast("Please enter a valid Iqama number."); - // } - // }, - // // color: CustomColors., - // textColor: Colors.white, - // ), - // ), - // ), - // // SizedBox(width: 8), - // // Expanded( - // // child: DefaultButton( - // // TranslationBase.of(context).yes, - // // () => { - // // Navigator.of(context).push(FadePage(page: LoginType())), - // // locator().loginRegistration.visited_alhabib_group(true), - // // }, - // // color: CustomColors.green, - // // ), - // // ), - // ], - // ), - // Row( - // crossAxisAlignment: CrossAxisAlignment.center, - // mainAxisAlignment: MainAxisAlignment.center, - // children: [ - // RichText( - // textAlign: TextAlign.center, - // text: TextSpan( - // style: TextStyle( - // color: Colors.black, - // fontSize: 16, - // height: 26 / 16, - // fontFamily: 'poppins', - // fontWeight: FontWeight.w500, - // ), - // children: [ - // TextSpan(text: 'Don’t have an account? '), - // TextSpan( - // text: 'Register now', - // style: const TextStyle( - // color: Colors.red, - // fontSize: 16, - // height: 26 / 16, - // fontFamily: 'poppins', - // fontWeight: FontWeight.w500, - // ), - // recognizer: TapGestureRecognizer() - // ..onTap = () { - // Navigator.of(context).push(FadePage(page: RegisterNew())); - // // Example: Navigator.push(context, MaterialPageRoute(builder: (context) => RegisterScreen())); - // }, - // ), - // ], - // ), - // ), - // ], - // ) - // ], - // ), - // ); - // } - void onOtpBtnPressed(OTPType type) { if (phoneController.text.isEmpty) { Utils.showErrorToast("Please enter your phone number."); diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index e8a604b0..a3a90e88 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -50,6 +50,7 @@ import 'package:hmg_patient_app/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:google_api_availability/google_api_availability.dart'; +import 'package:lottie/lottie.dart'; import 'dart:math' show asin, cos, pi, pow, sin, sqrt; // import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart'; @@ -66,40 +67,39 @@ import 'navigation_service.dart'; AppSharedPreferences sharedPref = new AppSharedPreferences(); class Utils { - // static ProgressDialog pr; - - // void changeLanguage(ProjectViewModel projectViewModel, int value, Function onChange(int)) { - // sharedPref.setBool(IS_ROBOT_INIT, false); - // sharedPref.remove(CLINICS_LIST); - // if (projectViewModel.isArabic) { - // _selectedLanguage = 1; - // projectViewModel.changeLanguage('en'); - // locator().hamburgerMenu.logMenuItemClick('change language to english'); - // } else { - // _selectedLanguage = 0; - // projectViewModel.changeLanguage('ar'); - // locator().hamburgerMenu.logMenuItemClick('change language to arabic'); - // } - // var themeNotifier = Provider.of(context, listen: false); - // themeNotifier.setTheme(defaultTheme(fontName: projectViewModel.isArabic ? 'Cairo' : 'Poppins')); - // } - - static int selectedLanguage = 0; - - static void changeAppLanguage({required ProjectViewModel projectViewModel, required BuildContext context}) { + static void changeAppLanguage({required BuildContext context}) { sharedPref.setBool(IS_ROBOT_INIT, false); sharedPref.remove(CLINICS_LIST); - if (projectViewModel.isArabic) { - selectedLanguage = 1; // 1 for English - projectViewModel.changeLanguage('en'); // This will call notifyListeners in ViewModel + if (context.read().isArabic) { + context.read().changeLanguage('en'); locator().hamburgerMenu.logMenuItemClick('change language to english'); } else { - selectedLanguage = 0; // 0 for Arabic - projectViewModel.changeLanguage('ar'); // This will call notifyListeners in ViewModel + context.read().changeLanguage('ar'); locator().hamburgerMenu.logMenuItemClick('change language to arabic'); } } + static Widget showLottie({ + required BuildContext context, + String assetPath = 'assets/icons/no_property.json', + double? height, + double? width, + BoxFit fit = BoxFit.cover, + Alignment alignment = Alignment.center, + bool repeat = false, + bool animate = true, + void Function(LottieComposition)? onLoaded, + }) { + return Lottie.asset(assetPath, + height: height ?? MediaQuery.of(context).size.height * 0.26, + width: width ?? MediaQuery.of(context).size.width, + fit: fit, + alignment: alignment, + repeat: repeat, + animate: animate, + onLoaded: onLoaded); + } + static var navigationProjectsList = [ { "Desciption": "Sahafa Hospital", diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 188e9ebd..2095fc0f 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -354,6 +354,8 @@ class NewAppBarWidget extends StatelessWidget implements PreferredSizeWidget { final List? appBarIcons; final bool isShowLanguageChanger; + String currentLang = 'ar'; + VoidCallback? onTap; NewAppBarWidget( @@ -442,9 +444,9 @@ class NewAppBarWidget extends StatelessWidget implements PreferredSizeWidget { child: Directionality( textDirection: TextDirection.ltr, child: LanguageSelector( - currentLanguage: dropdownIndexValue == 0 ? 'ar' : 'en', + currentLanguage: projectViewModel.isArabic ? 'ar' : 'en', onLanguageChanged: (String value) { - dropDownIndexChange!(value == 'ar' ? 0 : 1); + dropDownIndexChange!(value == 'ar' ? 1 : 0); }, languages: [ {'code': 'ar', 'name': '${TranslationBase.of(context).lanEnglish}'}, diff --git a/pubspec.yaml b/pubspec.yaml index 077e741a..cd5a8eee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -130,6 +130,7 @@ dependencies: firebase_analytics: ^11.5.1 cloudflare_turnstile: ^3.2.0 device_info_plus: ^11.5.0 + lottie: ^3.3.1 google_maps_place_picker_mb_v2: ^1.0.1 # vital_sign_camera: @@ -182,6 +183,7 @@ flutter: - assets/images/new/body_parts/ - assets/images/new/body_parts/male/ - assets/images/new/body_parts/female/ + - assets/anims/lottie/ fonts: - family: WorkSans From 1971a384956decbe1ffbe6d247227d847781b69c Mon Sep 17 00:00:00 2001 From: Aamir Muhammad Date: Wed, 9 Jul 2025 16:52:03 +0300 Subject: [PATCH 2/2] tweaks --- lib/pages/login/welcome.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pages/login/welcome.dart b/lib/pages/login/welcome.dart index ba9aa73f..bd1e53aa 100644 --- a/lib/pages/login/welcome.dart +++ b/lib/pages/login/welcome.dart @@ -122,18 +122,18 @@ class _WelcomeLogin extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Utils.showLottie(context: context, assetPath: 'assets/anims/lottie/login.json'), + Utils.showLottie(context: context, assetPath: 'assets/anims/lottie/login.json', width: 238, repeat: true), // SvgPicture.asset("assets/images/new/hmg_icon.svg", height: 62, width: 62), Spacer(flex: 1), Text( TranslationBase.of(context).welcomeToDrSulaiman, style: TextStyle( - fontSize: 36, + fontSize: 32, fontFamily: (projectViewModel.currentLanguage == 'ar' ? 'Cairo' : 'Poppins'), fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.4, - height: 47 / 36, + height: 47 / 32, ), ), SizedBox(height: 20), @@ -149,6 +149,7 @@ class _WelcomeLogin extends State { ), bottomSheet: Container( decoration: BoxDecoration(color: Color(0xffF8F8F8)), + // height: 160, child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -236,7 +237,7 @@ class _WelcomeLogin extends State { height: 10, ), Padding( - padding: const EdgeInsets.symmetric(vertical: 16.0), + padding: const EdgeInsets.symmetric(vertical: 10.0), child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,