mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-01 01:47:41 +00:00
287c2d8b60
* unfocus text fields when push to next one * unfocus when push to next from new wallet / restore pages[skip ci]]
65 lines
1.5 KiB
Dart
65 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:cake_wallet/main.dart';
|
|
|
|
class RouteAwareWidget extends StatefulWidget {
|
|
RouteAwareWidget(
|
|
{required this.child,
|
|
this.pushToWidget,
|
|
this.pushToNextWidget,
|
|
this.popWidget,
|
|
this.popNextWidget});
|
|
|
|
final Widget child;
|
|
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();
|
|
}
|
|
|
|
class RouteAwareWidgetState extends State<RouteAwareWidget> with RouteAware {
|
|
@override
|
|
void didChangeDependencies() {
|
|
super.didChangeDependencies();
|
|
routeObserver.subscribe(this, ModalRoute.of(context) as PageRoute);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
routeObserver.unsubscribe(this);
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
void didPush() {
|
|
if (widget.pushToWidget != null) {
|
|
widget.pushToWidget!(context);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void didPushNext() {
|
|
if (widget.pushToNextWidget != null) {
|
|
widget.pushToNextWidget!(context);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void didPop() {
|
|
if (widget.popWidget != null) {
|
|
widget.popWidget!(context);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void didPopNext() {
|
|
if (widget.popNextWidget != null) {
|
|
widget.popNextWidget!(context);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => widget.child;
|
|
}
|