Merge branch 'main' of https://github.com/cake-tech/cake_wallet into cw_linux_direct_input_password

This commit is contained in:
OmarHatem 2023-09-22 19:11:26 +03:00
commit f3e8767203
6 changed files with 92 additions and 80 deletions

View file

@ -132,6 +132,9 @@ class NodeForm extends StatelessWidget {
Observer(
builder: (_) => StandardCheckbox(
value: nodeViewModel.useSSL,
gradientBackground: true,
borderColor: Theme.of(context).dividerColor,
iconColor: Colors.white,
onChanged: (value) => nodeViewModel.useSSL = value,
caption: S.of(context).use_ssl,
),
@ -148,6 +151,9 @@ class NodeForm extends StatelessWidget {
Observer(
builder: (_) => StandardCheckbox(
value: nodeViewModel.trusted,
gradientBackground: true,
borderColor: Theme.of(context).dividerColor,
iconColor: Colors.white,
onChanged: (value) => nodeViewModel.trusted = value,
caption: S.of(context).trusted,
),
@ -166,6 +172,9 @@ class NodeForm extends StatelessWidget {
children: [
StandardCheckbox(
value: nodeViewModel.useSocksProxy,
gradientBackground: true,
borderColor: Theme.of(context).dividerColor,
iconColor: Colors.white,
onChanged: (value) {
if (!value) {
_socksAddressController.text = '';

View file

@ -10,7 +10,7 @@ import 'package:cake_wallet/src/screens/receive/widgets/anonpay_status_section.d
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
import 'package:cake_wallet/src/screens/receive/widgets/copy_link_item.dart';
import 'package:cake_wallet/themes/extensions/qr_code_theme.dart';
import 'package:device_display_brightness/device_display_brightness.dart';
import 'package:cake_wallet/utils/brightness_util.dart';
import 'package:flutter/material.dart';
import 'package:qr_flutter/qr_flutter.dart' as qr;
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
@ -82,8 +82,7 @@ class AnonPayReceivePage extends BasePage {
@override
Widget Function(BuildContext, Widget) get rootWrapper =>
(BuildContext context, Widget scaffold) =>
GradientBackground(scaffold: scaffold);
(BuildContext context, Widget scaffold) => GradientBackground(scaffold: scaffold);
@override
Widget body(BuildContext context) {
@ -101,19 +100,13 @@ class AnonPayReceivePage extends BasePage {
),
child: GestureDetector(
onTap: () async {
final double brightness = await DeviceDisplayBrightness.getBrightness();
// ignore: unawaited_futures
DeviceDisplayBrightness.setBrightness(1.0);
await Navigator.pushNamed(
context,
Routes.fullscreenQR,
arguments: QrViewData(data: invoiceInfo.clearnetUrl,
BrightnessUtil.changeBrightnessForFunction(() async {
await Navigator.pushNamed(context, Routes.fullscreenQR,
arguments: QrViewData(
data: invoiceInfo.clearnetUrl,
version: qr.QrVersions.auto,
)
);
// ignore: unawaited_futures
DeviceDisplayBrightness.setBrightness(brightness);
));
});
},
child: Hero(
tag: Key(invoiceInfo.clearnetUrl),

View file

@ -3,10 +3,9 @@ import 'package:cake_wallet/themes/extensions/qr_code_theme.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
import 'package:cake_wallet/src/screens/receive/widgets/currency_input_field.dart';
import 'package:cake_wallet/utils/device_info.dart';
import 'package:cake_wallet/utils/brightness_util.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:device_display_brightness/device_display_brightness.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
@ -64,7 +63,7 @@ class QRWidget extends StatelessWidget {
flex: 5,
child: GestureDetector(
onTap: () {
changeBrightnessForRoute(
BrightnessUtil.changeBrightnessForFunction(
() async {
await Navigator.pushNamed(context, Routes.fullscreenQR,
arguments: QrViewData(
@ -178,23 +177,4 @@ class QRWidget extends StatelessWidget {
// update amount if currency changed
addressListViewModel.changeAmount(amountController.text);
}
Future<void> changeBrightnessForRoute(Future<void> Function() navigation) async {
// if not mobile, just navigate
if (!DeviceInfo.instance.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);
}
}

View file

@ -5,10 +5,10 @@ import 'package:cake_wallet/src/widgets/list_row.dart';
import 'package:cake_wallet/src/widgets/section_divider.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/utils/brightness_util.dart';
import 'package:cake_wallet/utils/clipboard_util.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/view_model/wallet_keys_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_mobx/flutter_mobx.dart';
@ -26,19 +26,15 @@ class WalletKeysPage extends BasePage {
@override
Widget trailing(BuildContext context) => IconButton(
onPressed: () async {
// Get the current brightness:
final double brightness = await DeviceDisplayBrightness.getBrightness();
final url = await walletKeysViewModel.url;
// ignore: unawaited_futures
DeviceDisplayBrightness.setBrightness(1.0);
BrightnessUtil.changeBrightnessForFunction(() async {
await Navigator.pushNamed(
context,
Routes.fullscreenQR,
arguments: QrViewData(data: url.toString(), version: QrVersions.auto),
);
// ignore: unawaited_futures
DeviceDisplayBrightness.setBrightness(brightness);
});
},
splashColor: Colors.transparent,
highlightColor: Colors.transparent,

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/src/widgets/standard_checkbox.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
@ -101,7 +102,7 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
height: 1,
)
: const SizedBox(),
itemCount: items == null || items.isEmpty ? 0 : items.length,
itemCount: items.isEmpty ? 0 : items.length,
itemBuilder: (context, index) => buildItem(index),
),
);
@ -112,19 +113,38 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
return GestureDetector(
onTap: () {
Navigator.of(context).pop();
if (item.isDisabled) {
return;
}
bool newValue = !item.value;
item.value = newValue;
widget.onChanged(index, newValue);
setState(() {});
},
child: Container(
height: 55,
color: Theme.of(context).dialogTheme.backgroundColor,
padding: EdgeInsets.only(left: 24, right: 24),
child: CheckboxListTile(
child: Row(
children: [
StandardCheckbox(
value: item.value,
activeColor: item.value
? Palette.blueCraiola
: Theme.of(context).extension<FilterTheme>()!.checkboxBackgroundColor,
checkColor: Colors.white,
title: widget.displayItem?.call(item) ??
gradientBackground: true,
borderColor: Theme.of(context).dividerColor,
iconColor: Colors.white,
onChanged: (bool? value) {
if (value == null || item.isDisabled) {
return;
}
item.value = value;
widget.onChanged(index, value);
setState(() {});
},
),
SizedBox(width: 16),
widget.displayItem?.call(item) ??
Text(
item.title,
style: TextStyle(
@ -136,17 +156,8 @@ class CheckBoxPickerState extends State<CheckBoxPicker> {
: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
decoration: TextDecoration.none,
),
),
onChanged: (bool? value) {
if (value == null) {
return;
}
item.value = value;
widget.onChanged(index, value);
setState(() {});
},
controlAffinity: ListTileControlAffinity.leading,
)
],
),
),
);

View file

@ -0,0 +1,23 @@
import 'package:cake_wallet/utils/device_info.dart';
import 'package:device_display_brightness/device_display_brightness.dart';
class BrightnessUtil {
static Future<void> changeBrightnessForFunction(Future<void> Function() func) async {
// if not mobile, just navigate
if (!DeviceInfo.instance.isMobile) {
func();
return;
}
// Get the current brightness:
final brightness = await DeviceDisplayBrightness.getBrightness();
// ignore: unawaited_futures
DeviceDisplayBrightness.setBrightness(1.0);
await func();
// ignore: unawaited_futures
DeviceDisplayBrightness.setBrightness(brightness);
}
}