@ -1,3 +1,5 @@
import ' dart:ui ' as ui ;
import ' package:easy_localization/easy_localization.dart ' ;
import ' package:easy_localization/easy_localization.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:hmg_patient_app_new/core/app_assets.dart ' ;
import ' package:hmg_patient_app_new/core/app_assets.dart ' ;
@ -19,7 +21,6 @@ import 'package:hmg_patient_app_new/widgets/bottomsheet/generic_bottom_sheet.dar
import ' package:hmg_patient_app_new/widgets/buttons/custom_button.dart ' ;
import ' package:hmg_patient_app_new/widgets/buttons/custom_button.dart ' ;
import ' package:hmg_patient_app_new/widgets/routes/custom_page_route.dart ' ;
import ' package:hmg_patient_app_new/widgets/routes/custom_page_route.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:provider/provider.dart ' ;
import ' dart:ui ' as ui ;
class SavedLogin extends StatefulWidget {
class SavedLogin extends StatefulWidget {
const SavedLogin ( { super . key } ) ;
const SavedLogin ( { super . key } ) ;
@ -33,6 +34,7 @@ class _SavedLogin extends State<SavedLogin> {
late AuthenticationViewModel authVm ;
late AuthenticationViewModel authVm ;
late AppState appState ;
late AppState appState ;
bool ? isOther ;
bool ? isOther ;
@ override
@ override
void initState ( ) {
void initState ( ) {
authVm = context . read < AuthenticationViewModel > ( ) ;
authVm = context . read < AuthenticationViewModel > ( ) ;
@ -90,11 +92,11 @@ class _SavedLogin extends State<SavedLogin> {
: SizedBox ( ) ,
: SizedBox ( ) ,
SizedBox ( height: 24. h ) ,
SizedBox ( height: 24. h ) ,
Container (
Container (
padding: EdgeInsets . all ( 16. h ) ,
padding: EdgeInsets . all ( 16. h ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 20. h , hasShadow: false , isCustomShadow: [
decoration: RoundedRectangleBorder ( )
BoxShadow ( color: Color ( 0x0D000000 ) , blurRadius: 16. h , offset: Offset ( 0 , 0 ) , spreadRadius: 5. h ) ,
. toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 20. h , hasShadow: false , isCustomShadow: [
] ) ,
BoxShadow ( color: Color ( 0x0D000000 ) , blurRadius: 16. h , offset: Offset ( 0 , 0 ) , spreadRadius: 5. h ) ,
] ) ,
child: Column (
child: Column (
children: [
children: [
/ / Last login info - show WhatsApp only if isOther AND loginType is SMS
/ / Last login info - show WhatsApp only if isOther AND loginType is SMS
@ -105,7 +107,9 @@ class _SavedLogin extends State<SavedLogin> {
textDirection: ui . TextDirection . ltr ,
textDirection: ui . TextDirection . ltr ,
child: appState . getSelectDeviceByImeiRespModelElement ! = null
child: appState . getSelectDeviceByImeiRespModelElement ! = null
? ( appState . getSelectDeviceByImeiRespModelElement ! . createdOn ! = null
? ( appState . getSelectDeviceByImeiRespModelElement ! . createdOn ! = null
? DateUtil . getFormattedDate ( DateUtil . convertStringToDate ( appState . getSelectDeviceByImeiRespModelElement ! . createdOn ! ) , " d MMMM, y 'at' HH:mm " )
? DateUtil . getFormattedDate (
DateUtil . convertStringToDate ( appState . getSelectDeviceByImeiRespModelElement ! . createdOn ! ) ,
" d MMMM, y 'at' HH:mm " )
: ' -- ' )
: ' -- ' )
. toText16 ( isBold: true , color: AppColors . textColor , isEnglishOnly: true )
. toText16 ( isBold: true , color: AppColors . textColor , isEnglishOnly: true )
: SizedBox ( ) ,
: SizedBox ( ) ,
@ -115,10 +119,14 @@ class _SavedLogin extends State<SavedLogin> {
? Container (
? Container (
margin: EdgeInsets . all ( 16. h ) ,
margin: EdgeInsets . all ( 16. h ) ,
child: Utils . buildSvgWithAssets (
child: Utils . buildSvgWithAssets (
icon: ( isOther = = true & & loginType = = LoginTypeEnum . sms ) ? AppAssets . whatsapp : getTypeIcons ( appState . getSelectDeviceByImeiRespModelElement ! . logInType ! ) ,
icon: ( isOther = = true & & loginType = = LoginTypeEnum . sms )
? AppAssets . whatsapp
: getTypeIcons ( appState . getSelectDeviceByImeiRespModelElement ! . logInType ! ) ,
height: 54. h ,
height: 54. h ,
width: 54. w ,
width: 54. w ,
iconColor: ( isOther = = true & & loginType = = LoginTypeEnum . sms ) | | loginType . toInt = = 4 ? null : AppColors . primaryRedColor ) )
iconColor: ( isOther = = true & & loginType = = LoginTypeEnum . sms ) | | loginType . toInt = = 4
? null
: AppColors . primaryRedColor ) )
: SizedBox ( ) ,
: SizedBox ( ) ,
/ / Main login button - for isOther with SMS , show WhatsApp , otherwise keep original login type
/ / Main login button - for isOther with SMS , show WhatsApp , otherwise keep original login type
CustomButton (
CustomButton (
@ -126,7 +134,6 @@ class _SavedLogin extends State<SavedLogin> {
? " ${ LocaleKeys . loginBy . tr ( ) } ${ LoginTypeEnum . whatsapp . displayName } "
? " ${ LocaleKeys . loginBy . tr ( ) } ${ LoginTypeEnum . whatsapp . displayName } "
: " ${ LocaleKeys . loginBy . tr ( ) } ${ loginType . displayName } " ,
: " ${ LocaleKeys . loginBy . tr ( ) } ${ loginType . displayName } " ,
onPressed: ( ) {
onPressed: ( ) {
if ( loginType = = LoginTypeEnum . fingerprint | | loginType = = LoginTypeEnum . face ) {
if ( loginType = = LoginTypeEnum . fingerprint | | loginType = = LoginTypeEnum . face ) {
authVm . loginWithFingerPrintFace ( ( ) { } ) ;
authVm . loginWithFingerPrintFace ( ( ) { } ) ;
} else {
} else {
@ -147,7 +154,8 @@ class _SavedLogin extends State<SavedLogin> {
height: 40. h ,
height: 40. h ,
padding: EdgeInsets . symmetric ( vertical: 10. h ) ,
padding: EdgeInsets . symmetric ( vertical: 10. h ) ,
icon: ( isOther = = true & & loginType = = LoginTypeEnum . sms ) ? AppAssets . whatsapp : getTypeIcons ( loginType . toInt ) ,
icon: ( isOther = = true & & loginType = = LoginTypeEnum . sms ) ? AppAssets . whatsapp : getTypeIcons ( loginType . toInt ) ,
iconColor: ( isOther = = true & & loginType = = LoginTypeEnum . sms ) | | loginType = = LoginTypeEnum . whatsapp ? null : Colors . white ,
iconColor:
( isOther = = true & & loginType = = LoginTypeEnum . sms ) | | loginType = = LoginTypeEnum . whatsapp ? null : Colors . white ,
) ,
) ,
] ,
] ,
) ,
) ,
@ -159,120 +167,124 @@ class _SavedLogin extends State<SavedLogin> {
padding: EdgeInsets . symmetric ( horizontal: 16. w ) ,
padding: EdgeInsets . symmetric ( horizontal: 16. w ) ,
child: Text (
child: Text (
LocaleKeys . oR . tr ( ) ,
LocaleKeys . oR . tr ( ) ,
style: context . dynamicTextStyle ( fontSize: 16. f , fontWeight: FontWeight . w600 , ) ,
style: context . dynamicTextStyle (
fontSize: 16. f ,
fontWeight: FontWeight . w600 ,
) ,
) ,
) ,
) ,
) ,
SizedBox ( height: 24. h ) ,
SizedBox ( height: 24. h ) ,
/ / OTP login button
/ / OTP login button
loginType . toInt ! = 1
loginType . toInt ! = 1
? Column (
? Column (
children: [
children: [
loginType . toInt ! = 1
loginType . toInt ! = 1
? CustomButton (
? CustomButton (
text: LocaleKeys . loginByOTP . tr ( ) ,
text: LocaleKeys . loginByOTP . tr ( ) ,
onPressed: ( ) {
onPressed: ( ) {
showModalBottomSheet (
showModalBottomSheet (
context: context ,
context: context ,
isScrollControlled: true ,
isScrollControlled: true ,
isDismissible: false ,
isDismissible: false ,
useSafeArea: true ,
useSafeArea: true ,
backgroundColor: Colors . transparent ,
backgroundColor: Colors . transparent ,
enableDrag: false ,
enableDrag: false ,
/ / Prevent dragging to avoid focus conflicts
/ / Prevent dragging to avoid focus conflicts
builder: ( bottomSheetContext ) = >
builder: ( bottomSheetContext ) = >
StatefulBuilder ( builder: ( BuildContext context , StateSetter setModalState ) {
StatefulBuilder ( builder: ( BuildContext context , StateSetter setModalState ) {
return Padding (
return Padding (
padding: EdgeInsets . only ( bottom: MediaQuery . of ( bottomSheetContext ) . viewInsets . bottom ) ,
padding: EdgeInsets . only ( bottom: MediaQuery . of ( bottomSheetContext ) . viewInsets . bottom ) ,
child: SingleChildScrollView (
child: SingleChildScrollView (
child: GenericBottomSheet (
child: GenericBottomSheet (
countryCode: " 966 " ,
countryCode: " 966 " ,
initialPhoneNumber: " " ,
initialPhoneNumber: " " ,
textController: TextEditingController ( ) ,
textController: TextEditingController ( ) ,
isFromSavedLogin: true ,
isFromSavedLogin: true ,
isEnableCountryDropdown: true ,
isEnableCountryDropdown: true ,
onCountryChange: ( value ) { } ,
onCountryChange: ( value ) { } ,
onChange: ( String ? value ) { } ,
onChange: ( String ? value ) { } ,
buttons: [
buttons: [
Padding (
Padding (
padding: EdgeInsets . only ( bottom: 10. h ) ,
padding: EdgeInsets . only ( bottom: 10. h ) ,
child: CustomButton (
child: CustomButton (
text: LocaleKeys . sendOTPSMS . tr ( ) ,
text: LocaleKeys . sendOTPSMS . tr ( ) ,
onPressed: ( ) {
Navigator . of ( context ) . pop ( ) ;
loginType = LoginTypeEnum . sms ;
authVm . checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . sms ) ;
} ,
backgroundColor: AppColors . primaryRedColor ,
borderColor: AppColors . primaryRedColor ,
textColor: Colors . white ,
icon: AppAssets . sms ) ,
) ,
Row (
crossAxisAlignment: CrossAxisAlignment . center ,
mainAxisAlignment: MainAxisAlignment . center ,
children: [
Padding (
padding: EdgeInsets . symmetric ( horizontal: 8. h ) ,
child: ( LocaleKeys . oR . tr ( ) ) . toText16 ( color: AppColors . textColor ) ) ,
] ,
) ,
Padding (
padding: EdgeInsets . only ( bottom: 10. h , top: 10. h ) ,
child: CustomButton (
text: LocaleKeys . sendOTPWHATSAPP . tr ( ) ,
onPressed: ( ) {
onPressed: ( ) {
Navigator . of ( context ) . pop ( ) ;
Navigator . of ( context ) . pop ( ) ;
loginType = LoginTypeEnum . sms ;
loginType = LoginTypeEnum . whatsapp ;
authVm . checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . sms ) ;
authVm . checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . whatsapp ) ;
} ,
} ,
backgroundColor: AppColors . primaryRedColor ,
backgroundColor: AppColors . transparent ,
borderColor: AppColors . primaryRedColor ,
borderColor: AppColors . textColor ,
textColor: Colors . white ,
textColor: AppColors . textColor ,
icon: AppAssets . sms ) ,
icon: AppAssets . whatsapp ,
) ,
iconColor: null ,
Row (
applyThemeColor: false ,
crossAxisAlignment: CrossAxisAlignment . center ,
) ,
mainAxisAlignment: MainAxisAlignment . center ,
children: [
Padding (
padding: EdgeInsets . symmetric ( horizontal: 8. h ) ,
child: ( LocaleKeys . oR . tr ( ) ) . toText16 ( color: AppColors . textColor ) ) ,
] ,
) ,
Padding (
padding: EdgeInsets . only ( bottom: 10. h , top: 10. h ) ,
child: CustomButton (
text: LocaleKeys . sendOTPWHATSAPP . tr ( ) ,
onPressed: ( ) {
Navigator . of ( context ) . pop ( ) ;
loginType = LoginTypeEnum . whatsapp ;
authVm . checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . whatsapp ) ;
} ,
backgroundColor: AppColors . transparent ,
borderColor: AppColors . textColor ,
textColor: AppColors . textColor ,
icon: AppAssets . whatsapp ,
iconColor: null ,
applyThemeColor: false ,
) ,
) ,
) ,
] ,
] ,
) ,
) ,
) ,
) ,
) ;
);
} ) ,
}) ,
) ;
);
} ,
} ,
height: isFoldable ? 50. h : 40. h ,
backgroundColor: AppColors . whiteColor ,
backgroundColor: AppColors . whiteColor ,
borderColor: AppColors . borderOnlyColor ,
borderColor: AppColors . borderOnlyColor ,
textColor: AppColors . textColor ,
textColor: AppColors . textColor ,
borderWidth: 2 ,
borderWidth: 2 ,
padding: EdgeInsets . fromLTRB ( 0 , 14. h , 0 , 14. h ) ,
padding: EdgeInsets . fromLTRB ( 0 , 14. h , 0 , 14. h ) ,
icon: AppAssets . sms ,
icon: AppAssets . sms ,
iconColor: AppColors . textColor ,
iconColor: AppColors . textColor ,
)
)
: Container ( ) ,
: Container ( ) ,
SizedBox (
SizedBox (
height: 20. h ,
height: 20. h ,
) ,
) ,
] ,
] ,
)
)
: CustomButton (
: CustomButton (
text: " ${ LocaleKeys . loginBy . tr ( ) } ${ LoginTypeEnum . whatsapp . displayName } " ,
text: " ${ LocaleKeys . loginBy . tr ( ) } ${ LoginTypeEnum . whatsapp . displayName } " ,
icon: AppAssets . whatsapp ,
icon: AppAssets . whatsapp ,
iconColor: null ,
iconColor: null ,
onPressed: ( ) {
onPressed: ( ) {
if ( loginType = = LoginTypeEnum . fingerprint | | loginType = = LoginTypeEnum . face ) {
if ( loginType = = LoginTypeEnum . fingerprint | | loginType = = LoginTypeEnum . face ) {
authVm . loginWithFingerPrintFace ( ( ) { } ) ;
authVm . loginWithFingerPrintFace ( ( ) { } ) ;
} else {
} else {
loginType = LoginTypeEnum . whatsapp ;
loginType = LoginTypeEnum . whatsapp ;
authVm . checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . whatsapp ) ;
authVm . checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . whatsapp ) ;
}
}
} ,
} ,
backgroundColor: AppColors . whiteColor ,
backgroundColor: AppColors . whiteColor ,
borderColor: AppColors . textColor ,
borderColor: AppColors . textColor ,
textColor: AppColors . textColor ,
textColor: AppColors . textColor ,
borderWidth: 2. w ,
borderWidth: 2. w ,
padding: EdgeInsets . fromLTRB ( 0 , 14. h , 0 , 14. h ) ,
padding: EdgeInsets . fromLTRB ( 0 , 14. h , 0 , 14. h ) ,
applyThemeColor: false ,
applyThemeColor: false ,
) ,
) ,
] ,
] ,
const Spacer ( flex: 2 ) ,
const Spacer ( flex: 2 ) ,
@ -294,7 +306,7 @@ class _SavedLogin extends State<SavedLogin> {
CustomPageRoute (
CustomPageRoute (
page: LandingNavigation ( ) ,
page: LandingNavigation ( ) ,
) ,
) ,
( r ) = > false ) ;
( r ) = > false ) ;
/ / Navigator . of ( context ) . pushAndRemoveUntil (
/ / Navigator . of ( context ) . pushAndRemoveUntil (
/ / MaterialPageRoute ( builder: ( BuildContext context ) = > LandingNavigation ( ) )
/ / MaterialPageRoute ( builder: ( BuildContext context ) = > LandingNavigation ( ) )
/ / ) ;
/ / ) ;