mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-29 04:49:51 +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/themes/theme_base.dart';
|
||||||
|
import 'package:cake_wallet/utils/route_aware.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cake_wallet/di.dart';
|
import 'package:cake_wallet/di.dart';
|
||||||
|
@ -32,6 +33,14 @@ abstract class BasePage extends StatelessWidget {
|
||||||
|
|
||||||
Widget? get endDrawer => null;
|
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;
|
AppBarStyle get appBarStyle => AppBarStyle.regular;
|
||||||
|
|
||||||
Widget Function(BuildContext, Widget)? get rootWrapper => null;
|
Widget Function(BuildContext, Widget)? get rootWrapper => null;
|
||||||
|
@ -162,15 +171,21 @@ abstract class BasePage extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final root = Scaffold(
|
final root = RouteAwareWidget(
|
||||||
key: _scaffoldKey,
|
child: Scaffold(
|
||||||
backgroundColor: pageBackgroundColor(context),
|
key: _scaffoldKey,
|
||||||
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
|
backgroundColor: pageBackgroundColor(context),
|
||||||
extendBodyBehindAppBar: extendBodyBehindAppBar,
|
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
|
||||||
endDrawer: endDrawer,
|
extendBodyBehindAppBar: extendBodyBehindAppBar,
|
||||||
appBar: appBar(context),
|
endDrawer: endDrawer,
|
||||||
body: body(context),
|
appBar: appBar(context),
|
||||||
floatingActionButton: floatingActionButton(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;
|
return rootWrapper?.call(context, root) ?? root;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,14 @@ class ExchangePage extends BasePage {
|
||||||
@override
|
@override
|
||||||
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||||
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||||
|
if (!currentFocus.hasPrimaryFocus) {
|
||||||
|
currentFocus.focusedChild?.unfocus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget middle(BuildContext context) => Row(
|
Widget middle(BuildContext context) => Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
|
|
@ -84,12 +84,7 @@ class IoniaGiftCardDetailPage extends BasePage {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return RouteAwareWidget(
|
return ScrollableWithBottomSection(
|
||||||
pushToWidget: ()=> viewModel.increaseBrightness(),
|
|
||||||
pushToNextWidget: ()=> DeviceDisplayBrightness.setBrightness(viewModel.brightness),
|
|
||||||
popNextWidget: ()=> viewModel.increaseBrightness(),
|
|
||||||
popWidget: ()=> DeviceDisplayBrightness.setBrightness(viewModel.brightness),
|
|
||||||
child: ScrollableWithBottomSection(
|
|
||||||
contentPadding: EdgeInsets.all(24),
|
contentPadding: EdgeInsets.all(24),
|
||||||
content: Column(
|
content: Column(
|
||||||
children: [
|
children: [
|
||||||
|
@ -168,7 +163,7 @@ class IoniaGiftCardDetailPage extends BasePage {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildIoniaTile(BuildContext context, {required String title, required String subTitle}) {
|
Widget buildIoniaTile(BuildContext context, {required String title, required String subTitle}) {
|
||||||
|
|
|
@ -38,6 +38,14 @@ class NewWalletPage extends BasePage {
|
||||||
@override
|
@override
|
||||||
String get title => S.current.new_wallet;
|
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
|
@override
|
||||||
Widget body(BuildContext context) => WalletNameForm(
|
Widget body(BuildContext context) => WalletNameForm(
|
||||||
_walletNewVM,
|
_walletNewVM,
|
||||||
|
|
|
@ -34,6 +34,14 @@ class NewWalletTypePage extends BasePage {
|
||||||
String get title =>
|
String get title =>
|
||||||
isCreate ? S.current.wallet_list_create_new_wallet : S.current.wallet_list_restore_wallet;
|
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
|
@override
|
||||||
Widget body(BuildContext context) => WalletTypeForm(
|
Widget body(BuildContext context) => WalletTypeForm(
|
||||||
onTypeSelected: onTypeSelected,
|
onTypeSelected: onTypeSelected,
|
||||||
|
|
|
@ -21,6 +21,14 @@ class RestoreFromBackupPage extends BasePage {
|
||||||
@override
|
@override
|
||||||
String get title => S.current.restore_title_from_backup;
|
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
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
reaction((_) => restoreFromBackupViewModel.state, (ExecutionState state) {
|
reaction((_) => restoreFromBackupViewModel.state, (ExecutionState state) {
|
||||||
|
|
|
@ -101,6 +101,14 @@ class WalletRestorePage extends BasePage {
|
||||||
// String? derivationPath = null;
|
// String? derivationPath = null;
|
||||||
DerivationInfo? derivationInfo;
|
DerivationInfo? derivationInfo;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||||
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||||
|
if (!currentFocus.hasPrimaryFocus) {
|
||||||
|
currentFocus.focusedChild?.unfocus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
reaction((_) => walletRestoreViewModel.state, (ExecutionState state) {
|
reaction((_) => walletRestoreViewModel.state, (ExecutionState state) {
|
||||||
|
|
|
@ -66,6 +66,14 @@ class SendPage extends BasePage {
|
||||||
@override
|
@override
|
||||||
bool get extendBodyBehindAppBar => true;
|
bool get extendBodyBehindAppBar => true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||||
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||||
|
if (!currentFocus.hasPrimaryFocus) {
|
||||||
|
currentFocus.focusedChild?.unfocus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget? leading(BuildContext context) {
|
Widget? leading(BuildContext context) {
|
||||||
final _backButton = Icon(
|
final _backButton = Icon(
|
||||||
|
|
|
@ -32,6 +32,14 @@ class SendTemplatePage extends BasePage {
|
||||||
@override
|
@override
|
||||||
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Function(BuildContext)? get pushToNextWidget => (context) {
|
||||||
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||||
|
if (!currentFocus.hasPrimaryFocus) {
|
||||||
|
currentFocus.focusedChild?.unfocus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget trailing(context) => Observer(builder: (_) {
|
Widget trailing(context) => Observer(builder: (_) {
|
||||||
return sendTemplateViewModel.recipients.length > 1
|
return sendTemplateViewModel.recipients.length > 1
|
||||||
|
|
|
@ -10,10 +10,10 @@ class RouteAwareWidget extends StatefulWidget {
|
||||||
this.popNextWidget});
|
this.popNextWidget});
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final Function()? pushToWidget;
|
final Function(BuildContext context)? pushToWidget;
|
||||||
final Function()? pushToNextWidget;
|
final Function(BuildContext context)? pushToNextWidget;
|
||||||
final Function()? popWidget;
|
final Function(BuildContext context)? popWidget;
|
||||||
final Function()? popNextWidget;
|
final Function(BuildContext context)? popNextWidget;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RouteAwareWidget> createState() => RouteAwareWidgetState();
|
State<RouteAwareWidget> createState() => RouteAwareWidgetState();
|
||||||
|
@ -35,28 +35,28 @@ class RouteAwareWidgetState extends State<RouteAwareWidget> with RouteAware {
|
||||||
@override
|
@override
|
||||||
void didPush() {
|
void didPush() {
|
||||||
if (widget.pushToWidget != null) {
|
if (widget.pushToWidget != null) {
|
||||||
widget.pushToWidget!();
|
widget.pushToWidget!(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didPushNext() {
|
void didPushNext() {
|
||||||
if (widget.pushToNextWidget != null) {
|
if (widget.pushToNextWidget != null) {
|
||||||
widget.pushToNextWidget!();
|
widget.pushToNextWidget!(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didPop() {
|
void didPop() {
|
||||||
if (widget.popWidget != null) {
|
if (widget.popWidget != null) {
|
||||||
widget.popWidget!();
|
widget.popWidget!(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didPopNext() {
|
void didPopNext() {
|
||||||
if (widget.popNextWidget != null) {
|
if (widget.popNextWidget != null) {
|
||||||
widget.popNextWidget!();
|
widget.popNextWidget!(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue