Skip to content

Commit

Permalink
fix: staking (#661)
Browse files Browse the repository at this point in the history
* fix: improve pwd creation ux

* fix: hide asset select arrow if only 1 asset; improve `max` button dx;

* feat: add staking withdraw hint; fix `AmountInput` tap area;

* chore: review

---------

Co-authored-by: Egor Komarov <egor.komarov@bf.rocks>
  • Loading branch information
Odrin and Egor Komarov authored Dec 3, 2024
1 parent f7de565 commit eb6c13b
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 66 deletions.
3 changes: 2 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@
"stEverAppearInMinutes": "stEVER will appear in your account within a couple of minutes",
"stEverReturnInMinutes": "stEVER will be returned in your account within a couple of minutes",
"withdrawHoursNote": "Your tokens will be withdrawn from staking within {} hours, once the staking round is complete.",
"withdrawHousProgress": "EVER will appear in your account within {} hours",
"withdrawHoursProgress": "EVER will appear in your account within {} hours",
"withdrawHoursHint": "Your tokens will be withdrawn from staking within {} hours, once the staking round is complete.",
"cancelUnstaking": "Cancel unstaking",
"cancelUnstakingNote": "You can cancel unstaking, then stEVER will be returned to your account",
"unstakingCancelled": "Unstaking cancelled",
Expand Down
3 changes: 2 additions & 1 deletion assets/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@
"stEverAppearInMinutes": "stEVER will appear in your account within a couple of minutes",
"stEverReturnInMinutes": "stEVER will be returned in your account within a couple of minutes",
"withdrawHoursNote": "Your tokens will be withdrawn from staking within {} hours, once the staking round is complete.",
"withdrawHousProgress": "EVER will appear in your account within {} hours",
"withdrawHoursProgress": "EVER will appear in your account within {} hours",
"withdrawHoursHint": "Your tokens will be withdrawn from staking within {} hours, once the staking round is complete.",
"cancelUnstaking": "Cancel unstaking",
"cancelUnstakingNote": "You can cancel unstaking, then stEVER will be returned to your account",
"unstakingCancelled": "Unstaking cancelled",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:app/feature/add_seed/create_password/model/password_status.dart';
import 'package:app/feature/add_seed/create_password/widgets/password_info_section.dart';
import 'package:app/generated/generated.dart';
import 'package:app/utils/focus_utils.dart';
import 'package:flutter/material.dart';
import 'package:ui_components_lib/ui_components_lib.dart';
import 'package:ui_components_lib/v2/ui_components_lib_v2.dart';
Expand Down Expand Up @@ -30,14 +31,15 @@ class CreateSeedPasswordView extends StatefulWidget {

class _CreateSeedPasswordViewState extends State<CreateSeedPasswordView> {
final ScrollController _scrollController = ScrollController();
final FocusNode _focusNode = FocusNode();
final FocusNode _pwd1focusNode = FocusNode();
final FocusNode _pwd2focusNode = FocusNode();

@override
void initState() {
super.initState();

_focusNode.addListener(() {
if (_focusNode.hasFocus) {
_pwd1focusNode.addListener(() {
if (_pwd1focusNode.hasFocus) {
_scrollToBottom();
}
});
Expand Down Expand Up @@ -71,15 +73,20 @@ class _CreateSeedPasswordViewState extends State<CreateSeedPasswordView> {
),
const SizedBox(height: DimensSize.d24),
SecureTextField(
focusNode: _focusNode,
focusNode: _pwd1focusNode,
hintText: LocaleKeys.confirmSetPasswordHint.tr(),
textEditingController: widget.passwordController,
textInputAction: TextInputAction.next,
isAutofocus: true,
onSubmit: _onPwd1Submit,
),
const SizedBox(height: DimensSize.d8),
SecureTextField(
focusNode: _pwd2focusNode,
hintText: LocaleKeys.confirmRepeatPasswordHint.tr(),
textEditingController: widget.confirmController,
textInputAction: TextInputAction.done,
onSubmit: _onPwd2Submit,
),
const SizedBox(height: DimensSize.d24),
PasswordInfoSection(
Expand Down Expand Up @@ -107,7 +114,8 @@ class _CreateSeedPasswordViewState extends State<CreateSeedPasswordView> {

@override
void dispose() {
_focusNode.dispose();
_pwd1focusNode.dispose();
_pwd2focusNode.dispose();
_scrollController.dispose();
super.dispose();
}
Expand All @@ -127,4 +135,12 @@ class _CreateSeedPasswordViewState extends State<CreateSeedPasswordView> {
}
});
}

void _onPwd1Submit(String? _) => requestFocus(context, _pwd2focusNode);

void _onPwd2Submit(String? _) {
if (widget.passwordStatus == PasswordStatus.match) {
widget.onPressedNext();
}
}
}
7 changes: 4 additions & 3 deletions lib/feature/wallet/staking/bloc/staking_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class StakingBloc extends Bloc<StakingBlocEvent, StakingBlocState>

void _registerHandlers() {
on<_Init>((_, emit) => _init(emit));
on<_SelectMax>((_, emit) => _selectMax());
on<_SelectMax>((event, emit) => _selectMax(event.fieldState));
on<_UpdateReceive>((event, emit) => _updateReceive(event.value, emit));
on<_UpdateRequests>((event, emit) {
_requests = event.requests;
Expand Down Expand Up @@ -352,7 +352,7 @@ class StakingBloc extends Bloc<StakingBlocEvent, StakingBlocState>
);
}

void _selectMax() {
void _selectMax(FormFieldState<String>? fieldState) {
var max = _dataState.asset.balance;

if (_type == StakingPageType.stake) {
Expand All @@ -375,7 +375,8 @@ class StakingBloc extends Bloc<StakingBlocEvent, StakingBlocState>
}
}

_inputController.text = max.amount.toString();
_inputController.text = max.formatImproved();
fieldState?.didChange(_inputController.text);
}

Currency get _nativeCurrency =>
Expand Down
Loading

0 comments on commit eb6c13b

Please sign in to comment.