mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-12 09:27:01 +00:00
disable exchange data loading based on enableExchange pref
and refactor showExchange->enableExchange
This commit is contained in:
parent
2b2127aeb5
commit
220cf65520
9 changed files with 18 additions and 17 deletions
|
@ -378,7 +378,8 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
|
|||
// TODO: this should probably run unawaited. Keep commented out for now as proper community nodes ui hasn't been implemented yet
|
||||
// unawaited(_nodeService.updateCommunityNodes());
|
||||
|
||||
if (AppConfig.hasFeature(AppFeature.swap)) {
|
||||
if (AppConfig.hasFeature(AppFeature.swap) &&
|
||||
ref.read(prefsChangeNotifierProvider).enableExchange) {
|
||||
await ExchangeDataLoadingService.instance.initDB();
|
||||
// run without awaiting
|
||||
if (ref.read(prefsChangeNotifierProvider).externalCalls &&
|
||||
|
|
|
@ -46,7 +46,7 @@ class _HomeViewButtonBarState extends ConsumerState<HomeViewButtonBar> {
|
|||
Widget build(BuildContext context) {
|
||||
final prefs = ref.watch(prefsChangeNotifierProvider);
|
||||
|
||||
final showExchange = prefs.showExchange;
|
||||
final showExchange = prefs.enableExchange;
|
||||
|
||||
final selectedIndex = ref.watch(homeViewPageIndexStateProvider.state).state;
|
||||
return Row(
|
||||
|
|
|
@ -204,7 +204,7 @@ class AdvancedSettingsView extends StatelessWidget {
|
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Show exchange features",
|
||||
"Enable exchange features",
|
||||
style: STextStyles.titleBold12(context),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
|
@ -214,13 +214,13 @@ class AdvancedSettingsView extends StatelessWidget {
|
|||
child: DraggableSwitchButton(
|
||||
isOn: ref.watch(
|
||||
prefsChangeNotifierProvider.select(
|
||||
(value) => value.showExchange,
|
||||
(value) => value.enableExchange,
|
||||
),
|
||||
),
|
||||
onValueChanged: (newValue) {
|
||||
ref
|
||||
.read(prefsChangeNotifierProvider)
|
||||
.showExchange = newValue;
|
||||
.enableExchange = newValue;
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
|
@ -219,7 +219,7 @@ class TokenWalletOptions extends ConsumerWidget {
|
|||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final prefs = ref.watch(prefsChangeNotifierProvider);
|
||||
final showExchange = prefs.showExchange;
|
||||
final showExchange = prefs.enableExchange;
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
|
|
@ -519,7 +519,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
|
||||
final prefs = ref.watch(prefsChangeNotifierProvider);
|
||||
final showExchange = prefs.showExchange;
|
||||
final showExchange = prefs.enableExchange;
|
||||
|
||||
return ConditionalParent(
|
||||
condition: _rescanningOnOpen,
|
||||
|
|
|
@ -117,7 +117,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
|
|||
Widget build(BuildContext context) {
|
||||
final prefs = ref.watch(prefsChangeNotifierProvider);
|
||||
|
||||
final showExchange = prefs.showExchange;
|
||||
final showExchange = prefs.enableExchange;
|
||||
|
||||
return Material(
|
||||
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||
|
|
|
@ -354,7 +354,7 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
|
|||
final coin = wallet.info.coin;
|
||||
|
||||
final prefs = ref.watch(prefsChangeNotifierProvider);
|
||||
final showExchange = prefs.showExchange;
|
||||
final showExchange = prefs.enableExchange;
|
||||
|
||||
final showMore = wallet is PaynymInterface ||
|
||||
(wallet is CoinControlInterface &&
|
||||
|
|
|
@ -174,7 +174,7 @@ class _AdvancedSettings extends ConsumerState<AdvancedSettings> {
|
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Show exchange features",
|
||||
"Enable exchange features",
|
||||
style: STextStyles.desktopTextExtraSmall(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
|
@ -189,13 +189,13 @@ class _AdvancedSettings extends ConsumerState<AdvancedSettings> {
|
|||
child: DraggableSwitchButton(
|
||||
isOn: ref.watch(
|
||||
prefsChangeNotifierProvider.select(
|
||||
(value) => value.showExchange,
|
||||
(value) => value.enableExchange,
|
||||
),
|
||||
),
|
||||
onValueChanged: (newValue) {
|
||||
ref
|
||||
.read(prefsChangeNotifierProvider)
|
||||
.showExchange = newValue;
|
||||
.enableExchange = newValue;
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1133,18 +1133,18 @@ class Prefs extends ChangeNotifier {
|
|||
|
||||
// Show or hide exchange (buy & swap) features.
|
||||
|
||||
bool _showExchange = true;
|
||||
bool _enableExchange = true;
|
||||
|
||||
bool get showExchange => _showExchange;
|
||||
bool get enableExchange => _enableExchange;
|
||||
|
||||
set showExchange(bool showExchange) {
|
||||
if (_showExchange != showExchange) {
|
||||
set enableExchange(bool showExchange) {
|
||||
if (_enableExchange != showExchange) {
|
||||
DB.instance.put<dynamic>(
|
||||
boxName: DB.boxNamePrefs,
|
||||
key: "showExchange",
|
||||
value: showExchange,
|
||||
);
|
||||
_showExchange = showExchange;
|
||||
_enableExchange = showExchange;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue