diff --git a/lib/hive/db.dart b/lib/hive/db.dart index 48e6ba154..1a52d64df 100644 --- a/lib/hive/db.dart +++ b/lib/hive/db.dart @@ -9,7 +9,6 @@ import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/models/notification_model.dart'; import 'package:stackwallet/models/trade_wallet_lookup.dart'; import 'package:stackwallet/services/wallets_service.dart'; -import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; @@ -151,17 +150,6 @@ class DB { _loadSharedCoinCacheBoxes(), ]); _initialized = true; - - try { - if (_boxPrefs!.get("familiarity") == null) { - await _boxPrefs!.put("familiarity", 0); - } - int count = _boxPrefs!.get("familiarity") as int; - await _boxPrefs!.put("familiarity", count + 1); - Constants.exchangeForExperiencedUsers(count + 1); - } catch (e, s) { - print("$e $s"); - } } } diff --git a/lib/main.dart b/lib/main.dart index d5980409f..2086d351e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -235,6 +235,11 @@ class _MaterialAppWithThemeState extends ConsumerState await DB.instance.init(); await ref.read(prefsChangeNotifierProvider).init(); + final familiarity = ref.read(prefsChangeNotifierProvider).familiarity + 1; + ref.read(prefsChangeNotifierProvider).familiarity = familiarity; + + Constants.exchangeForExperiencedUsers(familiarity); + if (Util.isDesktop) { _desktopHasPassword = await ref.read(storageCryptoHandlerProvider).hasPassword(); diff --git a/lib/pages/settings_views/global_settings_view/hidden_settings.dart b/lib/pages/settings_views/global_settings_view/hidden_settings.dart index 7f35fcc86..d92b166d7 100644 --- a/lib/pages/settings_views/global_settings_view/hidden_settings.dart +++ b/lib/pages/settings_views/global_settings_view/hidden_settings.dart @@ -5,6 +5,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/providers/global/debug_service_provider.dart'; import 'package:stackwallet/providers/providers.dart'; +import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/background.dart'; @@ -127,6 +128,42 @@ class HiddenSettings extends StatelessWidget { ), ); }), + const SizedBox( + height: 12, + ), + Consumer( + builder: (_, ref, __) { + if (ref.watch(prefsChangeNotifierProvider + .select((value) => value.familiarity)) < + 6) { + return GestureDetector( + onTap: () async { + final familiarity = ref + .read(prefsChangeNotifierProvider) + .familiarity; + if (familiarity < 6) { + ref + .read(prefsChangeNotifierProvider) + .familiarity = 6; + + Constants.exchangeForExperiencedUsers(6); + } + }, + child: RoundedWhiteContainer( + child: Text( + "Enable exchange", + style: STextStyles.button(context).copyWith( + color: Theme.of(context) + .extension()! + .accentColorDark), + ), + ), + ); + } else { + return Container(); + } + }, + ), // const SizedBox( // height: 12, // ), diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 246291053..6b4b9821a 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -37,6 +37,7 @@ class Prefs extends ChangeNotifier { _gotoWalletOnStartup = await _getGotoWalletOnStartup(); _startupWalletId = await _getStartupWalletId(); _externalCalls = await _getHasExternalCalls(); + _familiarity = await _getHasFamiliarity(); _initialized = true; } @@ -328,6 +329,27 @@ class Prefs extends ChangeNotifier { false; } + // familiarity + + int _familiarity = 0; + + int get familiarity => _familiarity; + + set familiarity(int familiarity) { + if (_familiarity != familiarity) { + DB.instance.put( + boxName: DB.boxNamePrefs, key: "familiarity", value: familiarity); + _familiarity = familiarity; + notifyListeners(); + } + } + + Future _getHasFamiliarity() async { + return await DB.instance.get( + boxName: DB.boxNamePrefs, key: "familiarity") as int? ?? + 0; + } + // show testnet coins bool _showTestNetCoins = false;