mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
manual cherry picking
This commit is contained in:
parent
b776ba0678
commit
28efe3e18d
5 changed files with 101 additions and 18 deletions
|
@ -23,6 +23,7 @@ import 'package:stackwallet/providers/global/wallets_provider.dart';
|
|||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/wallet/mixins/cash_fusion.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
|
@ -54,6 +55,7 @@ class _CashFusionViewState extends ConsumerState<CashFusionView> {
|
|||
late final FocusNode portFocusNode;
|
||||
late final TextEditingController fusionRoundController;
|
||||
late final FocusNode fusionRoundFocusNode;
|
||||
Coin? coin;
|
||||
|
||||
bool _enableSSLCheckbox = false;
|
||||
bool _enableStartButton = false;
|
||||
|
@ -87,7 +89,11 @@ class _CashFusionViewState extends ConsumerState<CashFusionView> {
|
|||
);
|
||||
|
||||
// update user prefs (persistent)
|
||||
ref.read(prefsChangeNotifierProvider).fusionServerInfo = newInfo;
|
||||
if (coin == Coin.bitcoincash) {
|
||||
ref.read(prefsChangeNotifierProvider).fusionServerInfoBch = newInfo;
|
||||
} else {
|
||||
ref.read(prefsChangeNotifierProvider).fusionServerInfoXec = newInfo;
|
||||
}
|
||||
|
||||
unawaited(
|
||||
fusionWallet.fuse(
|
||||
|
@ -111,7 +117,16 @@ class _CashFusionViewState extends ConsumerState<CashFusionView> {
|
|||
portFocusNode = FocusNode();
|
||||
fusionRoundFocusNode = FocusNode();
|
||||
|
||||
final info = ref.read(prefsChangeNotifierProvider).fusionServerInfo;
|
||||
coin = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet
|
||||
.coin;
|
||||
|
||||
final info = (coin == Coin.bitcoincash)
|
||||
? ref.read(prefsChangeNotifierProvider).fusionServerInfoBch
|
||||
: ref.read(prefsChangeNotifierProvider).fusionServerInfoXec;
|
||||
|
||||
serverController.text = info.host;
|
||||
portController.text = info.port.toString();
|
||||
_enableSSLCheckbox = info.ssl;
|
||||
|
@ -212,7 +227,9 @@ class _CashFusionViewState extends ConsumerState<CashFusionView> {
|
|||
CustomTextButton(
|
||||
text: "Default",
|
||||
onTap: () {
|
||||
const def = FusionInfo.DEFAULTS;
|
||||
final def = (coin == Coin.bitcoincash)
|
||||
? FusionInfo.BCH_DEFAULTS
|
||||
: FusionInfo.XEC_DEFAULTS;
|
||||
serverController.text = def.host;
|
||||
portController.text = def.port.toString();
|
||||
fusionRoundController.text =
|
||||
|
|
|
@ -17,6 +17,7 @@ import 'package:stackwallet/providers/cash_fusion/fusion_progress_ui_state_provi
|
|||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/show_loading.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
|
@ -37,12 +38,13 @@ class FusionProgressView extends ConsumerStatefulWidget {
|
|||
static const routeName = "/cashFusionProgressView";
|
||||
|
||||
final String walletId;
|
||||
|
||||
@override
|
||||
ConsumerState<FusionProgressView> createState() => _FusionProgressViewState();
|
||||
}
|
||||
|
||||
class _FusionProgressViewState extends ConsumerState<FusionProgressView> {
|
||||
Coin? coin;
|
||||
|
||||
Future<bool> _requestAndProcessCancel() async {
|
||||
final shouldCancel = await showDialog<bool?>(
|
||||
context: context,
|
||||
|
@ -98,6 +100,12 @@ class _FusionProgressViewState extends ConsumerState<FusionProgressView> {
|
|||
.watch(fusionProgressUIStateProvider(widget.walletId))
|
||||
.fusionRoundsCompleted;
|
||||
|
||||
coin = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet
|
||||
.coin;
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return await _requestAndProcessCancel();
|
||||
|
@ -226,7 +234,9 @@ class _FusionProgressViewState extends ConsumerState<FusionProgressView> {
|
|||
final fusionWallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId) as CashFusion;
|
||||
|
||||
final fusionInfo = ref.read(prefsChangeNotifierProvider).fusionServerInfo;
|
||||
final fusionInfo = (coin == Coin.bitcoincash)
|
||||
? ref.read(prefsChangeNotifierProvider).fusionServerInfoBch
|
||||
: ref.read(prefsChangeNotifierProvider).fusionServerInfoXec;
|
||||
|
||||
try {
|
||||
fusionWallet.uiState = ref.read(
|
||||
|
|
|
@ -25,6 +25,7 @@ import 'package:stackwallet/providers/global/wallets_provider.dart';
|
|||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/wallet/mixins/cash_fusion.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -58,6 +59,7 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
|
|||
late final FocusNode portFocusNode;
|
||||
late final TextEditingController fusionRoundController;
|
||||
late final FocusNode fusionRoundFocusNode;
|
||||
late final Coin coin;
|
||||
|
||||
bool _enableStartButton = false;
|
||||
bool _enableSSLCheckbox = false;
|
||||
|
@ -91,7 +93,11 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
|
|||
);
|
||||
|
||||
// update user prefs (persistent)
|
||||
ref.read(prefsChangeNotifierProvider).fusionServerInfo = newInfo;
|
||||
if (coin == Coin.bitcoincash) {
|
||||
ref.read(prefsChangeNotifierProvider).fusionServerInfoBch = newInfo;
|
||||
} else {
|
||||
ref.read(prefsChangeNotifierProvider).fusionServerInfoXec = newInfo;
|
||||
}
|
||||
|
||||
unawaited(
|
||||
fusionWallet.fuse(
|
||||
|
@ -120,7 +126,16 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
|
|||
portFocusNode = FocusNode();
|
||||
fusionRoundFocusNode = FocusNode();
|
||||
|
||||
final info = ref.read(prefsChangeNotifierProvider).fusionServerInfo;
|
||||
coin = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet
|
||||
.coin;
|
||||
|
||||
final info = (coin == Coin.bitcoincash)
|
||||
? ref.read(prefsChangeNotifierProvider).fusionServerInfoBch
|
||||
: ref.read(prefsChangeNotifierProvider).fusionServerInfoXec;
|
||||
|
||||
serverController.text = info.host;
|
||||
portController.text = info.port.toString();
|
||||
_enableSSLCheckbox = info.ssl;
|
||||
|
@ -334,7 +349,9 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
|
|||
CustomTextButton(
|
||||
text: "Default",
|
||||
onTap: () {
|
||||
const def = FusionInfo.DEFAULTS;
|
||||
final def = (coin == Coin.bitcoincash)
|
||||
? FusionInfo.BCH_DEFAULTS
|
||||
: FusionInfo.XEC_DEFAULTS;
|
||||
serverController.text = def.host;
|
||||
portController.text = def.port.toString();
|
||||
fusionRoundController.text =
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:stackwallet/providers/cash_fusion/fusion_progress_ui_state_provi
|
|||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/show_loading.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/wallet/mixins/cash_fusion.dart';
|
||||
|
@ -39,6 +40,8 @@ class FusionDialogView extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
|
||||
Coin? coin;
|
||||
|
||||
Future<bool> _requestAndProcessCancel() async {
|
||||
if (!ref.read(fusionProgressUIStateProvider(widget.walletId)).running) {
|
||||
return true;
|
||||
|
@ -151,6 +154,12 @@ class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
|
|||
.watch(fusionProgressUIStateProvider(widget.walletId))
|
||||
.fusionRoundsCompleted;
|
||||
|
||||
coin = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet
|
||||
.coin;
|
||||
|
||||
return DesktopDialog(
|
||||
maxHeight: 600,
|
||||
child: SingleChildScrollView(
|
||||
|
@ -284,7 +293,9 @@ class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
|
|||
final fusionWallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId) as CashFusion;
|
||||
|
||||
final fusionInfo = ref.read(prefsChangeNotifierProvider).fusionServerInfo;
|
||||
final fusionInfo = (coin == Coin.bitcoincash)
|
||||
? ref.read(prefsChangeNotifierProvider).fusionServerInfoBch
|
||||
: ref.read(prefsChangeNotifierProvider).fusionServerInfoXec;
|
||||
|
||||
try {
|
||||
fusionWallet.uiState = ref.read(
|
||||
|
|
|
@ -65,7 +65,8 @@ class Prefs extends ChangeNotifier {
|
|||
await _setAmountUnits();
|
||||
await _setMaxDecimals();
|
||||
_useTor = await _getUseTor();
|
||||
_fusionServerInfo = await _getFusionServerInfo();
|
||||
_fusionServerInfoBch = await _getFusionServerInfoBch();
|
||||
_fusionServerInfoXec = await _getFusionServerInfoXec();
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
@ -936,32 +937,59 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
// fusion server info
|
||||
|
||||
FusionInfo _fusionServerInfo = FusionInfo.DEFAULTS;
|
||||
FusionInfo _fusionServerInfoBch = FusionInfo.BCH_DEFAULTS;
|
||||
FusionInfo _fusionServerInfoXec = FusionInfo.XEC_DEFAULTS;
|
||||
|
||||
FusionInfo get fusionServerInfo => _fusionServerInfo;
|
||||
FusionInfo get fusionServerInfoBch => _fusionServerInfoBch;
|
||||
FusionInfo get fusionServerInfoXec => _fusionServerInfoXec;
|
||||
|
||||
set fusionServerInfo(FusionInfo fusionServerInfo) {
|
||||
if (this.fusionServerInfo != fusionServerInfo) {
|
||||
set fusionServerInfoBch(FusionInfo fusionServerInfo) {
|
||||
if (fusionServerInfoBch != fusionServerInfo) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "fusionServerInfo",
|
||||
value: fusionServerInfo.toJsonString(),
|
||||
);
|
||||
_fusionServerInfo = fusionServerInfo;
|
||||
_fusionServerInfoBch = fusionServerInfo;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<FusionInfo> _getFusionServerInfo() async {
|
||||
set fusionServerInfoXec(FusionInfo fusionServerInfo) {
|
||||
if (fusionServerInfoXec != fusionServerInfo) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "fusionServerInfoXec",
|
||||
value: fusionServerInfo.toJsonString(),
|
||||
);
|
||||
_fusionServerInfoXec = fusionServerInfo;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<FusionInfo> _getFusionServerInfoBch() async {
|
||||
final saved = await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "fusionServerInfo",
|
||||
key: "fusionServerInfoBch",
|
||||
) as String?;
|
||||
|
||||
try {
|
||||
return FusionInfo.fromJsonString(saved!);
|
||||
} catch (_) {
|
||||
return FusionInfo.DEFAULTS;
|
||||
return FusionInfo.BCH_DEFAULTS;
|
||||
}
|
||||
}
|
||||
|
||||
Future<FusionInfo> _getFusionServerInfoXec() async {
|
||||
final saved = await DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "fusionServerInfoXec",
|
||||
) as String?;
|
||||
|
||||
try {
|
||||
return FusionInfo.fromJsonString(saved!);
|
||||
} catch (_) {
|
||||
return FusionInfo.XEC_DEFAULTS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue