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)
|
||||
)
|
||||
),
|
||||
onPressed: controller.handleLoginPressed,
|
||||
onPressed: () => controller.handleLoginPressed(context),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).signIn,
|
||||
style: const TextStyle(fontSize: 16, color: Colors.white)
|
||||
@@ -89,7 +89,7 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
|
||||
hintText: AppLocalizations.of(context).password,
|
||||
focusNode: controller.passFocusNode,
|
||||
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/state/failure.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/platform_info.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
@@ -254,20 +255,30 @@ class LoginController extends ReloadableController {
|
||||
));
|
||||
}
|
||||
|
||||
void handleBackButtonAction() {
|
||||
void handleBackButtonAction(BuildContext context) {
|
||||
KeyboardUtils.hideKeyboard(context);
|
||||
clearState();
|
||||
if (loginFormType.value == LoginFormType.credentialForm) {
|
||||
_password = null;
|
||||
_username = null;
|
||||
usernameInputController.clear();
|
||||
passwordInputController.clear();
|
||||
loginFormType.value = LoginFormType.baseUrlForm;
|
||||
} else if (loginFormType.value == LoginFormType.passwordForm) {
|
||||
_password = null;
|
||||
_baseUri = null;
|
||||
urlInputController.clear();
|
||||
passwordInputController.clear();
|
||||
loginFormType.value = LoginFormType.dnsLookupForm;
|
||||
switch(loginFormType.value) {
|
||||
case LoginFormType.dnsLookupForm:
|
||||
case LoginFormType.baseUrlForm:
|
||||
navigateToTwakeWelcomePage();
|
||||
break;
|
||||
case LoginFormType.passwordForm:
|
||||
_password = null;
|
||||
_baseUri = null;
|
||||
urlInputController.clear();
|
||||
passwordInputController.clear();
|
||||
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();
|
||||
}
|
||||
|
||||
void handleLoginPressed() {
|
||||
void handleLoginPressed(BuildContext context) {
|
||||
KeyboardUtils.hideKeyboard(context);
|
||||
log('LoginController::handleLoginPressed:_currentBaseUrl: $_currentBaseUrl | _username: $_username | _password: $_password');
|
||||
if (_currentBaseUrl == null) {
|
||||
consumeState(Stream.value(Left(AuthenticationUserFailure(CanNotFoundBaseUrl()))));
|
||||
@@ -503,6 +515,11 @@ class LoginController extends ReloadableController {
|
||||
passwordInputController.clear();
|
||||
}
|
||||
|
||||
bool get isBackButtonActivated =>
|
||||
loginFormType.value == LoginFormType.dnsLookupForm ||
|
||||
loginFormType.value == LoginFormType.passwordForm ||
|
||||
loginFormType.value == LoginFormType.credentialForm;
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
passFocusNode.dispose();
|
||||
|
||||
@@ -42,9 +42,10 @@ class LoginView extends BaseLoginView {
|
||||
)
|
||||
),
|
||||
Obx(() {
|
||||
if (controller.loginFormType.value == LoginFormType.passwordForm ||
|
||||
controller.loginFormType.value == LoginFormType.credentialForm) {
|
||||
return LoginBackButton(onBackAction: controller.handleBackButtonAction);
|
||||
if (controller.isBackButtonActivated) {
|
||||
return LoginBackButton(
|
||||
onBackAction: () => controller.handleBackButtonAction(context)
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
})
|
||||
@@ -52,9 +53,10 @@ class LoginView extends BaseLoginView {
|
||||
: Stack(children: [
|
||||
_buildCenterForm(context),
|
||||
Obx(() {
|
||||
if (controller.loginFormType.value == LoginFormType.passwordForm ||
|
||||
controller.loginFormType.value == LoginFormType.credentialForm) {
|
||||
return LoginBackButton(onBackAction: controller.handleBackButtonAction);
|
||||
if (controller.isBackButtonActivated) {
|
||||
return LoginBackButton(
|
||||
onBackAction: () => controller.handleBackButtonAction(context)
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
})
|
||||
@@ -103,7 +105,7 @@ class LoginView extends BaseLoginView {
|
||||
textEditingController: controller.passwordInputController,
|
||||
focusNode: controller.passFocusNode,
|
||||
onTextChange: controller.onPasswordChange,
|
||||
onTextSubmitted: (_) => controller.handleLoginPressed(),
|
||||
onTextSubmitted: (_) => controller.handleLoginPressed(context),
|
||||
);
|
||||
case LoginFormType.baseUrlForm:
|
||||
return _buildUrlInput(context);
|
||||
|
||||
Reference in New Issue
Block a user