Skip to content

Commit

Permalink
TF-2046 Move passFocusNode to controller to dispose it when view di…
Browse files Browse the repository at this point in the history
…sposed
  • Loading branch information
dab246 authored and hoangdat committed Jul 20, 2023
1 parent 4403e28 commit acfd766
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/features/login/presentation/base_login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
final responsiveUtils = Get.find<ResponsiveUtils>();
final imagePaths = Get.find<ImagePaths>();

final FocusNode passFocusNode = FocusNode();

Widget buildLoginMessage(BuildContext context, Either<Failure, Success> viewState) {
return Padding(
padding: const EdgeInsets.only(top: 11, bottom: 36, left: 58, right: 58),
Expand Down Expand Up @@ -146,7 +144,7 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
itemBuilder: (context, loginUsername) => RecentItemTileWidget(loginUsername, imagePath: imagePaths),
onSuggestionSelected: (recentUsername) {
controller.setUsername(recentUsername.username);
passFocusNode.requestFocus();
controller.passFocusNode.requestFocus();
},
suggestionsBoxDecoration: const SuggestionsBoxDecoration(borderRadius: BorderRadius.all(Radius.circular(14))),
noItemsFoundBuilder: (context) => const SizedBox(),
Expand Down Expand Up @@ -174,7 +172,7 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
..onChange(controller.setPasswordText)
..textInputAction(TextInputAction.done)
..hintText(AppLocalizations.of(context).password)
..setFocusNode(passFocusNode))
..setFocusNode(controller.passFocusNode))
.build()));
}

Expand Down
2 changes: 2 additions & 0 deletions lib/features/login/presentation/login_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class LoginController extends BaseController {

final TextEditingController urlInputController = TextEditingController();
final TextEditingController usernameInputController = TextEditingController();
final FocusNode passFocusNode = FocusNode();

LoginController(
this._authenticationInteractor,
Expand Down Expand Up @@ -378,6 +379,7 @@ class LoginController extends BaseController {

@override
void onClose() {
passFocusNode.dispose();
urlInputController.dispose();
usernameInputController.dispose();
super.onClose();
Expand Down

0 comments on commit acfd766

Please sign in to comment.