mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
Ignore increasing brightness for non-mobile platforms
This commit is contained in:
parent
6b2bf313a3
commit
b6666ca405
2 changed files with 37 additions and 17 deletions
|
@ -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<void> changeBrightnessForRoute(Future<void> 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);
|
||||
}
|
||||
}
|
||||
|
|
3
lib/utils/constants.dart
Normal file
3
lib/utils/constants.dart
Normal file
|
@ -0,0 +1,3 @@
|
|||
class ConstValues {
|
||||
static const int minimumDesktopWidth = 900;
|
||||
}
|
Loading…
Reference in a new issue