-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CW-526-Add-Trocador-providers-option-in-privacy-settings (#1177)
* Trocador settings page UI * add trocador providers states * add settings icon * minor fix * Revert "minor fix" This reverts commit e59d9df. * fixes * PR fixes * remove trocador menu icon
- Loading branch information
1 parent
bb5336f
commit 36361ef
Showing
9 changed files
with
134 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:cake_wallet/exchange/provider/trocador_exchange_provider.dart'; | ||
import 'package:cake_wallet/src/screens/base_page.dart'; | ||
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart'; | ||
import 'package:cake_wallet/view_model/settings/trocador_providers_view_model.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_mobx/flutter_mobx.dart'; | ||
|
||
class TrocadorProvidersPage extends BasePage { | ||
TrocadorProvidersPage(this.trocadorProvidersViewModel); | ||
|
||
@override | ||
String get title => 'Trocador Providers'; | ||
|
||
final TrocadorProvidersViewModel trocadorProvidersViewModel; | ||
|
||
@override | ||
Widget body(BuildContext context) { | ||
final availableProviders = TrocadorExchangeProvider.availableProviders; | ||
final providerStates = trocadorProvidersViewModel.providerStates; | ||
return Container( | ||
padding: EdgeInsets.only(top: 10), | ||
child: ListView.builder( | ||
itemCount: availableProviders.length, | ||
itemBuilder: (_, index) { | ||
String provider = availableProviders[index]; | ||
return Observer( | ||
builder: (_) => SettingsSwitcherCell( | ||
title: provider, | ||
value: providerStates[provider] ?? false, | ||
onValueChange: (BuildContext _, bool value) { | ||
trocadorProvidersViewModel.toggleProviderState(provider); | ||
})); | ||
}, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
lib/view_model/settings/trocador_providers_view_model.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:cake_wallet/store/settings_store.dart'; | ||
import 'package:mobx/mobx.dart'; | ||
|
||
part 'trocador_providers_view_model.g.dart'; | ||
|
||
class TrocadorProvidersViewModel = TrocadorProvidersViewModelBase with _$TrocadorProvidersViewModel; | ||
|
||
abstract class TrocadorProvidersViewModelBase with Store { | ||
TrocadorProvidersViewModelBase(this._settingsStore); | ||
|
||
final SettingsStore _settingsStore; | ||
|
||
@computed | ||
Map<String, bool> get providerStates => _settingsStore.trocadorProviderStates; | ||
|
||
@action | ||
void toggleProviderState(String providerName) { | ||
final currentState = providerStates[providerName] ?? false; | ||
_settingsStore.saveTrocadorProviderState(providerName, !currentState); | ||
} | ||
} |