increase brightness for gift card detail page (#478)

* increase brightness for gift card detail page

* move logic to view model

* fix format
This commit is contained in:
Serhii 2022-08-30 17:01:45 +03:00 committed by GitHub
parent 31a57fc4d3
commit 4a5747c630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -13,6 +13,7 @@ import 'package:cake_wallet/typography.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.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:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/src/widgets/framework.dart';
@ -25,6 +26,8 @@ class IoniaGiftCardDetailPage extends BasePage {
final IoniaGiftCardDetailsViewModel viewModel;
@override
Widget leading(BuildContext context) {
if (ModalRoute.of(context).isFirst) {
@ -47,7 +50,10 @@ class IoniaGiftCardDetailPage extends BasePage {
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
padding: EdgeInsets.all(0),
onPressed: () => onClose(context),
onPressed: () {
onClose(context);
DeviceDisplayBrightness.setBrightness(viewModel.brightness);
},
child: _backButton),
),
),
@ -64,6 +70,7 @@ class IoniaGiftCardDetailPage extends BasePage {
@override
Widget body(BuildContext context) {
viewModel.increaseBrightness();
reaction((_) => viewModel.redeemState, (ExecutionState state) {
if (state is FailureState) {
WidgetsBinding.instance.addPostFrameCallback((_) {

View file

@ -2,6 +2,7 @@ import 'package:cake_wallet/core/execution_state.dart';
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';
part 'ionia_gift_card_details_view_model.g.dart';
@ -14,6 +15,7 @@ abstract class IoniaGiftCardDetailsViewModelBase with Store {
}
final IoniaService ioniaService;
double brightness;
@observable
IoniaGiftCard giftCard;
@ -32,4 +34,9 @@ abstract class IoniaGiftCardDetailsViewModelBase with Store {
redeemState = FailureState(e.toString());
}
}
void increaseBrightness() async {
brightness = await DeviceDisplayBrightness.getBrightness();
await DeviceDisplayBrightness.setBrightness(1.0);
}
}