diff --git a/lib/src/screens/receive/widgets/qr_widget.dart b/lib/src/screens/receive/widgets/qr_widget.dart index 99bea1adc..5640e7590 100644 --- a/lib/src/screens/receive/widgets/qr_widget.dart +++ b/lib/src/screens/receive/widgets/qr_widget.dart @@ -1,8 +1,9 @@ +import 'dart:io'; + import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/utils/show_bar.dart'; import 'package:device_display_brightness/device_display_brightness.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:cake_wallet/generated/i18n.dart'; @@ -59,22 +60,17 @@ class QRWidget extends StatelessWidget { builder: (_) => Flexible( flex: 5, child: GestureDetector( - onTap: () async { - // Get the current brightness: - final double brightness = await DeviceDisplayBrightness.getBrightness(); - - // ignore: unawaited_futures - DeviceDisplayBrightness.setBrightness(1.0); - await Navigator.pushNamed( - context, - Routes.fullscreenQR, - arguments: { - 'qrData': addressListViewModel.uri.toString(), - 'isLight': isLight, - }, - ); - // ignore: unawaited_futures - DeviceDisplayBrightness.setBrightness(brightness); + onTap: () { + changeBrightnessForRoute(() async { + await Navigator.pushNamed( + context, + Routes.fullscreenQR, + arguments: { + 'qrData': addressListViewModel.uri.toString(), + 'isLight': isLight, + }, + ); + }); }, child: Hero( tag: Key(addressListViewModel.uri.toString()), @@ -173,4 +169,25 @@ class QRWidget extends StatelessWidget { ], ); } + + Future changeBrightnessForRoute(Future Function() navigation) async { + final isMobile = Platform.isIOS || Platform.isAndroid; + + // if not mobile, just navigate + if (!isMobile) { + navigation(); + return; + } + + // Get the current brightness: + final brightness = await DeviceDisplayBrightness.getBrightness(); + + // ignore: unawaited_futures + DeviceDisplayBrightness.setBrightness(1.0); + + await navigation(); + + // ignore: unawaited_futures + DeviceDisplayBrightness.setBrightness(brightness); + } } diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart new file mode 100644 index 000000000..ff8d60b9c --- /dev/null +++ b/lib/utils/constants.dart @@ -0,0 +1,3 @@ +class ConstValues { + static const int minimumDesktopWidth = 900; +} \ No newline at end of file