@ -1,3 +1,5 @@
import ' dart:ui ' as ui ;
import ' package:easy_localization/easy_localization.dart ' ;
import ' package:flutter/material.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/routes/custom_page_route.dart ' ;
import ' package:provider/provider.dart ' ;
import ' dart:ui ' as ui ;
class SavedLogin extends StatefulWidget {
const SavedLogin ( { super . key } ) ;
@ -33,6 +34,7 @@ class _SavedLogin extends State<SavedLogin> {
late AuthenticationViewModel authVm ;
late AppState appState ;
bool ? isOther ;
@ override
void initState ( ) {
authVm = context . read < AuthenticationViewModel > ( ) ;
@ -90,11 +92,11 @@ class _SavedLogin extends State<SavedLogin> {
: SizedBox ( ) ,
SizedBox ( height: 24. h ) ,
Container (
padding: EdgeInsets . all ( 16. h ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration ( color: AppColors . whiteColor , borderRadius: 20. h , hasShadow: false , isCustomShadow: [
BoxShadow ( color: Color ( 0x0D000000 ) , blurRadius: 16. h , offset: Offset ( 0 , 0 ) , spreadRadius: 5. h ) ,
] ) ,
decoration: RoundedRectangleBorder ( )
. 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 (
children: [
/ / 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 ,
child: appState . getSelectDeviceByImeiRespModelElement ! = 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 )
: SizedBox ( ) ,
@ -115,10 +119,14 @@ class _SavedLogin extends State<SavedLogin> {
? Container (
margin: EdgeInsets . all ( 16. h ) ,
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 ,
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 ( ) ,
/ / Main login button - for isOther with SMS , show WhatsApp , otherwise keep original login type
CustomButton (
@ -126,7 +134,6 @@ class _SavedLogin extends State<SavedLogin> {
? " ${ LocaleKeys . loginBy . tr ( ) } ${ LoginTypeEnum . whatsapp . displayName } "
: " ${ LocaleKeys . loginBy . tr ( ) } ${ loginType . displayName } " ,
onPressed: ( ) {
if ( loginType = = LoginTypeEnum . fingerprint | | loginType = = LoginTypeEnum . face ) {
authVm . loginWithFingerPrintFace ( ( ) { } ) ;
} else {
@ -147,7 +154,8 @@ class _SavedLogin extends State<SavedLogin> {
height: 40. h ,
padding: EdgeInsets . symmetric ( vertical: 10. h ) ,
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 ) ,
child: Text (
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 ) ,
/ / OTP login button
loginType . toInt ! = 1
? Column (
children: [
loginType . toInt ! = 1
? CustomButton (
text: LocaleKeys . loginByOTP . tr ( ) ,
onPressed: ( ) {
showModalBottomSheet (
context: context ,
isScrollControlled: true ,
isDismissible: false ,
useSafeArea: true ,
backgroundColor: Colors . transparent ,
enableDrag: false ,
/ / Prevent dragging to avoid focus conflicts
builder: ( bottomSheetContext ) = >
StatefulBuilder ( builder: ( BuildContext context , StateSetter setModalState ) {
return Padding (
padding: EdgeInsets . only ( bottom: MediaQuery . of ( bottomSheetContext ) . viewInsets . bottom ) ,
child: SingleChildScrollView (
child: GenericBottomSheet (
countryCode: " 966 " ,
initialPhoneNumber: " " ,
textController: TextEditingController ( ) ,
isFromSavedLogin: true ,
isEnableCountryDropdown: true ,
onCountryChange: ( value ) { } ,
onChange: ( String ? value ) { } ,
buttons: [
Padding (
padding: EdgeInsets . only ( bottom: 10. h ) ,
child: CustomButton (
text: LocaleKeys . sendOTPSMS . tr ( ) ,
? Column (
children: [
loginType . toInt ! = 1
? CustomButton (
text: LocaleKeys . loginByOTP . tr ( ) ,
onPressed: ( ) {
showModalBottomSheet (
context: context ,
isScrollControlled: true ,
isDismissible: false ,
useSafeArea: true ,
backgroundColor: Colors . transparent ,
enableDrag: false ,
/ / Prevent dragging to avoid focus conflicts
builder: ( bottomSheetContext ) = >
StatefulBuilder ( builder: ( BuildContext context , StateSetter setModalState ) {
return Padding (
padding: EdgeInsets . only ( bottom: MediaQuery . of ( bottomSheetContext ) . viewInsets . bottom ) ,
child: SingleChildScrollView (
child: GenericBottomSheet (
countryCode: " 966 " ,
initialPhoneNumber: " " ,
textController: TextEditingController ( ) ,
isFromSavedLogin: true ,
isEnableCountryDropdown: true ,
onCountryChange: ( value ) { } ,
onChange: ( String ? value ) { } ,
buttons: [
Padding (
padding: EdgeInsets . only ( bottom: 10. h ) ,
child: CustomButton (
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: ( ) {
Navigator . of ( context ) . pop ( ) ;
loginType = LoginTypeEnum . sms ;
authVm . checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . sms ) ;
loginType = LoginTypeEnum . whatsapp ;
authVm . checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . whatsapp ) ;
} ,
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: ( ) {
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 ,
backgroundColor: AppColors . transparent ,
borderColor: AppColors . textColor ,
textColor: AppColors . textColor ,
icon: AppAssets . whatsapp ,
iconColor: null ,
applyThemeColor: false ,
) ,
) ,
) ,
] ,
] ,
) ,
) ,
) ,
);
}) ,
);
} ,
backgroundColor: AppColors . whiteColor ,
borderColor: AppColors . borderOnlyColor ,
textColor: AppColors . textColor ,
borderWidth: 2 ,
padding: EdgeInsets . fromLTRB ( 0 , 14. h , 0 , 14. h ) ,
icon: AppAssets . sms ,
iconColor: AppColors . textColor ,
)
: Container ( ) ,
SizedBox (
height: 20. h ,
) ,
] ,
)
: CustomButton (
text: " ${ LocaleKeys . loginBy . tr ( ) } ${ LoginTypeEnum . whatsapp . displayName } " ,
icon: AppAssets . whatsapp ,
iconColor: null ,
onPressed: ( ) {
if ( loginType = = LoginTypeEnum . fingerprint | | loginType = = LoginTypeEnum . face ) {
authVm . loginWithFingerPrintFace ( ( ) { } ) ;
} else {
loginType = LoginTypeEnum . whatsapp ;
authVm . checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . whatsapp ) ;
}
} ,
backgroundColor: AppColors . whiteColor ,
borderColor: AppColors . textColor ,
textColor: AppColors . textColor ,
borderWidth: 2. w ,
padding: EdgeInsets . fromLTRB ( 0 , 14. h , 0 , 14. h ) ,
applyThemeColor: false ,
) ,
) ;
} ) ,
) ;
} ,
height: isFoldable ? 50. h : 40. h ,
backgroundColor: AppColors . whiteColor ,
borderColor: AppColors . borderOnlyColor ,
textColor: AppColors . textColor ,
borderWidth: 2 ,
padding: EdgeInsets . fromLTRB ( 0 , 14. h , 0 , 14. h ) ,
icon: AppAssets . sms ,
iconColor: AppColors . textColor ,
)
: Container ( ) ,
SizedBox (
height: 20. h ,
) ,
] ,
)
: CustomButton (
text: " ${ LocaleKeys . loginBy . tr ( ) } ${ LoginTypeEnum . whatsapp . displayName } " ,
icon: AppAssets . whatsapp ,
iconColor: null ,
onPressed: ( ) {
if ( loginType = = LoginTypeEnum . fingerprint | | loginType = = LoginTypeEnum . face ) {
authVm . loginWithFingerPrintFace ( ( ) { } ) ;
} else {
loginType = LoginTypeEnum . whatsapp ;
authVm . checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . whatsapp ) ;
}
} ,
backgroundColor: AppColors . whiteColor ,
borderColor: AppColors . textColor ,
textColor: AppColors . textColor ,
borderWidth: 2. w ,
padding: EdgeInsets . fromLTRB ( 0 , 14. h , 0 , 14. h ) ,
applyThemeColor: false ,
) ,
] ,
const Spacer ( flex: 2 ) ,
@ -294,7 +306,7 @@ class _SavedLogin extends State<SavedLogin> {
CustomPageRoute (
page: LandingNavigation ( ) ,
) ,
( r ) = > false ) ;
( r ) = > false ) ;
/ / Navigator . of ( context ) . pushAndRemoveUntil (
/ / MaterialPageRoute ( builder: ( BuildContext context ) = > LandingNavigation ( ) )
/ / ) ;