Skip to content

Commit

Permalink
Rename settings__service to settings_repository
Browse files Browse the repository at this point in the history
  • Loading branch information
cygnet3 committed Oct 4, 2024
1 parent 1899561 commit 9542822
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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<void> 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<void> resetAll() async {
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/create/create_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -45,7 +45,7 @@ class CreateWalletScreenState extends State<CreateWalletScreen> {
final themeNotifier = Provider.of<ThemeNotifier>(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);
Expand Down
8 changes: 4 additions & 4 deletions lib/screens/home/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -55,7 +55,7 @@ class SettingsScreen extends StatelessWidget {
}

Future<void> _setBlindbitUrl(BuildContext context) async {
SettingsService settings = SettingsService();
SettingsRepository settings = SettingsRepository();
final controller = TextEditingController();
controller.text = await settings.getBlindbitUrl() ?? '';

Expand All @@ -69,7 +69,7 @@ class SettingsScreen extends StatelessWidget {
}

Future<void> _changeDustLimit(BuildContext context) async {
SettingsService settings = SettingsService();
SettingsRepository settings = SettingsRepository();
final controller = TextEditingController();
final dustLimit = await settings.getDustLimit();
if (dustLimit != null) {
Expand Down
6 changes: 3 additions & 3 deletions lib/states/chain_state.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -9,7 +9,7 @@ class ChainState extends ChangeNotifier {
ChainState();

Future<void> initialize() async {
final url = await SettingsService().getBlindbitUrl();
final url = await SettingsRepository().getBlindbitUrl();

if (url != null) {
try {
Expand Down Expand Up @@ -42,7 +42,7 @@ class ChainState extends ChangeNotifier {

Future<void> updateChainTip() async {
try {
final url = await SettingsService().getBlindbitUrl();
final url = await SettingsRepository().getBlindbitUrl();
_tip = await getChainHeight(blindbitUrl: url!);
Logger().i('updating tip: $_tip');

Expand Down
4 changes: 2 additions & 2 deletions lib/states/wallet_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 9542822

Please sign in to comment.