mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
CW-636-1-Unfocus text fields when push to next one (#1460)
* unfocus text fields when push to next one * unfocus when push to next from new wallet / restore pages[skip ci]]
This commit is contained in:
parent
43a4477b39
commit
287c2d8b60
10 changed files with 90 additions and 24 deletions
|
@ -1,4 +1,5 @@
|
|||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/utils/route_aware.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/di.dart';
|
||||
|
@ -32,6 +33,14 @@ abstract class BasePage extends StatelessWidget {
|
|||
|
||||
Widget? get endDrawer => null;
|
||||
|
||||
Function(BuildContext context)? get pushToWidget => null;
|
||||
|
||||
Function(BuildContext context)? get pushToNextWidget => null;
|
||||
|
||||
Function(BuildContext context)? get popWidget => null;
|
||||
|
||||
Function(BuildContext context)? get popNextWidget => null;
|
||||
|
||||
AppBarStyle get appBarStyle => AppBarStyle.regular;
|
||||
|
||||
Widget Function(BuildContext, Widget)? get rootWrapper => null;
|
||||
|
@ -162,15 +171,21 @@ abstract class BasePage extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final root = Scaffold(
|
||||
key: _scaffoldKey,
|
||||
backgroundColor: pageBackgroundColor(context),
|
||||
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
|
||||
extendBodyBehindAppBar: extendBodyBehindAppBar,
|
||||
endDrawer: endDrawer,
|
||||
appBar: appBar(context),
|
||||
body: body(context),
|
||||
floatingActionButton: floatingActionButton(context));
|
||||
final root = RouteAwareWidget(
|
||||
child: Scaffold(
|
||||
key: _scaffoldKey,
|
||||
backgroundColor: pageBackgroundColor(context),
|
||||
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
|
||||
extendBodyBehindAppBar: extendBodyBehindAppBar,
|
||||
endDrawer: endDrawer,
|
||||
appBar: appBar(context),
|
||||
body: body(context),
|
||||
floatingActionButton: floatingActionButton(context)),
|
||||
pushToWidget: (context) => pushToWidget?.call(context),
|
||||
pushToNextWidget: (context) => pushToNextWidget?.call(context),
|
||||
popWidget: (context) => popWidget?.call(context),
|
||||
popNextWidget: (context) => popNextWidget?.call(context),
|
||||
);
|
||||
|
||||
return rootWrapper?.call(context, root) ?? root;
|
||||
}
|
||||
|
|
|
@ -99,6 +99,14 @@ class ExchangePage extends BasePage {
|
|||
@override
|
||||
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
||||
|
||||
@override
|
||||
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.focusedChild?.unfocus();
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Widget middle(BuildContext context) => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
|
|
@ -84,12 +84,7 @@ class IoniaGiftCardDetailPage extends BasePage {
|
|||
}
|
||||
});
|
||||
|
||||
return RouteAwareWidget(
|
||||
pushToWidget: ()=> viewModel.increaseBrightness(),
|
||||
pushToNextWidget: ()=> DeviceDisplayBrightness.setBrightness(viewModel.brightness),
|
||||
popNextWidget: ()=> viewModel.increaseBrightness(),
|
||||
popWidget: ()=> DeviceDisplayBrightness.setBrightness(viewModel.brightness),
|
||||
child: ScrollableWithBottomSection(
|
||||
return ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.all(24),
|
||||
content: Column(
|
||||
children: [
|
||||
|
@ -168,7 +163,7 @@ class IoniaGiftCardDetailPage extends BasePage {
|
|||
},
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildIoniaTile(BuildContext context, {required String title, required String subTitle}) {
|
||||
|
|
|
@ -38,6 +38,14 @@ class NewWalletPage extends BasePage {
|
|||
@override
|
||||
String get title => S.current.new_wallet;
|
||||
|
||||
@override
|
||||
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.focusedChild?.unfocus();
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) => WalletNameForm(
|
||||
_walletNewVM,
|
||||
|
|
|
@ -34,6 +34,14 @@ class NewWalletTypePage extends BasePage {
|
|||
String get title =>
|
||||
isCreate ? S.current.wallet_list_create_new_wallet : S.current.wallet_list_restore_wallet;
|
||||
|
||||
@override
|
||||
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.focusedChild?.unfocus();
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) => WalletTypeForm(
|
||||
onTypeSelected: onTypeSelected,
|
||||
|
|
|
@ -21,6 +21,14 @@ class RestoreFromBackupPage extends BasePage {
|
|||
@override
|
||||
String get title => S.current.restore_title_from_backup;
|
||||
|
||||
@override
|
||||
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.focusedChild?.unfocus();
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
reaction((_) => restoreFromBackupViewModel.state, (ExecutionState state) {
|
||||
|
|
|
@ -101,6 +101,14 @@ class WalletRestorePage extends BasePage {
|
|||
// String? derivationPath = null;
|
||||
DerivationInfo? derivationInfo;
|
||||
|
||||
@override
|
||||
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.focusedChild?.unfocus();
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
reaction((_) => walletRestoreViewModel.state, (ExecutionState state) {
|
||||
|
|
|
@ -66,6 +66,14 @@ class SendPage extends BasePage {
|
|||
@override
|
||||
bool get extendBodyBehindAppBar => true;
|
||||
|
||||
@override
|
||||
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.focusedChild?.unfocus();
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Widget? leading(BuildContext context) {
|
||||
final _backButton = Icon(
|
||||
|
|
|
@ -32,6 +32,14 @@ class SendTemplatePage extends BasePage {
|
|||
@override
|
||||
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
||||
|
||||
@override
|
||||
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus) {
|
||||
currentFocus.focusedChild?.unfocus();
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Widget trailing(context) => Observer(builder: (_) {
|
||||
return sendTemplateViewModel.recipients.length > 1
|
||||
|
|
|
@ -10,10 +10,10 @@ class RouteAwareWidget extends StatefulWidget {
|
|||
this.popNextWidget});
|
||||
|
||||
final Widget child;
|
||||
final Function()? pushToWidget;
|
||||
final Function()? pushToNextWidget;
|
||||
final Function()? popWidget;
|
||||
final Function()? popNextWidget;
|
||||
final Function(BuildContext context)? pushToWidget;
|
||||
final Function(BuildContext context)? pushToNextWidget;
|
||||
final Function(BuildContext context)? popWidget;
|
||||
final Function(BuildContext context)? popNextWidget;
|
||||
|
||||
@override
|
||||
State<RouteAwareWidget> createState() => RouteAwareWidgetState();
|
||||
|
@ -35,28 +35,28 @@ class RouteAwareWidgetState extends State<RouteAwareWidget> with RouteAware {
|
|||
@override
|
||||
void didPush() {
|
||||
if (widget.pushToWidget != null) {
|
||||
widget.pushToWidget!();
|
||||
widget.pushToWidget!(context);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didPushNext() {
|
||||
if (widget.pushToNextWidget != null) {
|
||||
widget.pushToNextWidget!();
|
||||
widget.pushToNextWidget!(context);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didPop() {
|
||||
if (widget.popWidget != null) {
|
||||
widget.popWidget!();
|
||||
widget.popWidget!(context);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didPopNext() {
|
||||
if (widget.popNextWidget != null) {
|
||||
widget.popNextWidget!();
|
||||
widget.popNextWidget!(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue