Merge pull request #819 from cypherstack/add_frost

Hide FROST coins behind a frostEnabled pref
This commit is contained in:
Diego Salazar 2024-03-25 17:32:46 -06:00 committed by GitHub
commit d37c4d88d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 126 additions and 71 deletions

View file

@ -134,9 +134,18 @@ class _AddWalletViewState extends ConsumerState<AddWalletView> {
_coins.remove(Coin.wownero);
}
// Remove FROST from the list of coins based on our frostEnabled preference.
if (!ref.read(prefsChangeNotifierProvider).frostEnabled) {
_coins.remove(Coin.bitcoinFrost);
}
coinEntities.addAll(_coins.map((e) => CoinEntity(e)));
if (ref.read(prefsChangeNotifierProvider).showTestNetCoins) {
if (!ref.read(prefsChangeNotifierProvider).frostEnabled) {
_coinsTestnet.remove(Coin.bitcoinFrostTestNet);
}
coinEntities.addAll(_coinsTestnet.map((e) => CoinEntity(e)));
}

View file

@ -10,11 +10,10 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/providers/global/debug_service_provider.dart';
import 'package:stackwallet/providers/providers.dart';
@ -22,10 +21,8 @@ import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/onetime_popups/tor_has_been_add_dialog.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
class HiddenSettings extends StatelessWidget {
@ -39,27 +36,25 @@ class HiddenSettings extends StatelessWidget {
child: Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
appBar: AppBar(
leading: Util.isDesktop
? Padding(
padding: const EdgeInsets.all(8.0),
child: AppBarIconButton(
size: 32,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
shadows: const [],
icon: SvgPicture.asset(
Assets.svg.arrowLeft,
width: 18,
height: 18,
color: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
),
onPressed: Navigator.of(context).pop,
),
)
: Container(),
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: AppBarIconButton(
size: 32,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
shadows: const [],
icon: SvgPicture.asset(
Assets.svg.arrowLeft,
width: 18,
height: 18,
color: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
),
onPressed: Navigator.of(context).pop,
),
),
title: Text(
"Dev options",
style: STextStyles.navBarTitle(context),
@ -176,49 +171,48 @@ class HiddenSettings extends StatelessWidget {
const SizedBox(
height: 12,
),
Consumer(builder: (_, ref, __) {
return GestureDetector(
onTap: () async {
await showOneTimeTorHasBeenAddedDialogIfRequired(
context,
);
},
child: RoundedWhiteContainer(
child: Text(
"Test tor stacy popup",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
),
),
);
}),
const SizedBox(
height: 12,
),
Consumer(builder: (_, ref, __) {
return GestureDetector(
onTap: () async {
final box = await Hive.openBox<bool>(
DB.boxNameOneTimeDialogsShown);
await box.clear();
},
child: RoundedWhiteContainer(
child: Text(
"Reset tor stacy popup",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
),
),
);
}),
const SizedBox(
height: 12,
),
// Consumer(builder: (_, ref, __) {
// return GestureDetector(
// onTap: () async {
// await showOneTimeTorHasBeenAddedDialogIfRequired(
// context,
// );
// },
// child: RoundedWhiteContainer(
// child: Text(
// "Test tor stacy popup",
// style: STextStyles.button(context).copyWith(
// color: Theme.of(context)
// .extension<StackColors>()!
// .accentColorDark),
// ),
// ),
// );
// }),
// const SizedBox(
// height: 12,
// ),
// Consumer(builder: (_, ref, __) {
// return GestureDetector(
// onTap: () async {
// final box = await Hive.openBox<bool>(
// DB.boxNameOneTimeDialogsShown);
// await box.clear();
// },
// child: RoundedWhiteContainer(
// child: Text(
// "Reset tor stacy popup",
// style: STextStyles.button(context).copyWith(
// color: Theme.of(context)
// .extension<StackColors>()!
// .accentColorDark),
// ),
// ),
// );
// }),
// const SizedBox(
// height: 12,
// ),
Consumer(
builder: (_, ref, __) {
if (ref.watch(prefsChangeNotifierProvider
@ -252,6 +246,36 @@ class HiddenSettings extends StatelessWidget {
}
},
),
Consumer(
builder: (_, ref, __) {
return GestureDetector(
onTap: () async {
ref
.read(prefsChangeNotifierProvider)
.frostEnabled =
!(ref
.read(prefsChangeNotifierProvider)
.frostEnabled);
if (kDebugMode) {
print(
"FROST enabled: ${ref.read(prefsChangeNotifierProvider).frostEnabled}");
}
},
child: RoundedWhiteContainer(
child: Text(
"Toggle FROST multisig",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
),
),
);
},
),
const SizedBox(
height: 12,
),
Consumer(
builder: (_, ref, __) {
return GestureDetector(

View file

@ -68,6 +68,7 @@ class Prefs extends ChangeNotifier {
await _setMaxDecimals();
_useTor = await _getUseTor();
_fusionServerInfo = await _getFusionServerInfo();
_frostEnabled = await _getFrostEnabled();
_initialized = true;
}
@ -1008,4 +1009,25 @@ class Prefs extends ChangeNotifier {
return actualMap;
}
// FROST multisig
bool _frostEnabled = false;
bool get frostEnabled => _frostEnabled;
set frostEnabled(bool frostEnabled) {
if (_frostEnabled != frostEnabled) {
DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "frostEnabled", value: frostEnabled);
_frostEnabled = frostEnabled;
notifyListeners();
}
}
Future<bool> _getFrostEnabled() async {
return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "frostEnabled") as bool? ??
false;
}
}

View file

@ -528,8 +528,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "2897c6448e131241d4d91fe23fdab83305134225"
resolved-ref: "2897c6448e131241d4d91fe23fdab83305134225"
ref: "9e9441fc1e9ace8907256fff05fe2c607b0933b6"
resolved-ref: "9e9441fc1e9ace8907256fff05fe2c607b0933b6"
url: "https://github.com/cypherstack/electrum_adapter.git"
source: git
version: "3.0.0"

View file

@ -179,7 +179,7 @@ dependencies:
electrum_adapter:
git:
url: https://github.com/cypherstack/electrum_adapter.git
ref: 2897c6448e131241d4d91fe23fdab83305134225
ref: 9e9441fc1e9ace8907256fff05fe2c607b0933b6
stream_channel: ^2.1.0
dev_dependencies: