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 phoneNumberController = TextEditingController();
CountryEnum selectedCountry = CountryEnum.saudiArabia;
bool isTermsAccepted = false;
void login() {
if (ValidationUtils.isValidatePhoneAndId(nationalId: nationalIdController.text, phoneNumber: phoneNumberController.text)) {
} 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 {
String firebaseToken = "dOGRRszQQMGe_9wA5Hx3kO:APA91bFV5IcIJXvcCXXk0tc2ddtZgWwCPq7sGSuPr-YW7iiJpQZKgFGN9GAzCVOWL8MfheaP1slE8MdxB7lczdPBGdONQ7WbMmhgHcsUCUktq-hsapGXXqc";
final result = await authenticationRepo.selectDeviceByImei(firebaseToken: firebaseToken);

@ -83,7 +83,7 @@ class _LoginScreen extends State<LoginScreen> {
icon: AppAssets.login1,
iconColor: Colors.white,
onPressed: () {
showLoginModel(context: context, textController: authVm.phoneNumberController);
showLoginModel(context: context, authVM: authVm);
// if (nationIdController.text.isNotEmpty) {
// } 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(
isScrollControlled: true,
isDismissible: false,
@ -151,12 +151,12 @@ class _LoginScreen extends State<LoginScreen> {
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: SingleChildScrollView(
child: GenericBottomSheet(
countryCode: "966",
countryCode: authVM.selectedCountry.countryCode,
initialPhoneNumber: "",
textController: textController,
textController: authVM.phoneNumberController,
isEnableCountryDropdown: true,
onCountryChange: (value) {},
onChange: (String? value) {},
onCountryChange: authVM.onCountryChange,
onChange: authVM.onPhoneNumberChange,
buttons: [
Padding(
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/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/theme/colors.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/input_widget.dart';
import 'package:hmg_patient_app_new/widgets/otp/otp.dart';
import 'package:provider/provider.dart';
class RegisterNew extends StatefulWidget {
@override
@ -25,8 +27,6 @@ class RegisterNew extends StatefulWidget {
}
class _RegisterNew extends State<RegisterNew> {
bool isTermsAccepted = true;
@override
void initState() {
super.initState();
@ -40,6 +40,8 @@ class _RegisterNew extends State<RegisterNew> {
@override
Widget build(BuildContext context) {
AppState appState = getIt.get<AppState>();
AuthenticationViewModel authVm = context.read<AuthenticationViewModel>();
return Scaffold(
backgroundColor: AppColors.bgScaffoldColor,
appBar: CustomAppBar(
@ -68,12 +70,7 @@ class _RegisterNew extends State<RegisterNew> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Utils.showLottie(context: context,
assetPath: 'assets/animations/lottie/register.json',
width: 200.h,
height: 200.h,
fit: BoxFit.cover,
repeat: true),
Utils.showLottie(context: context, assetPath: 'assets/animations/lottie/register.json', width: 200.h, height: 200.h, fit: BoxFit.cover, repeat: true),
SizedBox(height: 16.h),
LocaleKeys.prepareToElevate.tr().toText32(isBold: true),
SizedBox(height: 24.h),
@ -125,22 +122,25 @@ class _RegisterNew extends State<RegisterNew> {
),
SizedBox(height: 25.h),
GestureDetector(
onTap: () {},
onTap: authVm.onTermAccepted,
child: Row(
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),
height: 24.h,
width: 24.h,
decoration: BoxDecoration(
color: isTermsAccepted ? const Color(0xFFE92227) : Colors.transparent,
color: isTermsAccepted ? AppColors.primaryRedColor : Colors.transparent,
borderRadius: BorderRadius.circular(6),
border: Border.all(
color: isTermsAccepted ? const Color(0xFFE92227) : Colors.grey,
width: 2.h,
),
border: Border.all(color: isTermsAccepted ? AppColors.primaryRedBorderColor : AppColors.greyColor, width: 2.h),
),
child: isTermsAccepted ? Icon(Icons.check, size: 16.fSize, color: Colors.white) : null,
);
},
),
SizedBox(width: 12.h),
Expanded(
@ -157,7 +157,7 @@ class _RegisterNew extends State<RegisterNew> {
text: "Register",
icon: AppAssets.note_edit,
onPressed: () {
showRegisterModel(context: context);
showRegisterModel(context: context, authVM: authVm);
},
),
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(
context: context,
isScrollControlled: true,
isDismissible: false,
useSafeArea: true,
backgroundColor: Colors.transparent,
builder: (bottomSheetContext) =>
Padding(
padding: EdgeInsets.only(bottom: MediaQuery
.of(bottomSheetContext)
.viewInsets
.bottom),
builder: (bottomSheetContext) => Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom),
child: SingleChildScrollView(
child: GenericBottomSheet(
countryCode: "966",
countryCode: authVM.selectedCountry.countryCode,
initialPhoneNumber: "",
textController: TextEditingController(),
textController: authVM.phoneNumberController,
isEnableCountryDropdown: true,
onChange: (String? value) {},
onCountryChange: authVM.onCountryChange,
onChange: authVM.onPhoneNumberChange,
buttons: [
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: CustomButton(
text: LocaleKeys.sendOTPSMS.tr(),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (BuildContext context) => OTPVerificationPage(phoneNumber: '12234567',)));
Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) => OTPVerificationPage(
phoneNumber: '12234567',
)));
// if (mobileNo.isEmpty) {
// context.showBottomSheet(

@ -53,8 +53,11 @@ class _RegisterNew extends State<RegisterNewStep2> {
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(onBackPressed: () {}, onLanguageChanged: (lang) {}, hideLogoAndLang: true,),
appBar: CustomAppBar(
onBackPressed: () {},
onLanguageChanged: (lang) {},
hideLogoAndLang: true,
),
body: SingleChildScrollView(
reverse: false,
padding: EdgeInsets.only(left: 24.h, right: 24.h, top: 24.h),
@ -79,8 +82,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
keyboardType: TextInputType.text,
isAllowLeadingIcon: true,
isReadOnly: isFromDubai ? false : true,
leadingIcon: AppAssets.user_circle).paddingSymmetrical(0.h,16.h),
Divider(height: 1, color: AppColors.greyColor,),
leadingIcon: AppAssets.user_circle)
.paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
TextInputWidget(
labelText: LocaleKeys.nationalIdNumber.tr(),
hintText: isFromDubai ? "widget.payload.nationalID!" : (widget.nHICData!.idNumber ?? ""),
@ -91,8 +98,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
isBorderAllowed: false,
isAllowLeadingIcon: true,
isReadOnly: true,
leadingIcon: AppAssets.student_card).paddingSymmetrical(0.h,16.h),
Divider(height: 1, color: AppColors.greyColor,),
leadingIcon: AppAssets.student_card)
.paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
isFromDubai
? DropdownWidget(
labelText: LocaleKeys.gender.tr(),
@ -122,9 +133,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
isAllowLeadingIcon: true,
isReadOnly: isFromDubai ? false : true,
leadingIcon: AppAssets.user_full,
onChange: (value) {}).paddingSymmetrical(0.h,16.h),
Divider(height: 1, color: AppColors.greyColor,),
onChange: (value) {})
.paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
isFromDubai
? DropdownWidget(
labelText: LocaleKeys.maritalStatus.tr(),
@ -152,8 +166,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
isAllowLeadingIcon: true,
isReadOnly: true,
leadingIcon: AppAssets.smart_phone,
onChange: (value) {}).paddingSymmetrical(0.h,16.h),
Divider(height: 1, color: AppColors.greyColor,),
onChange: (value) {})
.paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
isFromDubai
? DropdownWidget(
labelText: LocaleKeys.country.tr(),
@ -181,8 +199,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
isAllowLeadingIcon: true,
isReadOnly: true,
leadingIcon: AppAssets.globe,
onChange: (value) {}).paddingSymmetrical(0.h,16.h),
Divider(height: 1, color: AppColors.greyColor,),
onChange: (value) {})
.paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
TextInputWidget(
labelText: LocaleKeys.mobileNumber.tr(),
hintText: ("widget.payload.mobileNo" ?? ""),
@ -194,8 +216,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
isAllowLeadingIcon: true,
isReadOnly: true,
leadingIcon: AppAssets.call,
onChange: (value) {}).paddingSymmetrical(0.h,16.h),
Divider(height: 1, color: AppColors.greyColor,),
onChange: (value) {})
.paddingSymmetrical(0.h, 16.h),
Divider(
height: 1,
color: AppColors.greyColor,
),
TextInputWidget(
labelText: LocaleKeys.dob.tr(),
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,
// selectionCustomIcon: AppAssets.calendar,
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() {
super.initState();
if (!widget.isForEmail) {
widget.textController = TextEditingController(text: widget.initialPhoneNumber);
if (!widget.isForEmail && widget.textController != null) {
widget.textController!.text = widget.initialPhoneNumber!;
}
}
@ -116,13 +116,16 @@ class _GenericBottomSheetState extends State<GenericBottomSheet> {
padding: EdgeInsets.all(8.h),
keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number,
onChange: (value) {
widget.textController!.text = value!;
if (widget.onChange != null) {
widget.onChange!(value);
}
},
onCountryChange: (value) {
if (widget.onCountryChange != null) {
widget.onCountryChange!(value);
}
},
isEnable: true,
// focusNode: widget.myFocusNode,
isReadOnly: widget.isFromSavedLogin,
prefix: widget.isForEmail ? null : widget.countryCode,
isBorderAllowed: false,

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

Loading…
Cancel
Save