TF-2387 Navigate to TwakeWelcome page when click back button on login view
This commit is contained in:
@@ -27,7 +27,7 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
|
|||||||
side: const BorderSide(width: 0, color: AppColor.primaryColor)
|
side: const BorderSide(width: 0, color: AppColor.primaryColor)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
onPressed: controller.handleLoginPressed,
|
onPressed: () => controller.handleLoginPressed(context),
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context).signIn,
|
AppLocalizations.of(context).signIn,
|
||||||
style: const TextStyle(fontSize: 16, color: Colors.white)
|
style: const TextStyle(fontSize: 16, color: Colors.white)
|
||||||
@@ -89,7 +89,7 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
|
|||||||
hintText: AppLocalizations.of(context).password,
|
hintText: AppLocalizations.of(context).password,
|
||||||
focusNode: controller.passFocusNode,
|
focusNode: controller.passFocusNode,
|
||||||
onTextChange: controller.onPasswordChange,
|
onTextChange: controller.onPasswordChange,
|
||||||
onSubmitted: (_) => controller.handleLoginPressed(),
|
onSubmitted: (_) => controller.handleLoginPressed(context),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:core/presentation/extensions/url_extension.dart';
|
import 'package:core/presentation/extensions/url_extension.dart';
|
||||||
import 'package:core/presentation/state/failure.dart';
|
import 'package:core/presentation/state/failure.dart';
|
||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
|
import 'package:core/presentation/utils/keyboard_utils.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:core/utils/platform_info.dart';
|
import 'package:core/utils/platform_info.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
@@ -254,20 +255,30 @@ class LoginController extends ReloadableController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleBackButtonAction() {
|
void handleBackButtonAction(BuildContext context) {
|
||||||
|
KeyboardUtils.hideKeyboard(context);
|
||||||
clearState();
|
clearState();
|
||||||
if (loginFormType.value == LoginFormType.credentialForm) {
|
switch(loginFormType.value) {
|
||||||
_password = null;
|
case LoginFormType.dnsLookupForm:
|
||||||
_username = null;
|
case LoginFormType.baseUrlForm:
|
||||||
usernameInputController.clear();
|
navigateToTwakeWelcomePage();
|
||||||
passwordInputController.clear();
|
break;
|
||||||
loginFormType.value = LoginFormType.baseUrlForm;
|
case LoginFormType.passwordForm:
|
||||||
} else if (loginFormType.value == LoginFormType.passwordForm) {
|
_password = null;
|
||||||
_password = null;
|
_baseUri = null;
|
||||||
_baseUri = null;
|
urlInputController.clear();
|
||||||
urlInputController.clear();
|
passwordInputController.clear();
|
||||||
passwordInputController.clear();
|
loginFormType.value = LoginFormType.dnsLookupForm;
|
||||||
loginFormType.value = LoginFormType.dnsLookupForm;
|
break;
|
||||||
|
case LoginFormType.credentialForm:
|
||||||
|
_password = null;
|
||||||
|
_username = null;
|
||||||
|
usernameInputController.clear();
|
||||||
|
passwordInputController.clear();
|
||||||
|
loginFormType.value = LoginFormType.baseUrlForm;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +288,8 @@ class LoginController extends ReloadableController {
|
|||||||
userNameFocusNode.requestFocus();
|
userNameFocusNode.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleLoginPressed() {
|
void handleLoginPressed(BuildContext context) {
|
||||||
|
KeyboardUtils.hideKeyboard(context);
|
||||||
log('LoginController::handleLoginPressed:_currentBaseUrl: $_currentBaseUrl | _username: $_username | _password: $_password');
|
log('LoginController::handleLoginPressed:_currentBaseUrl: $_currentBaseUrl | _username: $_username | _password: $_password');
|
||||||
if (_currentBaseUrl == null) {
|
if (_currentBaseUrl == null) {
|
||||||
consumeState(Stream.value(Left(AuthenticationUserFailure(CanNotFoundBaseUrl()))));
|
consumeState(Stream.value(Left(AuthenticationUserFailure(CanNotFoundBaseUrl()))));
|
||||||
@@ -503,6 +515,11 @@ class LoginController extends ReloadableController {
|
|||||||
passwordInputController.clear();
|
passwordInputController.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get isBackButtonActivated =>
|
||||||
|
loginFormType.value == LoginFormType.dnsLookupForm ||
|
||||||
|
loginFormType.value == LoginFormType.passwordForm ||
|
||||||
|
loginFormType.value == LoginFormType.credentialForm;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
passFocusNode.dispose();
|
passFocusNode.dispose();
|
||||||
|
|||||||
@@ -42,9 +42,10 @@ class LoginView extends BaseLoginView {
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
Obx(() {
|
Obx(() {
|
||||||
if (controller.loginFormType.value == LoginFormType.passwordForm ||
|
if (controller.isBackButtonActivated) {
|
||||||
controller.loginFormType.value == LoginFormType.credentialForm) {
|
return LoginBackButton(
|
||||||
return LoginBackButton(onBackAction: controller.handleBackButtonAction);
|
onBackAction: () => controller.handleBackButtonAction(context)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
})
|
})
|
||||||
@@ -52,9 +53,10 @@ class LoginView extends BaseLoginView {
|
|||||||
: Stack(children: [
|
: Stack(children: [
|
||||||
_buildCenterForm(context),
|
_buildCenterForm(context),
|
||||||
Obx(() {
|
Obx(() {
|
||||||
if (controller.loginFormType.value == LoginFormType.passwordForm ||
|
if (controller.isBackButtonActivated) {
|
||||||
controller.loginFormType.value == LoginFormType.credentialForm) {
|
return LoginBackButton(
|
||||||
return LoginBackButton(onBackAction: controller.handleBackButtonAction);
|
onBackAction: () => controller.handleBackButtonAction(context)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
})
|
})
|
||||||
@@ -103,7 +105,7 @@ class LoginView extends BaseLoginView {
|
|||||||
textEditingController: controller.passwordInputController,
|
textEditingController: controller.passwordInputController,
|
||||||
focusNode: controller.passFocusNode,
|
focusNode: controller.passFocusNode,
|
||||||
onTextChange: controller.onPasswordChange,
|
onTextChange: controller.onPasswordChange,
|
||||||
onTextSubmitted: (_) => controller.handleLoginPressed(),
|
onTextSubmitted: (_) => controller.handleLoginPressed(context),
|
||||||
);
|
);
|
||||||
case LoginFormType.baseUrlForm:
|
case LoginFormType.baseUrlForm:
|
||||||
return _buildUrlInput(context);
|
return _buildUrlInput(context);
|
||||||
|
|||||||
Reference in New Issue
Block a user