diff --git a/lib/src/screens/receive/anonpay_receive_page.dart b/lib/src/screens/receive/anonpay_receive_page.dart index 4deae7972..3b8aef121 100644 --- a/lib/src/screens/receive/anonpay_receive_page.dart +++ b/lib/src/screens/receive/anonpay_receive_page.dart @@ -12,6 +12,7 @@ import 'package:cake_wallet/themes/theme_base.dart'; import 'package:device_display_brightness/device_display_brightness.dart'; import 'package:flutter/material.dart'; import 'package:qr_flutter/qr_flutter.dart' as qr; +import 'package:screen_brightness/screen_brightness.dart'; class AnonPayReceivePage extends BasePage { final AnonpayInfoBase invoiceInfo; @@ -44,10 +45,7 @@ class AnonPayReceivePage extends BasePage { fontSize: 18.0, fontWeight: FontWeight.bold, fontFamily: 'Lato', - color: Theme.of(context) - .accentTextTheme! - .displayMedium! - .backgroundColor!), + color: Theme.of(context).accentTextTheme!.displayMedium!.backgroundColor!), ), Text( invoiceInfo is AnonpayInvoiceInfo @@ -78,10 +76,7 @@ class AnonPayReceivePage extends BasePage { ), icon: Icon( Icons.edit, - color: Theme.of(context) - .accentTextTheme! - .bodySmall! - .color!, + color: Theme.of(context).accentTextTheme!.bodySmall!.color!, size: 22.0, ), ), @@ -115,19 +110,17 @@ class AnonPayReceivePage extends BasePage { ), child: GestureDetector( onTap: () async { - final double brightness = await DeviceDisplayBrightness.getBrightness(); + final double brightness = await ScreenBrightness().current; // ignore: unawaited_futures - DeviceDisplayBrightness.setBrightness(1.0); - await Navigator.pushNamed( - context, - Routes.fullscreenQR, - arguments: QrViewData(data: invoiceInfo.clearnetUrl, - version: qr.QrVersions.auto, - ) - ); + await ScreenBrightness().setScreenBrightness(1.0); + await Navigator.pushNamed(context, Routes.fullscreenQR, + arguments: QrViewData( + data: invoiceInfo.clearnetUrl, + version: qr.QrVersions.auto, + )); // ignore: unawaited_futures - DeviceDisplayBrightness.setBrightness(brightness); + await ScreenBrightness().setScreenBrightness(brightness); }, child: Hero( tag: Key(invoiceInfo.clearnetUrl), @@ -139,10 +132,8 @@ class AnonPayReceivePage extends BasePage { decoration: BoxDecoration( border: Border.all( width: 3, - color: Theme.of(context) - .accentTextTheme! - .displayMedium! - .backgroundColor!, + color: + Theme.of(context).accentTextTheme!.displayMedium!.backgroundColor!, ), ), child: QrImage( diff --git a/lib/src/screens/receive/widgets/qr_widget.dart b/lib/src/screens/receive/widgets/qr_widget.dart index 70a8e48bc..0b1b85b2e 100644 --- a/lib/src/screens/receive/widgets/qr_widget.dart +++ b/lib/src/screens/receive/widgets/qr_widget.dart @@ -12,6 +12,7 @@ import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart'; import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart'; +import 'package:screen_brightness/screen_brightness.dart'; class QRWidget extends StatelessWidget { QRWidget({ @@ -194,14 +195,14 @@ class QRWidget extends StatelessWidget { } // Get the current brightness: - final brightness = await DeviceDisplayBrightness.getBrightness(); + final brightness = await ScreenBrightness().current; // ignore: unawaited_futures - DeviceDisplayBrightness.setBrightness(1.0); + await ScreenBrightness().setScreenBrightness(1.0); await navigation(); // ignore: unawaited_futures - DeviceDisplayBrightness.setBrightness(brightness); + await ScreenBrightness().setScreenBrightness(brightness); } } diff --git a/lib/src/screens/wallet_keys/wallet_keys_page.dart b/lib/src/screens/wallet_keys/wallet_keys_page.dart index 63efdc5f9..fa562a23b 100644 --- a/lib/src/screens/wallet_keys/wallet_keys_page.dart +++ b/lib/src/screens/wallet_keys/wallet_keys_page.dart @@ -13,6 +13,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:qr_flutter/qr_flutter.dart'; +import 'package:screen_brightness/screen_brightness.dart'; class WalletKeysPage extends BasePage { WalletKeysPage(this.walletKeysViewModel); @@ -26,18 +27,18 @@ class WalletKeysPage extends BasePage { Widget trailing(BuildContext context) => IconButton( onPressed: () async { // Get the current brightness: - final double brightness = await DeviceDisplayBrightness.getBrightness(); + final double brightness = await ScreenBrightness().current; final url = await walletKeysViewModel.url; // ignore: unawaited_futures - DeviceDisplayBrightness.setBrightness(1.0); + await ScreenBrightness().setScreenBrightness(1.0); await Navigator.pushNamed( context, Routes.fullscreenQR, arguments: QrViewData(data: url.toString(), version: QrVersions.auto), ); // ignore: unawaited_futures - DeviceDisplayBrightness.setBrightness(brightness); + await ScreenBrightness().setScreenBrightness(brightness); }, splashColor: Colors.transparent, highlightColor: Colors.transparent, @@ -48,62 +49,60 @@ class WalletKeysPage extends BasePage { @override Widget body(BuildContext context) { - return Column( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 24.0), - child: Container( - width: double.infinity, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12.0), - color: Theme.of(context).accentTextTheme.bodySmall!.color!, - ), - child: Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: AutoSizeText( - S.of(context).do_not_share_warning_text.toUpperCase(), - textAlign: TextAlign.center, - maxLines: 4, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.red)), - ), - ), + return Column(children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24.0), + child: Container( + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12.0), + color: Theme.of(context).accentTextTheme.bodySmall!.color!, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: AutoSizeText(S.of(context).do_not_share_warning_text.toUpperCase(), + textAlign: TextAlign.center, + maxLines: 4, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: Colors.red)), ), ), ), - Expanded( - flex: 7, + ), + ), + Expanded( + flex: 7, child: Container( - padding: EdgeInsets.only(top: 20.0, bottom: 20.0), - child: Observer( - builder: (_) { - return ListView.separated( - separatorBuilder: (context, index) => Container( - height: 1, - padding: EdgeInsets.only(left: 24), - color: Theme.of(context).accentTextTheme.titleLarge!.backgroundColor!, - child: const SectionDivider(), - ), - itemCount: walletKeysViewModel.items.length, - itemBuilder: (BuildContext context, int index) { - final item = walletKeysViewModel.items[index]; + padding: EdgeInsets.only(top: 20.0, bottom: 20.0), + child: Observer( + builder: (_) { + return ListView.separated( + separatorBuilder: (context, index) => Container( + height: 1, + padding: EdgeInsets.only(left: 24), + color: Theme.of(context).accentTextTheme.titleLarge!.backgroundColor!, + child: const SectionDivider(), + ), + itemCount: walletKeysViewModel.items.length, + itemBuilder: (BuildContext context, int index) { + final item = walletKeysViewModel.items[index]; - return GestureDetector( - onTap: () { - ClipboardUtil.setSensitiveDataToClipboard(ClipboardData(text: item.value)); - showBar(context, S.of(context).copied_key_to_clipboard(item.title)); - }, - child: ListRow( - title: item.title + ':', - value: item.value, - ), - ); - }); - }, - )))]); + return GestureDetector( + onTap: () { + ClipboardUtil.setSensitiveDataToClipboard( + ClipboardData(text: item.value)); + showBar( + context, S.of(context).copied_key_to_clipboard(item.title)); + }, + child: ListRow( + title: item.title + ':', + value: item.value, + ), + ); + }); + }, + ))) + ]); } } diff --git a/lib/view_model/ionia/ionia_gift_card_details_view_model.dart b/lib/view_model/ionia/ionia_gift_card_details_view_model.dart index cbf5ebc78..d548dc4d6 100644 --- a/lib/view_model/ionia/ionia_gift_card_details_view_model.dart +++ b/lib/view_model/ionia/ionia_gift_card_details_view_model.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/ionia/ionia_service.dart'; import 'package:cake_wallet/ionia/ionia_gift_card.dart'; import 'package:mobx/mobx.dart'; import 'package:device_display_brightness/device_display_brightness.dart'; +import 'package:screen_brightness/screen_brightness.dart'; part 'ionia_gift_card_details_view_model.g.dart'; @@ -48,7 +49,7 @@ abstract class IoniaGiftCardDetailsViewModelBase with Store { } void increaseBrightness() async { - brightness = await DeviceDisplayBrightness.getBrightness(); - await DeviceDisplayBrightness.setBrightness(1.0); + brightness = await ScreenBrightness().current; + await ScreenBrightness().setScreenBrightness(1.0); } } diff --git a/pubspec_base.yaml b/pubspec_base.yaml index c64100280..60fe0d91d 100644 --- a/pubspec_base.yaml +++ b/pubspec_base.yaml @@ -66,7 +66,8 @@ dependencies: unorm_dart: ^0.2.0 # check unorm_dart for usage and for replace permission_handler: ^10.0.0 - device_display_brightness: ^0.0.6 + # device_display_brightness: ^0.0.6 + screen_brightness: ^0.2.2 workmanager: ^0.5.1 platform_device_id: ^1.0.1 wakelock: ^0.6.2