merge-update-with-lab-changes
Aamir Muhammad 3 months ago committed by haroon amjad
parent a565a1da1b
commit ff12e832ab

@ -19,6 +19,7 @@ class GenericBottomSheet extends StatefulWidget {
final bool isEnableCountryDropdown;
final bool isFromSavedLogin;
Function(String?)? onChange;
FocusNode? focusNode;
GenericBottomSheet(
{Key? key,
@ -30,6 +31,7 @@ class GenericBottomSheet extends StatefulWidget {
this.onCountryChange,
this.isEnableCountryDropdown = false,
this.isFromSavedLogin = false,
this.focusNode,
this.onChange})
: super(key: key);
@ -38,18 +40,18 @@ class GenericBottomSheet extends StatefulWidget {
}
class _GenericBottomSheetState extends State<GenericBottomSheet> {
// FocusNode node = FocusNode();
@override
void initState() {
super.initState();
if (!widget.isForEmail) {
widget.textController = TextEditingController(text: widget.initialPhoneNumber);
}
}
// WidgetsBinding.instance.addPostFrameCallback((_) {
// FocusScope.of(context).requestFocus(node);
// });
@override
void dispose() {
super.dispose();
}
@override
@ -59,7 +61,8 @@ class _GenericBottomSheetState extends State<GenericBottomSheet> {
bottom: Platform.isIOS ? false : true,
child: GestureDetector(
onTap: () {
FocusScope.of(context).unfocus(); // Dismiss the keyboard when tapping outside
// Only unfocus if the tap is not on the text field area
FocusScope.of(context).unfocus();
},
child: Builder(builder: (context) {
// final isRtl = Directionality.of(context) == TextDirection.rtl;
@ -104,6 +107,7 @@ class _GenericBottomSheetState extends State<GenericBottomSheet> {
widget.isForEmail ? TranslationBase.of(context).email : TranslationBase.of(context).phoneNumber,
widget.isForEmail ? "demo@gmail.com" : "5xxxxxxxx",
widget.textController!,
focusNode: widget.focusNode!,
padding: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8),
keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number,
onChange: (value) {
@ -113,7 +117,6 @@ class _GenericBottomSheetState extends State<GenericBottomSheet> {
}
},
isEnable: true,
// focusNode: node,
autoFocus: true,
isReadOnly: widget.isFromSavedLogin,
prefix: widget.isForEmail ? null : widget.countryCode,

@ -766,6 +766,7 @@ Widget newInputWidget(
readOnly: isReadOnly,
textAlignVertical: TextAlignVertical.top,
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
onChanged: onChange,
focusNode: focusNode,

@ -222,6 +222,7 @@ class _RegisterNew extends State<RegisterNew> {
hasSelection: false,
isBorderAllowed: false,
isAllowLeadingIcon: true,
autoFocus: true,
padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0),
leadingIcon: "assets/images/svg/student-card.svg", onChange: (value) {
print(value);

@ -90,13 +90,22 @@ class _WelcomeLogin extends State<WelcomeLogin> {
late int isHijri;
var healthId;
late FocusNode _focusNode;
@override
void initState() {
isLoading = true;
super.initState();
_focusNode = FocusNode();
phoneController = TextEditingController();
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
projectViewModel = context.read<ProjectViewModel>();
@ -172,6 +181,7 @@ class _WelcomeLogin extends State<WelcomeLogin> {
removePadding: true,
prefix: null,
hasSelection: false,
autoFocus: true,
isBorderAllowed: false,
isAllowLeadingIcon: true,
padding: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8),
@ -190,6 +200,8 @@ class _WelcomeLogin extends State<WelcomeLogin> {
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),
@ -198,6 +210,7 @@ class _WelcomeLogin extends State<WelcomeLogin> {
countryCode: selectedCountry.countryCode,
initialPhoneNumber: phoneNumber != null ? phoneNumber : "",
textController: phoneController,
focusNode: _focusNode,
isEnableCountryDropdown: true,
onCountryChange: (value) {
selectedCountry = value;
@ -205,6 +218,15 @@ class _WelcomeLogin extends State<WelcomeLogin> {
},
onChange: (String? value) {
phoneNumber = value;
// WidgetsBinding.instance.addPostFrameCallback((_) {
// Future.delayed(Duration(milliseconds: 300), () {
// if (mounted && _focusNode.canRequestFocus) {
// _focusNode.requestFocus();
// }
// });
// });
FocusNode().requestFocus(_focusNode);
},
buttons: [
Padding(
@ -342,13 +364,13 @@ class _WelcomeLogin extends State<WelcomeLogin> {
GifLoaderDialogUtils.hideDialog(context);
context.showBottomSheet(
child: ExceptionBottomSheet(
message: err.toString(),
showCancel: true,
onOkPressed: () {
Navigator.of(context).pop();
Navigator.of(context).push(FadePage(page: RegisterNew()));
},
));
message: err.toString(),
showCancel: true,
onOkPressed: () {
Navigator.of(context).pop();
Navigator.of(context).push(FadePage(page: RegisterNew()));
},
));
projectViewModel.analytics.loginRegistration.login_fail(error: err.toString());
});
}
@ -438,14 +460,6 @@ class _WelcomeLogin extends State<WelcomeLogin> {
if (activation.errorCode == '699') {
GifLoaderDialogUtils.hideDialog(context);
onWrongActivationCode(activation.errorEndUserMessage);
// context.showBottomSheet(
// child: ExceptionBottomSheet(
// message: activation.errorEndUserMessage,
// onOkPressed: () {
// Navigator.of(context).pop();
// },
// ),
// );
return;
} else if (registerd_data?.isRegister == true) {
Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew));

Loading…
Cancel
Save