Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/bloc/settings/settings_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
on<MarketMakerBotSettingsChanged>(_onMarketMakerBotSettingsChanged);
on<TestCoinsEnabledChanged>(_onTestCoinsEnabledChanged);
on<WeakPasswordsAllowedChanged>(_onWeakPasswordsAllowedChanged);
on<HideZeroBalanceAssetsChanged>(_onHideZeroBalanceAssetsChanged);
}

late StoredSettings _storedSettings;
Expand Down Expand Up @@ -68,4 +69,16 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
);
emitter(state.copyWith(weakPasswordsAllowed: event.weakPasswordsAllowed));
}

Future<void> _onHideZeroBalanceAssetsChanged(
HideZeroBalanceAssetsChanged event,
Emitter<SettingsState> emitter,
) async {
await _settingsRepo.updateSettings(
_storedSettings.copyWith(
hideZeroBalanceAssets: event.hideZeroBalanceAssets,
),
);
emitter(state.copyWith(hideZeroBalanceAssets: event.hideZeroBalanceAssets));
}
}
5 changes: 5 additions & 0 deletions lib/bloc/settings/settings_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ class WeakPasswordsAllowedChanged extends SettingsEvent {
@override
List<Object> get props => [weakPasswordsAllowed];
}

class HideZeroBalanceAssetsChanged extends SettingsEvent {
const HideZeroBalanceAssetsChanged({required this.hideZeroBalanceAssets});
final bool hideZeroBalanceAssets;
}
7 changes: 7 additions & 0 deletions lib/bloc/settings/settings_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class SettingsState extends Equatable {
required this.mmBotSettings,
required this.testCoinsEnabled,
required this.weakPasswordsAllowed,
required this.hideZeroBalanceAssets,
});

factory SettingsState.fromStored(StoredSettings stored) {
Expand All @@ -17,33 +18,39 @@ class SettingsState extends Equatable {
mmBotSettings: stored.marketMakerBotSettings,
testCoinsEnabled: stored.testCoinsEnabled,
weakPasswordsAllowed: stored.weakPasswordsAllowed,
hideZeroBalanceAssets: stored.hideZeroBalanceAssets,
);
}

final ThemeMode themeMode;
final MarketMakerBotSettings mmBotSettings;
final bool testCoinsEnabled;
final bool weakPasswordsAllowed;
final bool hideZeroBalanceAssets;

@override
List<Object?> get props => [
themeMode,
mmBotSettings,
testCoinsEnabled,
weakPasswordsAllowed,
hideZeroBalanceAssets,
];

SettingsState copyWith({
ThemeMode? mode,
MarketMakerBotSettings? marketMakerBotSettings,
bool? testCoinsEnabled,
bool? weakPasswordsAllowed,
bool? hideZeroBalanceAssets,
}) {
return SettingsState(
themeMode: mode ?? themeMode,
mmBotSettings: marketMakerBotSettings ?? mmBotSettings,
testCoinsEnabled: testCoinsEnabled ?? this.testCoinsEnabled,
weakPasswordsAllowed: weakPasswordsAllowed ?? this.weakPasswordsAllowed,
hideZeroBalanceAssets:
hideZeroBalanceAssets ?? this.hideZeroBalanceAssets,
);
}
}
8 changes: 8 additions & 0 deletions lib/model/stored_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ class StoredSettings {
required this.marketMakerBotSettings,
required this.testCoinsEnabled,
required this.weakPasswordsAllowed,
required this.hideZeroBalanceAssets,
});

final ThemeMode mode;
final AnalyticsSettings analytics;
final MarketMakerBotSettings marketMakerBotSettings;
final bool testCoinsEnabled;
final bool weakPasswordsAllowed;
final bool hideZeroBalanceAssets;

static StoredSettings initial() {
return StoredSettings(
Expand All @@ -25,6 +27,7 @@ class StoredSettings {
marketMakerBotSettings: MarketMakerBotSettings.initial(),
testCoinsEnabled: true,
weakPasswordsAllowed: false,
hideZeroBalanceAssets: false,
);
}

Expand All @@ -39,6 +42,7 @@ class StoredSettings {
),
testCoinsEnabled: json['testCoinsEnabled'] ?? true,
weakPasswordsAllowed: json['weakPasswordsAllowed'] ?? false,
hideZeroBalanceAssets: json['hideZeroBalanceAssets'] ?? false,
);
}

Expand All @@ -49,6 +53,7 @@ class StoredSettings {
storedMarketMakerSettingsKey: marketMakerBotSettings.toJson(),
'testCoinsEnabled': testCoinsEnabled,
'weakPasswordsAllowed': weakPasswordsAllowed,
'hideZeroBalanceAssets': hideZeroBalanceAssets,
};
}

Expand All @@ -58,6 +63,7 @@ class StoredSettings {
MarketMakerBotSettings? marketMakerBotSettings,
bool? testCoinsEnabled,
bool? weakPasswordsAllowed,
bool? hideZeroBalanceAssets,
}) {
return StoredSettings(
mode: mode ?? this.mode,
Expand All @@ -66,6 +72,8 @@ class StoredSettings {
marketMakerBotSettings ?? this.marketMakerBotSettings,
testCoinsEnabled: testCoinsEnabled ?? this.testCoinsEnabled,
weakPasswordsAllowed: weakPasswordsAllowed ?? this.weakPasswordsAllowed,
hideZeroBalanceAssets:
hideZeroBalanceAssets ?? this.hideZeroBalanceAssets,
);
}
}
17 changes: 10 additions & 7 deletions lib/views/wallet/wallet_page/wallet_main/wallet_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import 'package:web_dex/bloc/cex_market_data/price_chart/price_chart_bloc.dart';
import 'package:web_dex/bloc/cex_market_data/price_chart/price_chart_event.dart';
import 'package:web_dex/bloc/cex_market_data/profit_loss/profit_loss_bloc.dart';
import 'package:web_dex/bloc/coins_bloc/coins_bloc.dart';
import 'package:web_dex/bloc/settings/settings_bloc.dart';
import 'package:web_dex/bloc/settings/settings_event.dart';
import 'package:web_dex/bloc/taker_form/taker_bloc.dart';
import 'package:web_dex/bloc/taker_form/taker_event.dart';
import 'package:web_dex/common/screen.dart';
Expand Down Expand Up @@ -53,7 +55,6 @@ class WalletMain extends StatefulWidget {
}

class _WalletMainState extends State<WalletMain> with TickerProviderStateMixin {
bool _showCoinWithBalance = false;
String _searchKey = '';
PopupDispatcher? _popupDispatcher;
StreamSubscription<Wallet?>? _walletSubscription;
Expand Down Expand Up @@ -251,10 +252,10 @@ class _WalletMainState extends State<WalletMain> with TickerProviderStateMixin {
assetOverviewBloc.add(const AssetOverviewClearRequested());
}

void _onShowCoinsWithBalanceClick(bool? value) {
setState(() {
_showCoinWithBalance = value ?? false;
});
void _onShowCoinsWithBalanceClick(bool value) {
context
.read<SettingsBloc>()
.add(HideZeroBalanceAssetsChanged(hideZeroBalanceAssets: value));
}

void _onSearchChange(String searchKey) {
Expand Down Expand Up @@ -290,7 +291,8 @@ class _WalletMainState extends State<WalletMain> with TickerProviderStateMixin {
SliverPersistentHeader(
pinned: true,
delegate: _SliverSearchBarDelegate(
withBalance: _showCoinWithBalance,
withBalance:
context.watch<SettingsBloc>().state.hideZeroBalanceAssets,
onSearchChange: _onSearchChange,
onWithBalanceChange: _onShowCoinsWithBalanceClick,
mode: mode,
Expand All @@ -300,7 +302,8 @@ class _WalletMainState extends State<WalletMain> with TickerProviderStateMixin {
CoinListView(
mode: mode,
searchPhrase: _searchKey,
withBalance: _showCoinWithBalance,
withBalance:
context.watch<SettingsBloc>().state.hideZeroBalanceAssets,
onActiveCoinItemTap: _onActiveCoinItemTap,
onAssetItemTap: _onAssetItemTap,
onAssetStatisticsTap: _onAssetStatisticsTap,
Expand Down
6 changes: 3 additions & 3 deletions packages/komodo_ui_kit/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ packages:
description:
path: "packages/komodo_defi_rpc_methods"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -104,7 +104,7 @@ packages:
description:
path: "packages/komodo_defi_types"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -113,7 +113,7 @@ packages:
description:
path: "packages/komodo_ui"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand Down
20 changes: 10 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ packages:
description:
path: "packages/komodo_cex_market_data"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.0.1"
Expand All @@ -665,7 +665,7 @@ packages:
description:
path: "packages/komodo_coin_updates"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "1.0.0"
Expand All @@ -674,7 +674,7 @@ packages:
description:
path: "packages/komodo_coins"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -683,7 +683,7 @@ packages:
description:
path: "packages/komodo_defi_framework"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0"
Expand All @@ -692,7 +692,7 @@ packages:
description:
path: "packages/komodo_defi_local_auth"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -701,7 +701,7 @@ packages:
description:
path: "packages/komodo_defi_rpc_methods"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -710,7 +710,7 @@ packages:
description:
path: "packages/komodo_defi_sdk"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -719,7 +719,7 @@ packages:
description:
path: "packages/komodo_defi_types"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -735,7 +735,7 @@ packages:
description:
path: "packages/komodo_ui"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand All @@ -751,7 +751,7 @@ packages:
description:
path: "packages/komodo_wallet_build_transformer"
ref: dev
resolved-ref: a521a80f6f77e888512d13aa961511d6f83e2c14
resolved-ref: abd3de0995652a34e721dcb47283f5d670b239e8
url: "https://github.com/KomodoPlatform/komodo-defi-sdk-flutter.git"
source: git
version: "0.2.0+0"
Expand Down
Loading