mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-23 19:16:09 +00:00
Merge pull request #608 from cake-tech/CW-167-Custom-redeem-screens-fix
CW-258 fix increasing brightness
This commit is contained in:
commit
501e62829b
3 changed files with 76 additions and 7 deletions
|
@ -41,6 +41,7 @@ import 'package:cake_wallet/wallet_type_utils.dart';
|
||||||
|
|
||||||
final navigatorKey = GlobalKey<NavigatorState>();
|
final navigatorKey = GlobalKey<NavigatorState>();
|
||||||
final rootKey = GlobalKey<RootState>();
|
final rootKey = GlobalKey<RootState>();
|
||||||
|
final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
try {
|
try {
|
||||||
|
@ -279,6 +280,7 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||||
navigatorKey: navigatorKey,
|
navigatorKey: navigatorKey,
|
||||||
authService: authService,
|
authService: authService,
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
|
navigatorObservers: [routeObserver],
|
||||||
navigatorKey: navigatorKey,
|
navigatorKey: navigatorKey,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: settingsStore.theme,
|
theme: settingsStore.theme,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||||
import 'package:cake_wallet/typography.dart';
|
import 'package:cake_wallet/typography.dart';
|
||||||
import 'package:cake_wallet/utils/show_bar.dart';
|
import 'package:cake_wallet/utils/show_bar.dart';
|
||||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||||
|
import 'package:cake_wallet/utils/route_aware.dart';
|
||||||
import 'package:cake_wallet/view_model/ionia/ionia_gift_card_details_view_model.dart';
|
import 'package:cake_wallet/view_model/ionia/ionia_gift_card_details_view_model.dart';
|
||||||
import 'package:device_display_brightness/device_display_brightness.dart';
|
import 'package:device_display_brightness/device_display_brightness.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -47,10 +48,7 @@ class IoniaGiftCardDetailPage extends BasePage {
|
||||||
//highlightColor: Colors.transparent,
|
//highlightColor: Colors.transparent,
|
||||||
//splashColor: Colors.transparent,
|
//splashColor: Colors.transparent,
|
||||||
//padding: EdgeInsets.all(0),
|
//padding: EdgeInsets.all(0),
|
||||||
onPressed: () {
|
onPressed: ()=> onClose(context),
|
||||||
onClose(context);
|
|
||||||
DeviceDisplayBrightness.setBrightness(viewModel.brightness);
|
|
||||||
},
|
|
||||||
child: _backButton),
|
child: _backButton),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -68,7 +66,6 @@ class IoniaGiftCardDetailPage extends BasePage {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
viewModel.increaseBrightness();
|
|
||||||
reaction((_) => viewModel.redeemState, (ExecutionState state) {
|
reaction((_) => viewModel.redeemState, (ExecutionState state) {
|
||||||
if (state is FailureState) {
|
if (state is FailureState) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
@ -85,7 +82,12 @@ class IoniaGiftCardDetailPage extends BasePage {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return ScrollableWithBottomSection(
|
return RouteAwareWidget(
|
||||||
|
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: [
|
||||||
|
@ -164,7 +166,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}) {
|
||||||
|
|
65
lib/utils/route_aware.dart
Normal file
65
lib/utils/route_aware.dart
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
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()? pushToWidget;
|
||||||
|
final Function()? pushToNextWidget;
|
||||||
|
final Function()? popWidget;
|
||||||
|
final Function()? 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!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didPushNext() {
|
||||||
|
if (widget.pushToNextWidget != null) {
|
||||||
|
widget.pushToNextWidget!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didPop() {
|
||||||
|
if (widget.popWidget != null) {
|
||||||
|
widget.popWidget!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didPopNext() {
|
||||||
|
if (widget.popNextWidget != null) {
|
||||||
|
widget.popNextWidget!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => widget.child;
|
||||||
|
}
|
Loading…
Reference in a new issue