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

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

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

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

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

Loading…
Cancel
Save