From 9542822381471c346deeabf8111bea5d214ea276 Mon Sep 17 00:00:00 2001 From: cygnet Date: Fri, 4 Oct 2024 21:31:46 +0200 Subject: [PATCH] Rename settings__service to settings_repository --- .../settings_repository.dart} | 6 +++--- lib/screens/create/create_wallet.dart | 4 ++-- lib/screens/home/settings/settings.dart | 8 ++++---- lib/states/chain_state.dart | 6 +++--- lib/states/wallet_state.dart | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) rename lib/{services/settings_service.dart => repositories/settings_repository.dart} (84%) diff --git a/lib/services/settings_service.dart b/lib/repositories/settings_repository.dart similarity index 84% rename from lib/services/settings_service.dart rename to lib/repositories/settings_repository.dart index 84653db..71238d1 100644 --- a/lib/services/settings_service.dart +++ b/lib/repositories/settings_repository.dart @@ -1,13 +1,13 @@ import 'package:danawallet/constants.dart'; import 'package:shared_preferences/shared_preferences.dart'; -class SettingsService { +class SettingsRepository { final SharedPreferencesAsync prefs = SharedPreferencesAsync(); Future defaultSettings(Network network) async { final String blindbitUrl = network.getDefaultBlindbitUrl(); - await SettingsService().setBlindbitUrl(blindbitUrl); - await SettingsService().setDustLimit(defaultDustLimit); + await SettingsRepository().setBlindbitUrl(blindbitUrl); + await SettingsRepository().setDustLimit(defaultDustLimit); } Future resetAll() async { diff --git a/lib/screens/create/create_wallet.dart b/lib/screens/create/create_wallet.dart index 57201a2..0d43c97 100644 --- a/lib/screens/create/create_wallet.dart +++ b/lib/screens/create/create_wallet.dart @@ -4,7 +4,7 @@ import 'package:danawallet/constants.dart'; import 'package:danawallet/generated/rust/api/structs.dart'; import 'package:danawallet/generated/rust/api/wallet.dart'; import 'package:danawallet/screens/home/home.dart'; -import 'package:danawallet/services/settings_service.dart'; +import 'package:danawallet/repositories/settings_repository.dart'; import 'package:danawallet/states/chain_state.dart'; import 'package:danawallet/states/theme_notifier.dart'; import 'package:danawallet/states/wallet_state.dart'; @@ -45,7 +45,7 @@ class CreateWalletScreenState extends State { final themeNotifier = Provider.of(context, listen: false); // todo settings has to be initialized before chainstate, make this independent - await SettingsService().defaultSettings(_selectedNetwork); + await SettingsRepository().defaultSettings(_selectedNetwork); await chainState.initialize(); themeNotifier.setTheme(_selectedNetwork); diff --git a/lib/screens/home/settings/settings.dart b/lib/screens/home/settings/settings.dart index 8bd4a3d..b01c049 100644 --- a/lib/screens/home/settings/settings.dart +++ b/lib/screens/home/settings/settings.dart @@ -2,7 +2,7 @@ import 'package:bitcoin_ui/bitcoin_ui.dart'; import 'package:danawallet/global_functions.dart'; import 'package:danawallet/generated/rust/api/wallet.dart'; import 'package:danawallet/screens/create/create_wallet.dart'; -import 'package:danawallet/services/settings_service.dart'; +import 'package:danawallet/repositories/settings_repository.dart'; import 'package:danawallet/states/chain_state.dart'; import 'package:danawallet/states/home_state.dart'; import 'package:danawallet/states/spend_state.dart'; @@ -23,7 +23,7 @@ class SettingsScreen extends StatelessWidget { try { await walletState.reset(); - await SettingsService().resetAll(); + await SettingsRepository().resetAll(); spendSelectionState.reset(); chainState.reset(); themeNotifier.setTheme(null); @@ -55,7 +55,7 @@ class SettingsScreen extends StatelessWidget { } Future _setBlindbitUrl(BuildContext context) async { - SettingsService settings = SettingsService(); + SettingsRepository settings = SettingsRepository(); final controller = TextEditingController(); controller.text = await settings.getBlindbitUrl() ?? ''; @@ -69,7 +69,7 @@ class SettingsScreen extends StatelessWidget { } Future _changeDustLimit(BuildContext context) async { - SettingsService settings = SettingsService(); + SettingsRepository settings = SettingsRepository(); final controller = TextEditingController(); final dustLimit = await settings.getDustLimit(); if (dustLimit != null) { diff --git a/lib/states/chain_state.dart b/lib/states/chain_state.dart index 056a57d..65763b5 100644 --- a/lib/states/chain_state.dart +++ b/lib/states/chain_state.dart @@ -1,5 +1,5 @@ import 'package:danawallet/generated/rust/api/chain.dart'; -import 'package:danawallet/services/settings_service.dart'; +import 'package:danawallet/repositories/settings_repository.dart'; import 'package:flutter/material.dart'; import 'package:logger/logger.dart'; @@ -9,7 +9,7 @@ class ChainState extends ChangeNotifier { ChainState(); Future initialize() async { - final url = await SettingsService().getBlindbitUrl(); + final url = await SettingsRepository().getBlindbitUrl(); if (url != null) { try { @@ -42,7 +42,7 @@ class ChainState extends ChangeNotifier { Future updateChainTip() async { try { - final url = await SettingsService().getBlindbitUrl(); + final url = await SettingsRepository().getBlindbitUrl(); _tip = await getChainHeight(blindbitUrl: url!); Logger().i('updating tip: $_tip'); diff --git a/lib/states/wallet_state.dart b/lib/states/wallet_state.dart index c7760c8..3c555b1 100644 --- a/lib/states/wallet_state.dart +++ b/lib/states/wallet_state.dart @@ -5,7 +5,7 @@ import 'package:danawallet/generated/rust/api/structs.dart'; import 'package:danawallet/generated/rust/api/wallet.dart'; import 'package:danawallet/generated/rust/logger.dart'; import 'package:danawallet/repositories/wallet_repository.dart'; -import 'package:danawallet/services/settings_service.dart'; +import 'package:danawallet/repositories/settings_repository.dart'; import 'package:flutter/material.dart'; class WalletState extends ChangeNotifier { @@ -185,7 +185,7 @@ class WalletState extends ChangeNotifier { scanning = true; final wallet = await getWalletFromSecureStorage(); - final settings = SettingsService(); + final settings = SettingsRepository(); final blindbitUrl = await settings.getBlindbitUrl(); final dustLimit = await settings.getDustLimit();