pull/8/head
aamir-csol 2 months ago
parent 23a4035117
commit d1e1154bdb

@ -13,6 +13,7 @@ import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/services/dialog_service.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/dialogs/confirm_dialog.dart';
@ -66,7 +67,6 @@ class Utils {
hours: isAddHours ? 3 : 0,
),
));
;
}
static String convertStringToDateTime(String dateTimeString) {
@ -236,7 +236,8 @@ class Utils {
showDialog(
barrierDismissible: false,
context: context,
builder: (cxt) => ConfirmDialog(
builder: (cxt) =>
ConfirmDialog(
title: title!,
message: message!,
onTap: onTap,
@ -371,7 +372,9 @@ class Utils {
static String formatHijriDateToDisplay(String hijriDateString) {
try {
// Assuming hijriDateString is in the format yyyy-MM-dd
final datePart = hijriDateString.split("T").first;
final datePart = hijriDateString
.split("T")
.first;
final parts = datePart.split('-');
if (parts.length != 3) return "";
@ -429,8 +432,14 @@ class Utils {
void Function(LottieComposition)? onLoaded,
}) {
return Lottie.asset(assetPath,
height: height ?? MediaQuery.of(context).size.height * 0.26,
width: width ?? MediaQuery.of(context).size.width,
height: height ?? MediaQuery
.of(context)
.size
.height * 0.26,
width: width ?? MediaQuery
.of(context)
.size
.width,
fit: fit,
alignment: alignment,
repeat: repeat,
@ -487,9 +496,13 @@ class Utils {
],
);
}
static Future<bool> isGoogleServicesAvailable() async {
GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability();
String status = availability.toString().split('.').last;
String status = availability
.toString()
.split('.')
.last;
if (status == "success") {
return true;
}
@ -510,3 +523,26 @@ class Utils {
return crypto.md5.convert(utf8.encode(input)).toString();
}
}
class ValidationUtils {
static DialogService dialogService = getIt.get<DialogService>();
static bool isValidatePhoneAndId({
String? nationalId,
String? phoneNumber
}) {
if (nationalId == null || nationalId.isEmpty) {
dialogService.showErrorDialog(message: "Please enter a valid national ID or file number", onOkPressed: () {});
return false;
}
if (phoneNumber == null || phoneNumber.isEmpty) {
dialogService.showErrorDialog(message: "Please enter a valid phone number", onOkPressed: () {});
return false;
}
return true;
}
}

@ -240,6 +240,8 @@ extension EmailValidator on String {
style: TextStyle(height: 47 / 36, color: color ?? AppColors.blackColor, fontSize: 36.fSize, letterSpacing: -1, fontWeight: isBold ? FontWeight.w600 : FontWeight.normal),
);
Widget toText44({Color? color, bool isBold = false}) => Text(
this,
style: TextStyle(height: 32 / 32, color: color ?? AppColors.blackColor, fontSize: 44.fSize, letterSpacing: -0.4, fontWeight: isBold ? FontWeight.bold : FontWeight.normal),
@ -381,53 +383,55 @@ class FontUtils {
}
}
extension CountryExtension on Country {
extension CountryExtension on CountryEnum {
String get displayName {
switch (this) {
case Country.saudiArabia:
case CountryEnum.saudiArabia:
return "Kingdom Of Saudi Arabia";
case Country.unitedArabEmirates:
case CountryEnum.unitedArabEmirates:
return "United Arab Emirates";
}
}
String get nameArabic {
switch (this) {
case Country.saudiArabia:
case CountryEnum.saudiArabia:
return "المملكة العربية السعودية";
case Country.unitedArabEmirates:
case CountryEnum.unitedArabEmirates:
return "الإمارات العربية المتحدة";
}
}
String get iconPath {
switch (this) {
case Country.saudiArabia:
case CountryEnum.saudiArabia:
return AppAssets.ksa;
case Country.unitedArabEmirates:
case CountryEnum.unitedArabEmirates:
return AppAssets.uae;
}
}
String get countryCode {
switch (this) {
case Country.saudiArabia:
case CountryEnum.saudiArabia:
return "966";
case Country.unitedArabEmirates:
case CountryEnum.unitedArabEmirates:
return "971";
}
}
static Country fromDisplayName(String name) {
static CountryEnum fromDisplayName(String name) {
switch (name) {
case "Kingdom Of Saudi Arabia":
case "المملكة العربية السعودية":
return Country.saudiArabia;
return CountryEnum.saudiArabia;
case "United Arab Emirates":
case "الإمارات العربية المتحدة":
return Country.unitedArabEmirates;
return CountryEnum.unitedArabEmirates;
default:
throw Exception("Invalid country name");
}
}
}

@ -20,8 +20,7 @@ abstract class AuthenticationRepo {
required CheckPatientAuthenticationReq checkPatientAuthenticationReq,
});
Future<Either<Failure, GenericApiModel<dynamic>>> sendActivationCodeRegister(
{required CheckPatientAuthenticationReq checkPatientAuthenticationReq, String? languageID});
Future<Either<Failure, GenericApiModel<dynamic>>> sendActivationCodeRegister({required CheckPatientAuthenticationReq checkPatientAuthenticationReq, String? languageID});
}
class AuthenticationRepoImp implements AuthenticationRepo {
@ -114,8 +113,7 @@ class AuthenticationRepoImp implements AuthenticationRepo {
}
@override
Future<Either<Failure, GenericApiModel<dynamic>>> sendActivationCodeRegister(
{required CheckPatientAuthenticationReq checkPatientAuthenticationReq, String? languageID}) async {
Future<Either<Failure, GenericApiModel<dynamic>>> sendActivationCodeRegister({required CheckPatientAuthenticationReq checkPatientAuthenticationReq, String? languageID}) async {
int isOutKsa = (checkPatientAuthenticationReq.zipCode == '966' || checkPatientAuthenticationReq.zipCode == '+966') ? 0 : 1;
//TODO : We will use all these from AppState directly in the ApiClient

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/utils/request_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart';
import 'package:hmg_patient_app_new/features/authentication/models/request_models/check_patient_authentication_request_model.dart';
import 'package:hmg_patient_app_new/services/dialog_service.dart';
@ -23,9 +24,15 @@ class AuthenticationViewModel extends ChangeNotifier {
final TextEditingController nationalIdController = TextEditingController();
final TextEditingController phoneNumberController = TextEditingController();
void login() {
if (ValidationUtils.isValidatePhoneAndId(nationalId: nationalIdController.text, phoneNumber: phoneNumberController.text)) {
} else {
}
}
Future<void> selectDeviceImei({Function(dynamic)? onSuccess, Function(String)? onError}) async {
String firebaseToken =
"dOGRRszQQMGe_9wA5Hx3kO:APA91bFV5IcIJXvcCXXk0tc2ddtZgWwCPq7sGSuPr-YW7iiJpQZKgFGN9GAzCVOWL8MfheaP1slE8MdxB7lczdPBGdONQ7WbMmhgHcsUCUktq-hsapGXXqc";
String firebaseToken = "dOGRRszQQMGe_9wA5Hx3kO:APA91bFV5IcIJXvcCXXk0tc2ddtZgWwCPq7sGSuPr-YW7iiJpQZKgFGN9GAzCVOWL8MfheaP1slE8MdxB7lczdPBGdONQ7WbMmhgHcsUCUktq-hsapGXXqc";
final result = await authenticationRepo.selectDeviceByImei(firebaseToken: firebaseToken);
result.fold(

@ -7,6 +7,7 @@ import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/context_extensions.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/authentication/register.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
@ -14,6 +15,7 @@ import 'package:hmg_patient_app_new/widgets/appbar/app_bar_widget.dart';
import 'package:hmg_patient_app_new/widgets/bottomsheet/generic_bottom_sheet.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/input_widget.dart';
import 'package:provider/provider.dart';
class LoginScreen extends StatefulWidget {
@override
@ -33,6 +35,7 @@ class _LoginScreen extends State<LoginScreen> {
@override
Widget build(BuildContext context) {
AuthenticationViewModel authVm = context.read<AuthenticationViewModel>();
return Scaffold(
backgroundColor: AppColors.bgScaffoldColor,
appBar: CustomAppBar(
@ -61,7 +64,7 @@ class _LoginScreen extends State<LoginScreen> {
TextInputWidget(
labelText: "${LocaleKeys.nationalId.tr()} / ${LocaleKeys.fileNo.tr()}",
hintText: "xxxxxxxxx",
controller: TextEditingController(),
controller: authVm.nationalIdController,
keyboardType: TextInputType.number,
isEnable: true,
prefix: null,
@ -80,7 +83,7 @@ class _LoginScreen extends State<LoginScreen> {
icon: AppAssets.login1,
iconColor: Colors.white,
onPressed: () {
showLoginModel(context: context);
showLoginModel(context: context, textController: authVm.phoneNumberController);
// if (nationIdController.text.isNotEmpty) {
// } else {
@ -150,7 +153,7 @@ class _LoginScreen extends State<LoginScreen> {
child: GenericBottomSheet(
countryCode: "966",
initialPhoneNumber: "",
textController: TextEditingController(),
textController: textController,
isEnableCountryDropdown: true,
onCountryChange: (value) {},
onChange: (String? value) {},

@ -85,8 +85,8 @@ class _RegisterNew extends State<RegisterNew> {
child: Column(
children: [
CustomCountryDropdown(
countryList: Country.values,
onCountryChange: (Country? value) {},
countryList: CountryEnum.values,
onCountryChange: (CountryEnum? value) {},
isRtl: Directionality.of(context) == TextDirection.LTR,
).withVerticalPadding(8.h),
Divider(height: 1.h),

@ -51,7 +51,9 @@ class _LandingPageState extends State<LandingPage> {
CustomButton(
text: LocaleKeys.loginOrRegister.tr(context: context),
onPressed: () async {
await authenticationViewModel.selectDeviceImei();
// await authenticationViewModel.selectDeviceImei();
Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => LoginScreen()));
},
backgroundColor: Color(0xffFEE9EA),
borderColor: Color(0xffFEE9EA),

@ -40,7 +40,6 @@ class MedicalFilePage extends StatelessWidget {
isAllowLeadingIcon: true,
padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 8.h),
leadingIcon: AppAssets.student_card,
hasError: true,
),
SizedBox(height: 16.h),
Container(

@ -17,7 +17,7 @@ class GenericBottomSheet extends StatefulWidget {
final List<Widget> buttons;
TextEditingController? textController;
final bool isForEmail;
Function(Country)? onCountryChange;
Function(CountryEnum)? onCountryChange;
final bool isEnableCountryDropdown;
final bool isFromSavedLogin;
Function(String?)? onChange;

@ -7,8 +7,8 @@ import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
class CustomCountryDropdown extends StatefulWidget {
final List<Country> countryList;
final Function(Country)? onCountryChange;
final List<CountryEnum> countryList;
final Function(CountryEnum)? onCountryChange;
final bool isRtl;
const CustomCountryDropdown({
@ -23,14 +23,14 @@ class CustomCountryDropdown extends StatefulWidget {
}
class _CustomCountryDropdownState extends State<CustomCountryDropdown> {
Country? selectedCountry;
CountryEnum? selectedCountry;
late OverlayEntry _overlayEntry;
bool _isDropdownOpen = false;
@override
void initState() {
super.initState();
selectedCountry = Country.saudiArabia;
selectedCountry = CountryEnum.saudiArabia;
}
@override

Loading…
Cancel
Save