pull/8/head
aamir-csol 2 months ago
parent 0309299f44
commit e41ffd583d

@ -23,13 +23,28 @@ class AuthenticationViewModel extends ChangeNotifier {
final TextEditingController nationalIdController = TextEditingController(); final TextEditingController nationalIdController = TextEditingController();
final TextEditingController phoneNumberController = TextEditingController(); final TextEditingController phoneNumberController = TextEditingController();
CountryEnum selectedCountry = CountryEnum.saudiArabia;
bool isTermsAccepted = false;
void login() { void login() {
if (ValidationUtils.isValidatePhoneAndId(nationalId: nationalIdController.text, phoneNumber: phoneNumberController.text)) { if (ValidationUtils.isValidatePhoneAndId(nationalId: nationalIdController.text, phoneNumber: phoneNumberController.text)) {
} else {} } else {}
} }
void onCountryChange(CountryEnum country) {
selectedCountry = country;
notifyListeners();
}
void onPhoneNumberChange(String? phoneNumber) {
phoneNumberController.text = phoneNumber!;
}
void onTermAccepted() {
isTermsAccepted = !isTermsAccepted;
notifyListeners();
}
Future<void> selectDeviceImei({Function(dynamic)? onSuccess, Function(String)? onError}) async { 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); final result = await authenticationRepo.selectDeviceByImei(firebaseToken: firebaseToken);

@ -83,7 +83,7 @@ class _LoginScreen extends State<LoginScreen> {
icon: AppAssets.login1, icon: AppAssets.login1,
iconColor: Colors.white, iconColor: Colors.white,
onPressed: () { onPressed: () {
showLoginModel(context: context, textController: authVm.phoneNumberController); showLoginModel(context: context, authVM: authVm);
// if (nationIdController.text.isNotEmpty) { // if (nationIdController.text.isNotEmpty) {
// } else { // } else {
@ -140,7 +140,7 @@ class _LoginScreen extends State<LoginScreen> {
); );
} }
void showLoginModel({required BuildContext context, TextEditingController? textController}) { void showLoginModel({required BuildContext context, required AuthenticationViewModel authVM}) {
context.showBottomSheet( context.showBottomSheet(
isScrollControlled: true, isScrollControlled: true,
isDismissible: false, isDismissible: false,
@ -151,12 +151,12 @@ class _LoginScreen extends State<LoginScreen> {
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: SingleChildScrollView( child: SingleChildScrollView(
child: GenericBottomSheet( child: GenericBottomSheet(
countryCode: "966", countryCode: authVM.selectedCountry.countryCode,
initialPhoneNumber: "", initialPhoneNumber: "",
textController: textController, textController: authVM.phoneNumberController,
isEnableCountryDropdown: true, isEnableCountryDropdown: true,
onCountryChange: (value) {}, onCountryChange: authVM.onCountryChange,
onChange: (String? value) {}, onChange: authVM.onPhoneNumberChange,
buttons: [ buttons: [
Padding( Padding(
padding: EdgeInsets.only(bottom: 10.h), padding: EdgeInsets.only(bottom: 10.h),

@ -9,6 +9,7 @@ import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_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/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/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/appbar/app_bar_widget.dart'; import 'package:hmg_patient_app_new/widgets/appbar/app_bar_widget.dart';
@ -18,6 +19,7 @@ import 'package:hmg_patient_app_new/widgets/dropdown/country_dropdown_widget.dar
import 'package:hmg_patient_app_new/widgets/dropdown/dropdown_widget.dart'; import 'package:hmg_patient_app_new/widgets/dropdown/dropdown_widget.dart';
import 'package:hmg_patient_app_new/widgets/input_widget.dart'; import 'package:hmg_patient_app_new/widgets/input_widget.dart';
import 'package:hmg_patient_app_new/widgets/otp/otp.dart'; import 'package:hmg_patient_app_new/widgets/otp/otp.dart';
import 'package:provider/provider.dart';
class RegisterNew extends StatefulWidget { class RegisterNew extends StatefulWidget {
@override @override
@ -25,8 +27,6 @@ class RegisterNew extends StatefulWidget {
} }
class _RegisterNew extends State<RegisterNew> { class _RegisterNew extends State<RegisterNew> {
bool isTermsAccepted = true;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -40,6 +40,8 @@ class _RegisterNew extends State<RegisterNew> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
AppState appState = getIt.get<AppState>(); AppState appState = getIt.get<AppState>();
AuthenticationViewModel authVm = context.read<AuthenticationViewModel>();
return Scaffold( return Scaffold(
backgroundColor: AppColors.bgScaffoldColor, backgroundColor: AppColors.bgScaffoldColor,
appBar: CustomAppBar( appBar: CustomAppBar(
@ -68,12 +70,7 @@ class _RegisterNew extends State<RegisterNew> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Utils.showLottie(context: context, Utils.showLottie(context: context, assetPath: 'assets/animations/lottie/register.json', width: 200.h, height: 200.h, fit: BoxFit.cover, repeat: true),
assetPath: 'assets/animations/lottie/register.json',
width: 200.h,
height: 200.h,
fit: BoxFit.cover,
repeat: true),
SizedBox(height: 16.h), SizedBox(height: 16.h),
LocaleKeys.prepareToElevate.tr().toText32(isBold: true), LocaleKeys.prepareToElevate.tr().toText32(isBold: true),
SizedBox(height: 24.h), SizedBox(height: 24.h),
@ -125,22 +122,25 @@ class _RegisterNew extends State<RegisterNew> {
), ),
SizedBox(height: 25.h), SizedBox(height: 25.h),
GestureDetector( GestureDetector(
onTap: () {}, onTap: authVm.onTermAccepted,
child: Row( child: Row(
children: [ children: [
AnimatedContainer( Selector<AuthenticationViewModel, bool>(
selector: (_, viewModel) => viewModel.isTermsAccepted,
shouldRebuild: (previous, next) => previous != next,
builder: (context, isTermsAccepted, child) {
return AnimatedContainer(
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
height: 24.h, height: 24.h,
width: 24.h, width: 24.h,
decoration: BoxDecoration( decoration: BoxDecoration(
color: isTermsAccepted ? const Color(0xFFE92227) : Colors.transparent, color: isTermsAccepted ? AppColors.primaryRedColor : Colors.transparent,
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
border: Border.all( border: Border.all(color: isTermsAccepted ? AppColors.primaryRedBorderColor : AppColors.greyColor, width: 2.h),
color: isTermsAccepted ? const Color(0xFFE92227) : Colors.grey,
width: 2.h,
),
), ),
child: isTermsAccepted ? Icon(Icons.check, size: 16.fSize, color: Colors.white) : null, child: isTermsAccepted ? Icon(Icons.check, size: 16.fSize, color: Colors.white) : null,
);
},
), ),
SizedBox(width: 12.h), SizedBox(width: 12.h),
Expanded( Expanded(
@ -157,7 +157,7 @@ class _RegisterNew extends State<RegisterNew> {
text: "Register", text: "Register",
icon: AppAssets.note_edit, icon: AppAssets.note_edit,
onPressed: () { onPressed: () {
showRegisterModel(context: context); showRegisterModel(context: context, authVM: authVm);
}, },
), ),
SizedBox(height: 14), SizedBox(height: 14),
@ -200,35 +200,33 @@ class _RegisterNew extends State<RegisterNew> {
)); ));
} }
void showRegisterModel({required BuildContext context, TextEditingController? textController}) { void showRegisterModel({required BuildContext context, required AuthenticationViewModel authVM}) {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
isDismissible: false, isDismissible: false,
useSafeArea: true, useSafeArea: true,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
builder: (bottomSheetContext) => builder: (bottomSheetContext) => Padding(
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: authVM.selectedCountry.countryCode,
initialPhoneNumber: "", initialPhoneNumber: "",
textController: TextEditingController(), textController: authVM.phoneNumberController,
isEnableCountryDropdown: true, isEnableCountryDropdown: true,
onChange: (String? value) {}, onCountryChange: authVM.onCountryChange,
onChange: authVM.onPhoneNumberChange,
buttons: [ buttons: [
Padding( Padding(
padding: const EdgeInsets.only(bottom: 10), padding: const EdgeInsets.only(bottom: 10),
child: CustomButton( child: CustomButton(
text: LocaleKeys.sendOTPSMS.tr(), text: LocaleKeys.sendOTPSMS.tr(),
onPressed: () { onPressed: () {
Navigator.of(context).push( Navigator.of(context).push(MaterialPageRoute(
MaterialPageRoute(builder: (BuildContext context) => OTPVerificationPage(phoneNumber: '12234567',))); builder: (BuildContext context) => OTPVerificationPage(
phoneNumber: '12234567',
)));
// if (mobileNo.isEmpty) { // if (mobileNo.isEmpty) {
// context.showBottomSheet( // context.showBottomSheet(

@ -53,8 +53,11 @@ class _RegisterNew extends State<RegisterNewStep2> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: CustomAppBar(
appBar: CustomAppBar(onBackPressed: () {}, onLanguageChanged: (lang) {}, hideLogoAndLang: true,), onBackPressed: () {},
onLanguageChanged: (lang) {},
hideLogoAndLang: true,
),
body: SingleChildScrollView( body: SingleChildScrollView(
reverse: false, reverse: false,
padding: EdgeInsets.only(left: 24.h, right: 24.h, top: 24.h), padding: EdgeInsets.only(left: 24.h, right: 24.h, top: 24.h),
@ -79,8 +82,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
isAllowLeadingIcon: true, isAllowLeadingIcon: true,
isReadOnly: isFromDubai ? false : true, isReadOnly: isFromDubai ? false : true,
leadingIcon: AppAssets.user_circle).paddingSymmetrical(0.h,16.h), leadingIcon: AppAssets.user_circle)
Divider(height: 1, color: AppColors.greyColor,), .paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
TextInputWidget( TextInputWidget(
labelText: LocaleKeys.nationalIdNumber.tr(), labelText: LocaleKeys.nationalIdNumber.tr(),
hintText: isFromDubai ? "widget.payload.nationalID!" : (widget.nHICData!.idNumber ?? ""), hintText: isFromDubai ? "widget.payload.nationalID!" : (widget.nHICData!.idNumber ?? ""),
@ -91,8 +98,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
isBorderAllowed: false, isBorderAllowed: false,
isAllowLeadingIcon: true, isAllowLeadingIcon: true,
isReadOnly: true, isReadOnly: true,
leadingIcon: AppAssets.student_card).paddingSymmetrical(0.h,16.h), leadingIcon: AppAssets.student_card)
Divider(height: 1, color: AppColors.greyColor,), .paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
isFromDubai isFromDubai
? DropdownWidget( ? DropdownWidget(
labelText: LocaleKeys.gender.tr(), labelText: LocaleKeys.gender.tr(),
@ -122,9 +133,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
isAllowLeadingIcon: true, isAllowLeadingIcon: true,
isReadOnly: isFromDubai ? false : true, isReadOnly: isFromDubai ? false : true,
leadingIcon: AppAssets.user_full, leadingIcon: AppAssets.user_full,
onChange: (value) {})
onChange: (value) {}).paddingSymmetrical(0.h,16.h), .paddingSymmetrical(0.h, 16.h),
Divider(height: 1, color: AppColors.greyColor,), Divider(
height: 1,
color: AppColors.greyColor,
),
isFromDubai isFromDubai
? DropdownWidget( ? DropdownWidget(
labelText: LocaleKeys.maritalStatus.tr(), labelText: LocaleKeys.maritalStatus.tr(),
@ -152,8 +166,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
isAllowLeadingIcon: true, isAllowLeadingIcon: true,
isReadOnly: true, isReadOnly: true,
leadingIcon: AppAssets.smart_phone, leadingIcon: AppAssets.smart_phone,
onChange: (value) {}).paddingSymmetrical(0.h,16.h), onChange: (value) {})
Divider(height: 1, color: AppColors.greyColor,), .paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
isFromDubai isFromDubai
? DropdownWidget( ? DropdownWidget(
labelText: LocaleKeys.country.tr(), labelText: LocaleKeys.country.tr(),
@ -181,8 +199,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
isAllowLeadingIcon: true, isAllowLeadingIcon: true,
isReadOnly: true, isReadOnly: true,
leadingIcon: AppAssets.globe, leadingIcon: AppAssets.globe,
onChange: (value) {}).paddingSymmetrical(0.h,16.h), onChange: (value) {})
Divider(height: 1, color: AppColors.greyColor,), .paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
TextInputWidget( TextInputWidget(
labelText: LocaleKeys.mobileNumber.tr(), labelText: LocaleKeys.mobileNumber.tr(),
hintText: ("widget.payload.mobileNo" ?? ""), hintText: ("widget.payload.mobileNo" ?? ""),
@ -194,8 +216,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
isAllowLeadingIcon: true, isAllowLeadingIcon: true,
isReadOnly: true, isReadOnly: true,
leadingIcon: AppAssets.call, leadingIcon: AppAssets.call,
onChange: (value) {}).paddingSymmetrical(0.h,16.h), onChange: (value) {})
Divider(height: 1, color: AppColors.greyColor,), .paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
TextInputWidget( TextInputWidget(
labelText: LocaleKeys.dob.tr(), labelText: LocaleKeys.dob.tr(),
hintText: isFromDubai ? "widget.payload.dob!" : (widget.nHICData!.dateOfBirth ?? ""), hintText: isFromDubai ? "widget.payload.dob!" : (widget.nHICData!.dateOfBirth ?? ""),
@ -209,7 +235,8 @@ class _RegisterNew extends State<RegisterNewStep2> {
// selectedValue: widget.payload.dob != null ? Utils.formatDateToDisplay(widget.payload.dob.toString()) : null, // selectedValue: widget.payload.dob != null ? Utils.formatDateToDisplay(widget.payload.dob.toString()) : null,
// selectionCustomIcon: AppAssets.calendar, // selectionCustomIcon: AppAssets.calendar,
leadingIcon: AppAssets.birthday_cake, leadingIcon: AppAssets.birthday_cake,
onChange: (value) {}).paddingSymmetrical(0.h,16.h), onChange: (value) {})
.paddingSymmetrical(0.h, 16.h),
], ],
), ),
), ),

@ -46,8 +46,8 @@ class _GenericBottomSheetState extends State<GenericBottomSheet> {
void initState() { void initState() {
super.initState(); super.initState();
if (!widget.isForEmail) { if (!widget.isForEmail && widget.textController != null) {
widget.textController = TextEditingController(text: widget.initialPhoneNumber); widget.textController!.text = widget.initialPhoneNumber!;
} }
} }
@ -116,13 +116,16 @@ class _GenericBottomSheetState extends State<GenericBottomSheet> {
padding: EdgeInsets.all(8.h), padding: EdgeInsets.all(8.h),
keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number, keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number,
onChange: (value) { onChange: (value) {
widget.textController!.text = value!;
if (widget.onChange != null) { if (widget.onChange != null) {
widget.onChange!(value); widget.onChange!(value);
} }
}, },
onCountryChange: (value) {
if (widget.onCountryChange != null) {
widget.onCountryChange!(value);
}
},
isEnable: true, isEnable: true,
// focusNode: widget.myFocusNode,
isReadOnly: widget.isFromSavedLogin, isReadOnly: widget.isFromSavedLogin,
prefix: widget.isForEmail ? null : widget.countryCode, prefix: widget.isForEmail ? null : widget.countryCode,
isBorderAllowed: false, isBorderAllowed: false,

@ -28,11 +28,12 @@ class TextInputWidget extends StatelessWidget {
final bool isCountryDropDown; final bool isCountryDropDown;
final bool hasError; final bool hasError;
final String? errorMessage; final String? errorMessage;
Function(CountryEnum)? onCountryChange;
// final List<Country> countryList; // final List<Country> countryList;
// final Function(Country)? onCountryChange; // final Function(Country)? onCountryChange;
const TextInputWidget({ TextInputWidget({
Key? key, Key? key,
required this.labelText, required this.labelText,
required this.hintText, required this.hintText,
@ -52,6 +53,7 @@ class TextInputWidget extends StatelessWidget {
this.isCountryDropDown = false, this.isCountryDropDown = false,
this.hasError = false, this.hasError = false,
this.errorMessage, this.errorMessage,
this.onCountryChange,
// this.countryList = const [], // this.countryList = const [],
// this.onCountryChange, // this.onCountryChange,
}) : super(key: key); }) : super(key: key);
@ -74,21 +76,16 @@ class TextInputWidget extends StatelessWidget {
child: Row( child: Row(
textDirection: Directionality.of(context), textDirection: Directionality.of(context),
children: [ children: [
if (isAllowLeadingIcon && leadingIcon != null && !isCountryDropDown) if (isAllowLeadingIcon && leadingIcon != null && !isCountryDropDown) _buildLeadingIcon(context),
_buildLeadingIcon(context),
isCountryDropDown isCountryDropDown
? CustomCountryDropdown( ? CustomCountryDropdown(
countryList: CountryEnum.values, countryList: CountryEnum.values,
onCountryChange: (CountryEnum? value) { onCountryChange: onCountryChange,
print(value);
},
isRtl: Directionality.of(context) == TextDirection.rtl, isRtl: Directionality.of(context) == TextDirection.rtl,
isFromBottomSheet: isCountryDropDown, isFromBottomSheet: isCountryDropDown,
isEnableTextField: true, isEnableTextField: true,
onPhoneNumberChanged: (value) { onPhoneNumberChanged: onChange,
print(value); // textField: _buildTextField(context),
},
textField: _buildTextField(context),
) )
: Expanded( : Expanded(
child: Column( child: Column(

Loading…
Cancel
Save