This commit is contained in:
M 2020-09-28 18:47:43 +03:00
parent 51cf11127c
commit e3678d2cf9
32 changed files with 482 additions and 904 deletions

View file

@ -1,38 +0,0 @@
import 'package:hive/hive.dart';
import 'package:cake_wallet/store/contact_list_store.dart';
import 'package:cake_wallet/entities/contact.dart';
class ContactService {
ContactService(this.contactSource, this.contactListStore) {
_forceUpdateContactListStore();
}
final Box<Contact> contactSource;
final ContactListStore contactListStore;
Future add(Contact contact) async {
await contactSource.add(contact);
// contactListStore.contacts.add(contact);
}
Future update(Contact contact) async {
await contact.save();
final index = contactListStore.contacts.indexOf(contact) ?? -1;
if (index >= 0) {
_forceUpdateContactListStore();
} else {
// contactListStore.contacts.add(contact);
}
}
Future delete(Contact contact) async {
await contact.delete();
contactListStore.contacts.remove(contact);
}
void _forceUpdateContactListStore() {
contactListStore.contacts.clear();
// contactListStore.contacts.addAll(contactSource.values);
}
}

View file

@ -1,5 +1,4 @@
import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart'; import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart';
import 'package:cake_wallet/core/contact_service.dart';
import 'package:cake_wallet/core/wallet_service.dart'; import 'package:cake_wallet/core/wallet_service.dart';
import 'package:cake_wallet/entities/biometric_auth.dart'; import 'package:cake_wallet/entities/biometric_auth.dart';
import 'package:cake_wallet/entities/contact_record.dart'; import 'package:cake_wallet/entities/contact_record.dart';
@ -8,22 +7,22 @@ import 'package:cake_wallet/entities/contact.dart';
import 'package:cake_wallet/entities/node.dart'; import 'package:cake_wallet/entities/node.dart';
import 'package:cake_wallet/exchange/trade.dart'; import 'package:cake_wallet/exchange/trade.dart';
// import 'package:cake_wallet/src/domain/services/wallet_service.dart';
import 'package:cake_wallet/src/screens/contact/contact_list_page.dart'; import 'package:cake_wallet/src/screens/contact/contact_list_page.dart';
import 'package:cake_wallet/src/screens/contact/contact_page.dart'; import 'package:cake_wallet/src/screens/contact/contact_page.dart';
import 'package:cake_wallet/src/screens/exchange_trade/exchange_confirm_page.dart'; import 'package:cake_wallet/src/screens/exchange_trade/exchange_confirm_page.dart';
import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_page.dart'; import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_page.dart';
import 'package:cake_wallet/src/screens/faq/faq_page.dart';
import 'package:cake_wallet/src/screens/nodes/node_create_or_edit_page.dart'; import 'package:cake_wallet/src/screens/nodes/node_create_or_edit_page.dart';
import 'package:cake_wallet/src/screens/nodes/nodes_list_page.dart'; import 'package:cake_wallet/src/screens/nodes/nodes_list_page.dart';
import 'package:cake_wallet/src/screens/rescan/rescan_page.dart'; import 'package:cake_wallet/src/screens/rescan/rescan_page.dart';
import 'package:cake_wallet/src/screens/seed/wallet_seed_page.dart'; import 'package:cake_wallet/src/screens/seed/wallet_seed_page.dart';
import 'package:cake_wallet/src/screens/send/send_template_page.dart'; import 'package:cake_wallet/src/screens/send/send_template_page.dart';
import 'package:cake_wallet/src/screens/settings/change_language.dart';
import 'package:cake_wallet/src/screens/settings/settings.dart'; import 'package:cake_wallet/src/screens/settings/settings.dart';
import 'package:cake_wallet/src/screens/setup_pin_code/setup_pin_code.dart'; import 'package:cake_wallet/src/screens/setup_pin_code/setup_pin_code.dart';
import 'package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart'; import 'package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart';
import 'package:cake_wallet/src/screens/exchange/exchange_page.dart'; import 'package:cake_wallet/src/screens/exchange/exchange_page.dart';
import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart'; import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart';
import 'package:cake_wallet/store/contact_list_store.dart';
import 'package:cake_wallet/store/node_list_store.dart'; import 'package:cake_wallet/store/node_list_store.dart';
import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/core/auth_service.dart'; import 'package:cake_wallet/core/auth_service.dart';
@ -38,10 +37,7 @@ import 'package:cake_wallet/src/screens/receive/receive_page.dart';
import 'package:cake_wallet/src/screens/send/send_page.dart'; import 'package:cake_wallet/src/screens/send/send_page.dart';
import 'package:cake_wallet/src/screens/subaddress/address_edit_or_create_page.dart'; import 'package:cake_wallet/src/screens/subaddress/address_edit_or_create_page.dart';
import 'package:cake_wallet/src/screens/wallet_list/wallet_list_page.dart'; import 'package:cake_wallet/src/screens/wallet_list/wallet_list_page.dart';
import 'package:cake_wallet/store/theme_changer_store.dart';
import 'package:cake_wallet/store/wallet_list_store.dart'; import 'package:cake_wallet/store/wallet_list_store.dart';
import 'package:cake_wallet/utils/mobx.dart';
import 'package:cake_wallet/theme_changer.dart';
import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart'; import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart';
import 'package:cake_wallet/view_model/contact_list/contact_view_model.dart'; import 'package:cake_wallet/view_model/contact_list/contact_view_model.dart';
import 'package:cake_wallet/view_model/exchange/exchange_trade_view_model.dart'; import 'package:cake_wallet/view_model/exchange/exchange_trade_view_model.dart';
@ -62,11 +58,9 @@ import 'package:cake_wallet/view_model/wallet_keys_view_model.dart';
import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart'; import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
import 'package:cake_wallet/view_model/wallet_seed_view_model.dart'; import 'package:cake_wallet/view_model/wallet_seed_view_model.dart';
import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart'; import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:get_it/get_it.dart'; import 'package:get_it/get_it.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart'; import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
@ -104,17 +98,13 @@ Future setup(
getIt.registerSingleton<FlutterSecureStorage>(FlutterSecureStorage()); getIt.registerSingleton<FlutterSecureStorage>(FlutterSecureStorage());
getIt.registerSingleton(AuthenticationStore()); getIt.registerSingleton(AuthenticationStore());
getIt.registerSingleton<WalletListStore>(WalletListStore()); getIt.registerSingleton<WalletListStore>(WalletListStore());
getIt.registerSingleton(ContactListStore());
getIt.registerSingleton(NodeListStoreBase.instance); getIt.registerSingleton(NodeListStoreBase.instance);
getIt.registerSingleton<SettingsStore>(settingsStore); getIt.registerSingleton<SettingsStore>(settingsStore);
getIt.registerSingleton<AppStore>(AppStore( getIt.registerSingleton<AppStore>(AppStore(
authenticationStore: getIt.get<AuthenticationStore>(), authenticationStore: getIt.get<AuthenticationStore>(),
walletList: getIt.get<WalletListStore>(), walletList: getIt.get<WalletListStore>(),
settingsStore: getIt.get<SettingsStore>(), settingsStore: getIt.get<SettingsStore>(),
contactListStore: getIt.get<ContactListStore>(),
nodeListStore: getIt.get<NodeListStore>())); nodeListStore: getIt.get<NodeListStore>()));
getIt.registerSingleton<ContactService>(
ContactService(contactSource, getIt.get<AppStore>().contactListStore));
getIt.registerSingleton<TradesStore>(TradesStore( getIt.registerSingleton<TradesStore>(TradesStore(
tradesSource: tradesSource, settingsStore: getIt.get<SettingsStore>())); tradesSource: tradesSource, settingsStore: getIt.get<SettingsStore>()));
getIt.registerSingleton<TradeFilterStore>(TradeFilterStore()); getIt.registerSingleton<TradeFilterStore>(TradeFilterStore());
@ -285,14 +275,10 @@ Future setup(
getIt.registerFactory(() => WalletKeysPage(getIt.get<WalletKeysViewModel>())); getIt.registerFactory(() => WalletKeysPage(getIt.get<WalletKeysViewModel>()));
getIt.registerFactoryParam<ContactViewModel, ContactRecord, void>( getIt.registerFactoryParam<ContactViewModel, ContactRecord, void>(
(ContactRecord contact, _) => ContactViewModel( (ContactRecord contact, _) =>
contactSource, getIt.get<AppStore>().wallet, ContactViewModel(contactSource, contact: contact));
contact: contact));
getIt.registerFactory(() => ContactListViewModel( getIt.registerFactory(() => ContactListViewModel(contactSource));
getIt.get<AppStore>().contactListStore,
getIt.get<ContactService>(),
contactSource));
getIt.registerFactoryParam<ContactListPage, bool, void>( getIt.registerFactoryParam<ContactListPage, bool, void>(
(bool isEditable, _) => ContactListPage(getIt.get<ContactListViewModel>(), (bool isEditable, _) => ContactListPage(getIt.get<ContactListViewModel>(),
@ -366,9 +352,8 @@ Future setup(
getIt.registerFactory(() => RescanViewModel(getIt.get<AppStore>().wallet)); getIt.registerFactory(() => RescanViewModel(getIt.get<AppStore>().wallet));
getIt.registerFactory(() => RescanPage(getIt.get<RescanViewModel>())); getIt.registerFactory(() => RescanPage(getIt.get<RescanViewModel>()));
}
void setupThemeChangerStore(ThemeChanger themeChanger) { getIt.registerFactory(() => FaqPage(getIt.get<SettingsStore>()));
getIt.registerSingleton<ThemeChangerStore>(
ThemeChangerStore(themeChanger: themeChanger)); getIt.registerFactory(() => LanguageListPage(getIt.get<SettingsStore>()));
} }

View file

@ -1,38 +0,0 @@
import 'package:flutter/material.dart';
import 'package:devicelocale/devicelocale.dart';
import 'package:intl/intl.dart';
const Map<String, String> languages = {
'en': 'English',
'de': 'Deutsch (German)',
'es': 'Español (Spanish)',
'hi': 'हिंदी (Hindi)',
'ja': '日本 (Japanese)',
'ko': '한국어 (Korean)',
'nl': 'Nederlands (Dutch)',
'pl': 'Polski (Polish)',
'pt': 'Português (Portuguese)',
'ru': 'Русский (Russian)',
'uk': 'Українська (Ukrainian)',
'zh': '中文 (Chinese)'
};
class Language with ChangeNotifier {
Language(this._currentLanguage);
String _currentLanguage;
String getCurrentLanguage() => _currentLanguage;
void setCurrentLanguage(String language) {
_currentLanguage = language;
notifyListeners();
}
static Future<String> localeDetection() async {
var locale = await Devicelocale.currentLocale;
locale = Intl.shortLocale(locale);
return languages.keys.contains(locale) ? locale : 'en';
}
}

View file

@ -0,0 +1,26 @@
import 'package:devicelocale/devicelocale.dart';
import 'package:intl/intl.dart';
class LanguageService {
static const Map<String, String> list = {
'en': 'English',
'de': 'Deutsch (German)',
'es': 'Español (Spanish)',
'hi': 'हिंदी (Hindi)',
'ja': '日本 (Japanese)',
'ko': '한국어 (Korean)',
'nl': 'Nederlands (Dutch)',
'pl': 'Polski (Polish)',
'pt': 'Português (Portuguese)',
'ru': 'Русский (Russian)',
'uk': 'Українська (Ukrainian)',
'zh': '中文 (Chinese)'
};
static Future<String> localeDetection() async {
var locale = await Devicelocale.currentLocale;
locale = Intl.shortLocale(locale);
return list.keys.contains(locale) ? locale : 'en';
}
}

View file

@ -61,6 +61,7 @@ class Node extends HiveObject with Keyable {
} }
Future<bool> requestMoneroNode() async { Future<bool> requestMoneroNode() async {
try {
Map<String, dynamic> resBody; Map<String, dynamic> resBody;
if (login != null && password != null) { if (login != null && password != null) {
@ -79,6 +80,9 @@ class Node extends HiveObject with Keyable {
} }
return !(resBody['result']['offline'] as bool); return !(resBody['result']['offline'] as bool);
} catch (_) {
return false;
}
} }
Future<bool> requestBitcoinElectrumServer() async { Future<bool> requestBitcoinElectrumServer() async {

View file

@ -5,6 +5,7 @@ import 'package:hive/hive.dart';
abstract class Record<T extends HiveObject> with Keyable { abstract class Record<T extends HiveObject> with Keyable {
Record(this._source, this.original) { Record(this._source, this.original) {
key = original.key;
_listener?.cancel(); _listener?.cancel();
_listener = _source.watch(key: original.key).listen((event) { _listener = _source.watch(key: original.key).listen((event) {
if (!event.deleted) { if (!event.deleted) {
@ -16,7 +17,7 @@ abstract class Record<T extends HiveObject> with Keyable {
toBind(original); toBind(original);
} }
dynamic get key => original.key; dynamic key;
@override @override
dynamic get keyIndex => key; dynamic get keyIndex => key;

View file

@ -1,66 +1,30 @@
import 'package:cake_wallet/entities/fs_migration.dart';
import 'package:cake_wallet/entities/transaction_description.dart';
import 'package:cake_wallet/entities/transaction_description.dart';
import 'package:cake_wallet/reactions/bootstrap.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:cake_wallet/store/authentication_store.dart';
import 'package:cake_wallet/core/auth_service.dart';
import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart';
import 'package:cake_wallet/monero/monero_wallet_service.dart';
import 'package:cake_wallet/core/wallet_creation_service.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/view_model/wallet_new_vm.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get_it/get_it.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:provider/provider.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:cake_wallet/di.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:cw_monero/wallet.dart' as monero_wallet; import 'package:cw_monero/wallet.dart' as monero_wallet;
import 'package:cake_wallet/router.dart'; import 'package:cake_wallet/router.dart';
import 'theme_changer.dart'; import 'package:cake_wallet/routes.dart';
import 'themes.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/reactions/bootstrap.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:cake_wallet/store/authentication_store.dart';
import 'package:cake_wallet/entities/transaction_description.dart';
import 'package:cake_wallet/entities/get_encryption_key.dart'; import 'package:cake_wallet/entities/get_encryption_key.dart';
import 'package:cake_wallet/entities/contact.dart'; import 'package:cake_wallet/entities/contact.dart';
import 'package:cake_wallet/entities/node.dart'; import 'package:cake_wallet/entities/node.dart';
import 'package:cake_wallet/entities/wallet_info.dart'; import 'package:cake_wallet/entities/wallet_info.dart';
import 'package:cake_wallet/exchange/trade.dart';
// import 'package:cake_wallet/monero/transaction_description.dart';
import 'package:cake_wallet/src/reactions/set_reactions.dart';
// import 'package:cake_wallet/src/stores/login/login_store.dart';
// import 'package:cake_wallet/src/stores/balance/balance_store.dart';
// import 'package:cake_wallet/src/stores/sync/sync_store.dart';
// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
// import 'package:cake_wallet/src/stores/send_template/send_template_store.dart';
// import 'package:cake_wallet/src/stores/exchange_template/exchange_template_store.dart';
import 'package:cake_wallet/src/screens/root/root.dart';
//import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
// import 'package:cake_wallet/src/stores/settings/settings_store.dart';
// import 'package:cake_wallet/src/stores/price/price_store.dart';
// import 'package:cake_wallet/src/domain/services/user_service.dart';
// import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
import 'package:cake_wallet/entities/balance_display_mode.dart';
import 'package:cake_wallet/entities/default_settings_migration.dart'; import 'package:cake_wallet/entities/default_settings_migration.dart';
import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/entities/transaction_priority.dart';
import 'package:cake_wallet/entities/wallet_type.dart'; import 'package:cake_wallet/entities/wallet_type.dart';
import 'package:cake_wallet/entities/template.dart'; import 'package:cake_wallet/entities/template.dart';
import 'package:cake_wallet/exchange/trade.dart';
import 'package:cake_wallet/exchange/exchange_template.dart'; import 'package:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/src/screens/root/root.dart';
// import 'package:cake_wallet/src/domain/services/wallet_service.dart';
// import 'package:cake_wallet/src/domain/services/fiat_convertation_service.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/entities/language.dart';
// import 'package:cake_wallet/src/stores/seed_language/seed_language_store.dart';
bool isThemeChangerRegistered = false;
final navigatorKey = GlobalKey<NavigatorState>(); final navigatorKey = GlobalKey<NavigatorState>();
@ -94,41 +58,6 @@ void main() async {
final templates = await Hive.openBox<Template>(Template.boxName); final templates = await Hive.openBox<Template>(Template.boxName);
final exchangeTemplates = final exchangeTemplates =
await Hive.openBox<ExchangeTemplate>(ExchangeTemplate.boxName); await Hive.openBox<ExchangeTemplate>(ExchangeTemplate.boxName);
// final sharedPreferences = await SharedPreferences.getInstance();
// final walletService = WalletService();
// final fiatConvertationService = FiatConvertationService();
// final walletListService = WalletListService(
// secureStorage: secureStorage,
// walletInfoSource: walletInfoSource,
// walletService: walletService,
// sharedPreferences: sharedPreferences);
// final userService = UserService(
// sharedPreferences: sharedPreferences, secureStorage: secureStorage);
// final settingsStore = await SettingsStoreBase.load(
// nodes: nodes,
// sharedPreferences: sharedPreferences,
// initialFiatCurrency: FiatCurrency.usd,
// initialTransactionPriority: TransactionPriority.slow,
// initialBalanceDisplayMode: BalanceDisplayMode.availableBalance);
// final priceStore = PriceStore();
// final walletStore =
// WalletStore(walletService: walletService, settingsStore: settingsStore);
// final syncStore = SyncStore(walletService: walletService);
// final balanceStore = BalanceStore(
// walletService: walletService,
// settingsStore: settingsStore,
// priceStore: priceStore);
// final loginStore = LoginStore(
// sharedPreferences: sharedPreferences, walletsService: walletListService);
// final seedLanguageStore = SeedLanguageStore();
// final sendTemplateStore = SendTemplateStore(templateSource: templates);
// final exchangeTemplateStore =
// ExchangeTemplateStore(templateSource: exchangeTemplates);
// final walletCreationService = WalletCreationService();
// final authService = AuthService();
await initialSetup( await initialSetup(
sharedPreferences: await SharedPreferences.getInstance(), sharedPreferences: await SharedPreferences.getInstance(),
nodes: nodes, nodes: nodes,
@ -139,15 +68,7 @@ void main() async {
templates: templates, templates: templates,
exchangeTemplates: exchangeTemplates, exchangeTemplates: exchangeTemplates,
initialMigrationVersion: 4); initialMigrationVersion: 4);
// setReactions( runApp(App());
// settingsStore: settingsStore,
// priceStore: priceStore,
// syncStore: syncStore,
// walletStore: walletStore,
// walletService: walletService,
// // authenticationStore: authenticationStore,
// loginStore: loginStore);
runApp(CakeWalletApp());
} }
Future<void> initialSetup( Future<void> initialSetup(
@ -178,63 +99,25 @@ Future<void> initialSetup(
monero_wallet.onStartup(); monero_wallet.onStartup();
} }
class CakeWalletApp extends StatelessWidget { class App extends StatelessWidget {
CakeWalletApp() { App() {
SystemChrome.setPreferredOrientations( SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]); [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
//final settingsStore = Provider.of<SettingsStore>(context);
final settingsStore = getIt.get<AppStore>().settingsStore; final settingsStore = getIt.get<AppStore>().settingsStore;
return ChangeNotifierProvider<ThemeChanger>( if (settingsStore.theme == null) {
create: (_) => ThemeChanger( settingsStore.isDarkTheme = false;
settingsStore.isDarkTheme ? Themes.darkTheme : Themes.lightTheme),
child: ChangeNotifierProvider<Language>(
create: (_) => Language(settingsStore.languageCode),
child: MaterialAppWithTheme()));
} }
}
class MaterialAppWithTheme extends StatelessWidget {
MaterialAppWithTheme();
@override
Widget build(BuildContext context) {
// final sharedPreferences = Provider.of<SharedPreferences>(context);
// final walletService = Provider.of<WalletService>(context);
// final walletListService = Provider.of<WalletListService>(context);
// final userService = Provider.of<UserService>(context);
// final settingsStore = Provider.of<SettingsStore>(context);
// final priceStore = Provider.of<PriceStore>(context);
// final walletStore = Provider.of<WalletStore>(context);
// final syncStore = Provider.of<SyncStore>(context);
// final balanceStore = Provider.of<BalanceStore>(context);
final theme = Provider.of<ThemeChanger>(context);
final currentLanguage = Provider.of<Language>(context);
// final contacts = Provider.of<Box<Contact>>(context);
// final nodes = Provider.of<Box<Node>>(context);
// final trades = Provider.of<Box<Trade>>(context);
// final transactionDescriptions =
// Provider.of<Box<TransactionDescription>>(context);
if (!isThemeChangerRegistered) {
setupThemeChangerStore(theme);
isThemeChangerRegistered = true;
}
/*final statusBarColor =
settingsStore.isDarkTheme ? Colors.black : Colors.white;*/
final _settingsStore = getIt.get<AppStore>().settingsStore;
final statusBarColor = Colors.transparent; final statusBarColor = Colors.transparent;
final statusBarBrightness = final statusBarBrightness =
_settingsStore.isDarkTheme ? Brightness.light : Brightness.dark; settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
final statusBarIconBrightness = final statusBarIconBrightness =
_settingsStore.isDarkTheme ? Brightness.light : Brightness.dark; settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
final authenticationStore = getIt.get<AuthenticationStore>(); final authenticationStore = getIt.get<AuthenticationStore>();
final initialRoute = authenticationStore.state == AuthenticationState.denied final initialRoute = authenticationStore.state == AuthenticationState.denied
? Routes.welcome ? Routes.welcome
@ -245,12 +128,13 @@ class MaterialAppWithTheme extends StatelessWidget {
statusBarBrightness: statusBarBrightness, statusBarBrightness: statusBarBrightness,
statusBarIconBrightness: statusBarIconBrightness)); statusBarIconBrightness: statusBarIconBrightness));
return Observer(builder: (BuildContext context) {
return Root( return Root(
authenticationStore: authenticationStore, authenticationStore: authenticationStore,
child: MaterialApp( child: MaterialApp(
navigatorKey: navigatorKey, navigatorKey: navigatorKey,
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: theme.getTheme(), theme: settingsStore.theme,
localizationsDelegates: [ localizationsDelegates: [
S.delegate, S.delegate,
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
@ -258,9 +142,10 @@ class MaterialAppWithTheme extends StatelessWidget {
GlobalWidgetsLocalizations.delegate, GlobalWidgetsLocalizations.delegate,
], ],
supportedLocales: S.delegate.supportedLocales, supportedLocales: S.delegate.supportedLocales,
locale: Locale(currentLanguage.getCurrentLanguage()), locale: Locale(settingsStore.languageCode),
onGenerateRoute: (settings) => Router.generateRoute(settings), onGenerateRoute: (settings) => Router.generateRoute(settings),
initialRoute: initialRoute, initialRoute: initialRoute,
)); ));
});
} }
} }

View file

@ -252,8 +252,8 @@ class Router {
case Routes.addressBookAddContact: case Routes.addressBookAddContact:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (_) => builder: (_) => getIt.get<ContactPage>(
getIt.get<ContactPage>(param1: settings.arguments as ContactRecord)); param1: settings.arguments as ContactRecord));
case Routes.showKeys: case Routes.showKeys:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
@ -297,10 +297,11 @@ class Router {
return MaterialPageRoute<void>(builder: (_) => getIt.get<RescanPage>()); return MaterialPageRoute<void>(builder: (_) => getIt.get<RescanPage>());
case Routes.faq: case Routes.faq:
return MaterialPageRoute<void>(builder: (_) => FaqPage()); return MaterialPageRoute<void>(builder: (_) => getIt.get<FaqPage>());
case Routes.changeLanguage: case Routes.changeLanguage:
return MaterialPageRoute<void>(builder: (_) => ChangeLanguage()); return MaterialPageRoute<void>(
builder: (_) => getIt.get<LanguageListPage>());
default: default:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(

View file

@ -1,98 +0,0 @@
// import 'dart:async';
// import 'package:flutter/foundation.dart';
// import 'package:mobx/mobx.dart';
// import 'package:cake_wallet/entities/node.dart';
// import 'package:cake_wallet/entities/sync_status.dart';
// import 'package:cake_wallet/src/domain/services/wallet_service.dart';
// import 'package:cake_wallet/src/start_updating_price.dart';
// import 'package:cake_wallet/src/stores/sync/sync_store.dart';
// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
// import 'package:cake_wallet/src/stores/settings/settings_store.dart';
// import 'package:cake_wallet/src/stores/price/price_store.dart';
// import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
// import 'package:cake_wallet/src/stores/login/login_store.dart';
//
// Timer _reconnectionTimer;
// ReactionDisposer _connectToNodeDisposer;
// ReactionDisposer _onSyncStatusChangeDisposer;
// ReactionDisposer _onCurrentWalletChangeDisposer;
//
// void setReactions(
// {@required SettingsStore settingsStore,
// @required PriceStore priceStore,
// @required SyncStore syncStore,
// @required WalletStore walletStore,
// @required WalletService walletService,
// // @required AuthenticationStore authenticationStore,
// @required LoginStore loginStore}) {
// connectToNode(settingsStore: settingsStore, walletStore: walletStore);
// onSyncStatusChange(
// syncStore: syncStore,
// walletStore: walletStore,
// settingsStore: settingsStore);
// onCurrentWalletChange(
// walletStore: walletStore,
// settingsStore: settingsStore,
// priceStore: priceStore);
// autorun((_) async {
// // if (authenticationStore.state == AuthenticationState.allowed) {
// // await loginStore.loadCurrentWallet();
// // authenticationStore.state = AuthenticationState.readyToLogin;
// // }
// });
// }
//
// void connectToNode({SettingsStore settingsStore, WalletStore walletStore}) {
// _connectToNodeDisposer?.call();
//
// _connectToNodeDisposer = reaction((_) => settingsStore.node,
// (Node node) async => await walletStore.connectToNode(node: node));
// }
//
// void onCurrentWalletChange(
// {WalletStore walletStore,
// SettingsStore settingsStore,
// PriceStore priceStore}) {
// _onCurrentWalletChangeDisposer?.call();
//
// reaction((_) => walletStore.name, (String _) {
// walletStore.connectToNode(node: settingsStore.node);
// startUpdatingPrice(settingsStore: settingsStore, priceStore: priceStore);
// });
// }
//
// void onSyncStatusChange(
// {SyncStore syncStore,
// WalletStore walletStore,
// SettingsStore settingsStore}) {
// // _onSyncStatusChangeDisposer?.call();
//
// // reaction((_) => syncStore.status, (SyncStatus status) async {
// // if (status is ConnectedSyncStatus) {
// // await walletStore.startSync();
// // }
//
// // // Reconnect to the node if the app is not started sync after 30 seconds
// // if (status is StartingSyncStatus) {
// // startReconnectionObserver(syncStore: syncStore, walletStore: walletStore);
// // }
// // });
// }
//
// void startReconnectionObserver({SyncStore syncStore, WalletStore walletStore}) {
// if (_reconnectionTimer != null) {
// _reconnectionTimer.cancel();
// }
//
// _reconnectionTimer = Timer.periodic(Duration(minutes: 1), (_) async {
// try {
// final isConnected = await walletStore.isConnected();
//
// if (!isConnected) {
// await walletStore.reconnect();
// }
// } catch (e) {
// print(e);
// }
// });
// }

View file

@ -1,14 +1,22 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:cake_wallet/src/widgets/nav_bar.dart';
import 'package:provider/provider.dart';
import 'package:cake_wallet/themes.dart';
import 'package:cake_wallet/theme_changer.dart';
import 'package:cake_wallet/palette.dart'; import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/src/widgets/nav_bar.dart';
enum AppBarStyle { regular, withShadow, transparent } enum AppBarStyle { regular, withShadow, transparent }
abstract class BasePage extends StatelessWidget { abstract class BasePage extends StatelessWidget {
BasePage()
: _scaffoldKey = GlobalKey<ScaffoldState>(),
_closeButtonImage = Image.asset('assets/images/close_button.png'),
_closeButtonImageDarkTheme =
Image.asset('assets/images/close_button_dark_theme.png');
final GlobalKey<ScaffoldState> _scaffoldKey;
final Image _closeButtonImage;
final Image _closeButtonImageDarkTheme;
String get title => null; String get title => null;
bool get isModalBackButton => false; bool get isModalBackButton => false;
@ -29,11 +37,7 @@ abstract class BasePage extends StatelessWidget {
Widget Function(BuildContext, Widget) get rootWrapper => null; Widget Function(BuildContext, Widget) get rootWrapper => null;
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); bool get _isDarkTheme => getIt.get<SettingsStore>().isDarkTheme;
final _closeButtonImage = Image.asset('assets/images/close_button.png');
final _closeButtonImageDarkTheme =
Image.asset('assets/images/close_button_dark_theme.png');
void onOpenEndDrawer() => _scaffoldKey.currentState.openEndDrawer(); void onOpenEndDrawer() => _scaffoldKey.currentState.openEndDrawer();
@ -46,11 +50,8 @@ abstract class BasePage extends StatelessWidget {
final _backButton = Image.asset('assets/images/back_arrow.png', final _backButton = Image.asset('assets/images/back_arrow.png',
color: titleColor ?? Theme.of(context).primaryTextTheme.title.color); color: titleColor ?? Theme.of(context).primaryTextTheme.title.color);
final _closeButton =
final _themeChanger = Provider.of<ThemeChanger>(context); _isDarkTheme ? _closeButtonImageDarkTheme : _closeButtonImage;
final _closeButton = _themeChanger.getTheme() == Themes.darkTheme
? _closeButtonImageDarkTheme
: _closeButtonImage;
return SizedBox( return SizedBox(
height: 37, height: 37,
@ -86,10 +87,8 @@ abstract class BasePage extends StatelessWidget {
Widget floatingActionButton(BuildContext context) => null; Widget floatingActionButton(BuildContext context) => null;
ObstructingPreferredSizeWidget appBar(BuildContext context) { ObstructingPreferredSizeWidget appBar(BuildContext context) {
final _themeChanger = Provider.of<ThemeChanger>(context); final appBarColor =
final _isDarkTheme = _themeChanger.getTheme() == Themes.darkTheme; _isDarkTheme ? backgroundDarkColor : backgroundLightColor;
final appBarColor = _isDarkTheme
? backgroundDarkColor : backgroundLightColor;
switch (appBarStyle) { switch (appBarStyle) {
case AppBarStyle.regular: case AppBarStyle.regular:
@ -131,9 +130,6 @@ abstract class BasePage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final _themeChanger = Provider.of<ThemeChanger>(context);
final _isDarkTheme = _themeChanger.getTheme() == Themes.darkTheme;
final root = Scaffold( final root = Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
backgroundColor: backgroundColor:
@ -142,7 +138,7 @@ abstract class BasePage extends StatelessWidget {
extendBodyBehindAppBar: extendBodyBehindAppBar, extendBodyBehindAppBar: extendBodyBehindAppBar,
endDrawer: endDrawer, endDrawer: endDrawer,
appBar: appBar(context), appBar: appBar(context),
body: body(context), //SafeArea(child: ), body: body(context),
floatingActionButton: floatingActionButton(context)); floatingActionButton: floatingActionButton(context));
return rootWrapper?.call(context, root) ?? root; return rootWrapper?.call(context, root) ?? root;

View file

@ -164,10 +164,10 @@ class ContactListPage extends BasePage {
final isDelete = final isDelete =
await showAlertDialog(context) ?? false; await showAlertDialog(context) ?? false;
// if (isDelete) { if (isDelete) {
// await contactListViewModel await contactListViewModel
// .delete(contact); .delete(contact);
// } }
}, },
), ),
], ],

View file

@ -1,33 +0,0 @@
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:provider/provider.dart';
import 'package:cake_wallet/exchange/trade.dart';
// import 'package:cake_wallet/monero/transaction_description.dart';
// import 'package:cake_wallet/src/domain/services/wallet_service.dart';
// import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
// import 'package:cake_wallet/src/stores/action_list/action_list_store.dart';
// import 'package:cake_wallet/src/stores/action_list/trade_filter_store.dart';
// import 'package:cake_wallet/src/stores/action_list/transaction_filter_store.dart';
// import 'package:cake_wallet/src/stores/price/price_store.dart';
// import 'package:cake_wallet/src/stores/settings/settings_store.dart';
// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
// FIXME: Remove me.
// Widget createDashboardPage(
// {@required WalletService walletService,
// @required PriceStore priceStore,
// @required Box<TransactionDescription> transactionDescriptions,
// @required SettingsStore settingsStore,
// @required Box<Trade> trades,
// @required WalletStore walletStore}) =>
// Provider(
// create: (_) => ActionListStore(
// walletService: walletService,
// settingsStore: settingsStore,
// priceStore: priceStore,
// tradesSource: trades,
// transactionFilterStore: TransactionFilterStore(),
// tradeFilterStore: TradeFilterStore(walletStore: walletStore),
// transactionDescriptions: transactionDescriptions),
// child: DashboardPage());

View file

@ -105,7 +105,7 @@ class DashboardPage extends BasePage {
Container( Container(
padding: EdgeInsets.only(left: 45, right: 45, bottom: 24), padding: EdgeInsets.only(left: 45, right: 45, bottom: 24),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[ children: <Widget>[
ActionButton( ActionButton(
image: sendImage, image: sendImage,

View file

@ -11,11 +11,8 @@ class BalancePage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: EdgeInsets.all(24), padding: EdgeInsets.all(24),
child: Center(
child: Container(
height: 160,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Observer(builder: (_) { Observer(builder: (_) {
@ -28,6 +25,7 @@ class BalancePage extends StatelessWidget {
height: 1), height: 1),
); );
}), }),
SizedBox(height: 10),
Observer(builder: (_) { Observer(builder: (_) {
return Text(dashboardViewModel.balanceViewModel.cryptoBalance, return Text(dashboardViewModel.balanceViewModel.cryptoBalance,
style: TextStyle( style: TextStyle(
@ -37,6 +35,7 @@ class BalancePage extends StatelessWidget {
height: 1), height: 1),
textAlign: TextAlign.center); textAlign: TextAlign.center);
}), }),
SizedBox(height: 10),
Observer(builder: (_) { Observer(builder: (_) {
return Text(dashboardViewModel.balanceViewModel.fiatBalance, return Text(dashboardViewModel.balanceViewModel.fiatBalance,
style: TextStyle( style: TextStyle(
@ -48,8 +47,6 @@ class BalancePage extends StatelessWidget {
}), }),
], ],
), ),
),
),
); );
} }
} }

View file

@ -146,11 +146,11 @@ class ExchangeCardState extends State<ExchangeCard> {
textAlign: TextAlign.left, textAlign: TextAlign.left,
keyboardType: TextInputType.numberWithOptions( keyboardType: TextInputType.numberWithOptions(
signed: false, decimal: true), signed: false, decimal: true),
inputFormatters: [ // inputFormatters: [
LengthLimitingTextInputFormatter(15), // LengthLimitingTextInputFormatter(15),
BlacklistingTextInputFormatter( // BlacklistingTextInputFormatter(
RegExp('[\\-|\\ |\\,]')) // RegExp('[\\-|\\ |\\,]'))
], // ],
hintText: '0.0000', hintText: '0.0000',
borderColor: widget.borderColor, borderColor: widget.borderColor,
textStyle: TextStyle( textStyle: TextStyle(

View file

@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
import 'package:cake_wallet/palette.dart';
class FAQItem extends StatefulWidget {
FAQItem(this.title, this.text);
final String title;
final String text;
@override
State<StatefulWidget> createState() => FAQItemState();
}
class FAQItemState extends State<FAQItem> {
bool isActive;
@override
void initState() {
isActive = false;
super.initState();
}
@override
Widget build(BuildContext context) {
final addIcon =
Icon(Icons.add, color: Theme.of(context).primaryTextTheme.title.color);
final removeIcon = Icon(Icons.remove, color: Palette.blueCraiola);
final icon = isActive ? removeIcon : addIcon;
final color = isActive
? Palette.blueCraiola
: Theme.of(context).primaryTextTheme.title.color;
return ListTileTheme(
contentPadding: EdgeInsets.fromLTRB(0, 6, 24, 6),
child: ExpansionTile(
title: Text(widget.title,
style: TextStyle(
fontSize: 14, fontWeight: FontWeight.w500, color: color)),
trailing: icon,
onExpansionChanged: (value) => setState(() => isActive = value),
children: <Widget>[
Row(mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.only(
right: 24.0,
),
child: Text(
widget.text,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Theme.of(context).primaryTextTheme.title.color),
),
))
])
],
),
);
}
}

View file

@ -1,46 +1,30 @@
import 'dart:convert'; import 'dart:convert';
import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/src/widgets/standard_list.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/src/screens/faq/faq_item.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/standard_list.dart';
import 'package:cake_wallet/store/settings_store.dart';
class FaqPage extends BasePage { class FaqPage extends BasePage {
FaqPage(this.settingsStore);
final SettingsStore settingsStore;
@override @override
String get title => S.current.faq; String get title => S.current.faq;
@override String get path => 'assets/faq/faq_' + settingsStore.languageCode + '.json';
Widget body(BuildContext context) => FaqForm();
}
class FaqForm extends StatefulWidget {
@override
FaqFormState createState() => FaqFormState();
}
class FaqFormState extends State<FaqForm> {
List<Icon> icons;
List<Color> colors;
bool isLoaded = false;
@override @override
Widget build(BuildContext context) { Widget body(BuildContext context) {
final addIcon = Icon(Icons.add, color: Theme.of(context).primaryTextTheme.title.color);
final removeIcon = Icon(Icons.remove, color: Palette.blueCraiola);
return Container( return Container(
padding: EdgeInsets.only(top: 12, left: 24), padding: EdgeInsets.only(top: 12, left: 24),
child: FutureBuilder( child: FutureBuilder(
builder: (context, snapshot) { builder: (context, snapshot) {
final faqItems = jsonDecode(snapshot.data.toString()) as List; final faqItems = jsonDecode(snapshot.data.toString()) as List;
if (snapshot.hasData) {
setIconsAndColors(context, faqItems.length, addIcon);
}
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
@ -49,112 +33,20 @@ class FaqFormState extends State<FaqForm> {
shrinkWrap: true, shrinkWrap: true,
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
final itemTitle = faqItems[index]["question"].toString(); final title = faqItems[index]["question"].toString();
final itemChild = faqItems[index]["answer"].toString(); final text = faqItems[index]["answer"].toString();
return ListTileTheme( return FAQItem(title, text);
contentPadding: EdgeInsets.fromLTRB(0, 6, 24, 6),
child: ExpansionTile(
title: Text(
itemTitle,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: colors[index]
),
),
trailing: icons[index],
onExpansionChanged: (value) {
setState(() {
if (value) {
icons[index] = removeIcon;
colors[index] = Palette.blueCraiola;
} else {
icons[index] = addIcon;
colors[index] = Theme.of(context).primaryTextTheme.title.color;
}
});
}, },
children: <Widget>[ separatorBuilder: (_, __) => StandardListSeparator(),
Row( itemCount: faqItems?.length ?? 0,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.only(
right: 24.0,
),
child: Text(
itemChild,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Theme.of(context).primaryTextTheme.title.color
),
),
))
],
) )
], ],
), ),
); );
}, },
separatorBuilder: (_, __) => future: rootBundle.loadString(path),
StandardListSeparator(),
itemCount: faqItems == null ? 0 : faqItems.length,
)
],
),
);
},
future: rootBundle.loadString(getFaqPath(context)),
), ),
); );
} }
void setIconsAndColors(BuildContext context, int index, Icon icon) {
if (isLoaded) {
return;
}
icons = List.generate(index, (int i) => icon);
colors = List.generate(index, (int i) => Theme.of(context).primaryTextTheme.title.color);
isLoaded = true;
}
String getFaqPath(BuildContext context) {
// FIXME: FIXME
// final settingsStore = Provider.of<SettingsStore>(context);
//
// switch (settingsStore.languageCode) {
// case 'en':
// return 'assets/faq/faq_en.json';
// case 'uk':
// return 'assets/faq/faq_uk.json';
// case 'ru':
// return 'assets/faq/faq_ru.json';
// case 'es':
// return 'assets/faq/faq_es.json';
// case 'ja':
// return 'assets/faq/faq_ja.json';
// case 'ko':
// return 'assets/faq/faq_ko.json';
// case 'hi':
// return 'assets/faq/faq_hi.json';
// case 'de':
// return 'assets/faq/faq_de.json';
// case 'zh':
// return 'assets/faq/faq_zh.json';
// case 'pt':
// return 'assets/faq/faq_pt.json';
// case 'pl':
// return 'assets/faq/faq_pl.json';
// case 'nl':
// return 'assets/faq/faq_nl.json';
// default:
// return 'assets/faq/faq_en.json';
// }
return '';
}
} }

View file

@ -1,4 +1,5 @@
import 'dart:ui'; import 'dart:ui';
// import 'package:cake_wallet/src/domain/common/transaction_priority.dart'; // import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
import 'package:cake_wallet/core/execution_state.dart'; import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
@ -20,6 +21,7 @@ import 'package:dotted_border/dotted_border.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart'; import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
// import 'package:cake_wallet/src/screens/send/widgets/sending_alert.dart'; // import 'package:cake_wallet/src/screens/send/widgets/sending_alert.dart';
import 'package:cake_wallet/src/widgets/template_tile.dart'; import 'package:cake_wallet/src/widgets/template_tile.dart';
import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
@ -70,8 +72,7 @@ class SendPage extends BasePage {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(24), bottomLeft: Radius.circular(24),
bottomRight: Radius.circular(24) bottomRight: Radius.circular(24)),
),
gradient: LinearGradient(colors: [ gradient: LinearGradient(colors: [
Theme.of(context).primaryTextTheme.subhead.color, Theme.of(context).primaryTextTheme.subhead.color,
Theme.of(context).primaryTextTheme.subhead.decorationColor, Theme.of(context).primaryTextTheme.subhead.decorationColor,
@ -106,10 +107,14 @@ class SendPage extends BasePage {
AddressTextFieldOption.qrCode, AddressTextFieldOption.qrCode,
AddressTextFieldOption.addressBook AddressTextFieldOption.addressBook
], ],
buttonColor: buttonColor: Theme.of(context)
Theme.of(context).primaryTextTheme.display1.color, .primaryTextTheme
borderColor: .display1
Theme.of(context).primaryTextTheme.headline.color, .color,
borderColor: Theme.of(context)
.primaryTextTheme
.headline
.color,
textStyle: TextStyle( textStyle: TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@ -123,17 +128,12 @@ class SendPage extends BasePage {
.decorationColor), .decorationColor),
validator: sendViewModel.addressValidator, validator: sendViewModel.addressValidator,
), ),
Observer(builder: (_) { Padding(
return Padding(
padding: const EdgeInsets.only(top: 20), padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField( child: BaseTextFormField(
controller: _cryptoAmountController, controller: _cryptoAmountController,
keyboardType: TextInputType.numberWithOptions( keyboardType: TextInputType.numberWithOptions(
signed: false, decimal: true), signed: false, decimal: true),
inputFormatters: [
BlacklistingTextInputFormatter(
RegExp('[\\-|\\ |\\,]'))
],
prefixIcon: Padding( prefixIcon: Padding(
padding: EdgeInsets.only(top: 9), padding: EdgeInsets.only(top: 9),
child: child:
@ -157,8 +157,7 @@ class SendPage extends BasePage {
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
Radius.circular(6))), Radius.circular(6))),
child: InkWell( child: InkWell(
onTap: () => onTap: () => sendViewModel.setSendAll(),
sendViewModel.setSendAll(),
child: Center( child: Center(
child: Text(S.of(context).all, child: Text(S.of(context).all,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -188,8 +187,7 @@ class SendPage extends BasePage {
.decorationColor, .decorationColor,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
fontSize: 14), fontSize: 14),
validator: sendViewModel.amountValidator)); validator: sendViewModel.amountValidator)),
}),
Observer( Observer(
builder: (_) => Padding( builder: (_) => Padding(
padding: EdgeInsets.only(top: 10), padding: EdgeInsets.only(top: 10),
@ -228,10 +226,6 @@ class SendPage extends BasePage {
controller: _fiatAmountController, controller: _fiatAmountController,
keyboardType: TextInputType.numberWithOptions( keyboardType: TextInputType.numberWithOptions(
signed: false, decimal: true), signed: false, decimal: true),
inputFormatters: [
BlacklistingTextInputFormatter(
RegExp('[\\-|\\ |\\,]'))
],
prefixIcon: Padding( prefixIcon: Padding(
padding: EdgeInsets.only(top: 9), padding: EdgeInsets.only(top: 9),
child: Text(sendViewModel.fiat.title + ':', child: Text(sendViewModel.fiat.title + ':',
@ -427,13 +421,12 @@ class SendPage extends BasePage {
) )
], ],
), ),
bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24), bottomSectionPadding:
EdgeInsets.only(left: 24, right: 24, bottom: 24),
bottomSection: Observer(builder: (_) { bottomSection: Observer(builder: (_) {
return LoadingPrimaryButton( return LoadingPrimaryButton(
onPressed: () { onPressed: () {
if (_formKey.currentState.validate()) { if (_formKey.currentState.validate()) {}
}
}, },
text: S.of(context).send, text: S.of(context).send,
color: Theme.of(context).accentTextTheme.body2.color, color: Theme.of(context).accentTextTheme.body2.color,
@ -443,8 +436,7 @@ class SendPage extends BasePage {
isDisabled: isDisabled:
false // FIXME !(syncStore.status is SyncedSyncStatus), false // FIXME !(syncStore.status is SyncedSyncStatus),
); );
}) })),
),
); );
} }
@ -565,7 +557,10 @@ class SendPage extends BasePage {
onPressed: () => onPressed: () =>
Navigator.of(context).pop(), Navigator.of(context).pop(),
text: S.of(context).send_got_it, text: S.of(context).send_got_it,
color: Theme.of(context).accentTextTheme.body2.color, color: Theme.of(context)
.accentTextTheme
.body2
.color,
textColor: Colors.white)) textColor: Colors.white))
], ],
); );

View file

@ -1,67 +1,67 @@
import 'package:cake_wallet/src/screens/settings/widgets/language_row.dart'; import 'package:cake_wallet/src/screens/settings/widgets/language_row.dart';
import 'package:cake_wallet/src/widgets/standard_list.dart'; import 'package:cake_wallet/src/widgets/standard_list.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/entities/language.dart'; import 'package:cake_wallet/entities/language_service.dart';
// import 'package:cake_wallet/src/stores/settings/settings_store.dart'; // import 'package:cake_wallet/src/stores/settings/settings_store.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
// FIXME: FIXME class LanguageListPage extends BasePage {
LanguageListPage(this.settingsStore);
final SettingsStore settingsStore;
class ChangeLanguage extends BasePage {
@override @override
String get title => S.current.settings_change_language; String get title => S.current.settings_change_language;
@override @override
Widget body(BuildContext context) { Widget body(BuildContext context) {
// final settingsStore = Provider.of<SettingsStore>(context); return Container(
// final currentLanguage = Provider.of<Language>(context); padding: EdgeInsets.only(top: 10.0),
// child: SectionStandardList(
// return Container( sectionCount: 1,
// padding: EdgeInsets.only(top: 10.0), context: context,
// child: SectionStandardList( itemCounter: (int sectionIndex) => LanguageService.list.values.length,
// sectionCount: 1, itemBuilder: (_, sectionIndex, index) {
// context: context, return Observer(builder: (BuildContext context) {
// itemCounter: (int sectionIndex) => languages.values.length, final item = LanguageService.list.values.elementAt(index);
// itemBuilder: (_, sectionIndex, index) { final code = LanguageService.list.keys.elementAt(index);
// final item = languages.values.elementAt(index); final isCurrent = code == settingsStore.languageCode ?? false;
// final code = languages.keys.elementAt(index);
// return LanguageRow(
// final isCurrent = settingsStore.languageCode == null title: item,
// ? false isSelected: isCurrent,
// : code == settingsStore.languageCode; handler: (context) async {
// if (!isCurrent) {
// return LanguageRow( await showPopUp<void>(
// title: item, context: context,
// isSelected: isCurrent, builder: (BuildContext context) {
// handler: (context) async { return AlertWithTwoActions(
// if (!isCurrent) { alertTitle: S.of(context).change_language,
// await showPopUp<void>( alertContent:
// context: context, S.of(context).change_language_to(item),
// builder: (BuildContext context) { rightButtonText: S.of(context).change,
// return AlertWithTwoActions( leftButtonText: S.of(context).cancel,
// alertTitle: S.of(context).change_language, actionRightButton: () {
// alertContent: S.of(context).change_language_to(item), settingsStore.languageCode = code;
// rightButtonText: S.of(context).change, Navigator.of(context).pop();
// leftButtonText: S.of(context).cancel, },
// actionRightButton: () { actionLeftButton: () =>
// settingsStore.saveLanguageCode( Navigator.of(context).pop());
// languageCode: code); });
// currentLanguage.setCurrentLanguage(code); }
// Navigator.of(context).pop(); },
// }, );
// actionLeftButton: () => Navigator.of(context).pop() });
// ); },
// }); ));
// }
// },
// );
// },
// )
// );
return null; return null;
} }

View file

@ -8,7 +8,7 @@ class AlertCloseButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Positioned( return Positioned(
bottom: 24, bottom: 60,
child: GestureDetector( child: GestureDetector(
onTap: () => Navigator.of(context).pop(), onTap: () => Navigator.of(context).pop(),
child: Container( child: Container(

View file

@ -4,7 +4,6 @@ import 'package:cake_wallet/store/wallet_list_store.dart';
import 'package:cake_wallet/store/authentication_store.dart'; import 'package:cake_wallet/store/authentication_store.dart';
import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/store/node_list_store.dart'; import 'package:cake_wallet/store/node_list_store.dart';
import 'package:cake_wallet/store/contact_list_store.dart';
part 'app_store.g.dart'; part 'app_store.g.dart';
@ -15,7 +14,6 @@ abstract class AppStoreBase with Store {
{this.authenticationStore, {this.authenticationStore,
this.walletList, this.walletList,
this.settingsStore, this.settingsStore,
this.contactListStore,
this.nodeListStore}); this.nodeListStore});
AuthenticationStore authenticationStore; AuthenticationStore authenticationStore;
@ -27,7 +25,5 @@ abstract class AppStoreBase with Store {
SettingsStore settingsStore; SettingsStore settingsStore;
ContactListStore contactListStore;
NodeListStore nodeListStore; NodeListStore nodeListStore;
} }

View file

@ -1,12 +0,0 @@
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/entities/contact_record.dart';
part 'contact_list_store.g.dart';
class ContactListStore = ContactListStoreBase with _$ContactListStore;
abstract class ContactListStoreBase with Store {
ContactListStoreBase() : contacts = ObservableList<ContactRecord>();
final ObservableList<ContactRecord> contacts;
}

View file

@ -1,5 +1,7 @@
import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cake_wallet/themes.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:package_info/package_info.dart'; import 'package:package_info/package_info.dart';
@ -7,7 +9,7 @@ import 'package:devicelocale/devicelocale.dart';
import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/wallet_type.dart'; import 'package:cake_wallet/entities/wallet_type.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:cake_wallet/entities/language.dart'; import 'package:cake_wallet/entities/language_service.dart';
import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart';
import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/entities/node.dart'; import 'package:cake_wallet/entities/node.dart';
@ -29,7 +31,7 @@ abstract class SettingsStoreBase with Store {
@required bool initialDarkTheme, @required bool initialDarkTheme,
@required int initialPinLength, @required int initialPinLength,
@required String initialLanguageCode, @required String initialLanguageCode,
@required String initialCurrentLocale, // @required String initialCurrentLocale,
@required this.appVersion, @required this.appVersion,
@required Map<WalletType, Node> nodes, @required Map<WalletType, Node> nodes,
this.actionlistDisplayMode}) { this.actionlistDisplayMode}) {
@ -41,7 +43,6 @@ abstract class SettingsStoreBase with Store {
isDarkTheme = initialDarkTheme; isDarkTheme = initialDarkTheme;
pinCodeLength = initialPinLength; pinCodeLength = initialPinLength;
languageCode = initialLanguageCode; languageCode = initialLanguageCode;
currentLocale = initialCurrentLocale;
currentNode = nodes[WalletType.monero]; currentNode = nodes[WalletType.monero];
this.nodes = ObservableMap<WalletType, Node>.of(nodes); this.nodes = ObservableMap<WalletType, Node>.of(nodes);
_sharedPreferences = sharedPreferences; _sharedPreferences = sharedPreferences;
@ -59,6 +60,10 @@ abstract class SettingsStoreBase with Store {
reaction((_) => currentNode, reaction((_) => currentNode,
(Node node) => _saveCurrentNode(node, WalletType.monero)); (Node node) => _saveCurrentNode(node, WalletType.monero));
reaction((_) => languageCode,
(String languageCode) => sharedPreferences.setString(
PreferencesKey.currentLanguageCode, languageCode));
} }
static const defaultPinLength = 4; static const defaultPinLength = 4;
@ -91,9 +96,11 @@ abstract class SettingsStoreBase with Store {
@observable @observable
Node currentNode; Node currentNode;
String languageCode; @computed
ThemeData get theme => isDarkTheme ? Themes.darkTheme : Themes.lightTheme;
String currentLocale; @observable
String languageCode;
String appVersion; String appVersion;
@ -135,8 +142,7 @@ abstract class SettingsStoreBase with Store {
defaultPinLength; defaultPinLength;
final savedLanguageCode = final savedLanguageCode =
sharedPreferences.getString(PreferencesKey.currentLanguageCode) ?? sharedPreferences.getString(PreferencesKey.currentLanguageCode) ??
await Language.localeDetection(); await LanguageService.localeDetection();
final initialCurrentLocale = await Devicelocale.currentLocale;
final nodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey); final nodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey);
final bitcoinElectrumServerId = sharedPreferences final bitcoinElectrumServerId = sharedPreferences
.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey); .getInt(PreferencesKey.currentBitcoinElectrumSererIdKey);
@ -159,8 +165,8 @@ abstract class SettingsStoreBase with Store {
initialDarkTheme: savedDarkTheme, initialDarkTheme: savedDarkTheme,
actionlistDisplayMode: actionListDisplayMode, actionlistDisplayMode: actionListDisplayMode,
initialPinLength: pinLength, initialPinLength: pinLength,
initialLanguageCode: savedLanguageCode, initialLanguageCode: savedLanguageCode
initialCurrentLocale: initialCurrentLocale); );
} }
Future<void> _saveCurrentNode(Node node, WalletType walletType) async { Future<void> _saveCurrentNode(Node node, WalletType walletType) async {

View file

@ -1,13 +0,0 @@
import 'package:cake_wallet/theme_changer.dart';
import 'package:mobx/mobx.dart';
part 'theme_changer_store.g.dart';
class ThemeChangerStore = ThemeChangerStoreBase with _$ThemeChangerStore;
abstract class ThemeChangerStoreBase with Store {
ThemeChangerStoreBase({this.themeChanger});
@observable
ThemeChanger themeChanger;
}

View file

@ -1,16 +0,0 @@
import 'package:flutter/material.dart';
class ThemeChanger with ChangeNotifier {
ThemeChanger(this._themeData);
ThemeData _themeData;
ThemeData getTheme() => _themeData;
void setTheme(ThemeData theme){
_themeData = theme;
notifyListeners();
}
}

View file

@ -4,7 +4,7 @@ import 'package:cake_wallet/store/settings_store.dart';
class DateFormatter { class DateFormatter {
static String get currentLocalFormat { static String get currentLocalFormat {
final isUSA = getIt.get<SettingsStore>().currentLocale == 'en_US'; final isUSA = getIt.get<SettingsStore>().languageCode.toLowerCase() == 'en';
final format = isUSA ? 'yyyy.MM.dd, HH:mm' : 'dd.MM.yyyy, HH:mm'; final format = isUSA ? 'yyyy.MM.dd, HH:mm' : 'dd.MM.yyyy, HH:mm';
return format; return format;

View file

@ -84,7 +84,8 @@ extension MobxBindable<T extends Keyable> on Box<T> {
return; return;
} }
dest.acceptBoxChange(event, transformed: transform(event.value as T)); dest.acceptBoxChange(event,
transformed: event.deleted ? null : transform(event.value as T));
}); });
} }
} }
@ -111,7 +112,8 @@ extension HiveBindable<T extends Keyable> on ObservableList<T> {
} }
final value = change.newValue as T; final value = change.newValue as T;
controller.add(EntityChange(value, type)); controller.add(EntityChange(value, type,
key: type == ChangeType.delete ? change.index : value.keyIndex));
}); });
}); });

View file

@ -1,9 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:cake_wallet/entities/contact_record.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/core/contact_service.dart'; import 'package:cake_wallet/entities/contact_record.dart';
import 'package:cake_wallet/store/contact_list_store.dart';
import 'package:cake_wallet/entities/contact.dart'; import 'package:cake_wallet/entities/contact.dart';
import 'package:cake_wallet/utils/mobx.dart'; import 'package:cake_wallet/utils/mobx.dart';
@ -13,24 +11,16 @@ class ContactListViewModel = ContactListViewModelBase
with _$ContactListViewModel; with _$ContactListViewModel;
abstract class ContactListViewModelBase with Store { abstract class ContactListViewModelBase with Store {
ContactListViewModelBase( ContactListViewModelBase(this.contactSource)
this.addressBookStore, this.contactService, this.contactSource) { : contacts = ObservableList<ContactRecord>() {
_subscription = contactSource.bindToListWithTransform(addressBookStore.contacts, _subscription = contactSource.bindToListWithTransform(
(Contact contact) => ContactRecord(contactSource, contact), contacts, (Contact contact) => ContactRecord(contactSource, contact),
initialFire: true); initialFire: true);
} }
final ContactListStore addressBookStore;
final ContactService contactService;
final Box<Contact> contactSource; final Box<Contact> contactSource;
final ObservableList<ContactRecord> contacts;
ObservableList<ContactRecord> get contacts => addressBookStore.contacts;
StreamSubscription<BoxEvent> _subscription; StreamSubscription<BoxEvent> _subscription;
void dispose() { Future<void> delete(ContactRecord contact) async => contact.original.delete();
// _subscription.cancel();
}
Future<void> delete(Contact contact) async => contactService.delete(contact);
} }

View file

@ -3,7 +3,6 @@ import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/core/execution_state.dart'; import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/core/wallet_base.dart'; import 'package:cake_wallet/core/wallet_base.dart';
import 'package:cake_wallet/core/contact_service.dart';
import 'package:cake_wallet/entities/contact.dart'; import 'package:cake_wallet/entities/contact.dart';
import 'package:cake_wallet/entities/crypto_currency.dart'; import 'package:cake_wallet/entities/crypto_currency.dart';
@ -12,13 +11,13 @@ part 'contact_view_model.g.dart';
class ContactViewModel = ContactViewModelBase with _$ContactViewModel; class ContactViewModel = ContactViewModelBase with _$ContactViewModel;
abstract class ContactViewModelBase with Store { abstract class ContactViewModelBase with Store {
ContactViewModelBase(this._contacts, this._wallet, {ContactRecord contact}) ContactViewModelBase(this._contacts, {ContactRecord contact})
: state = InitialExecutionState(), : state = InitialExecutionState(),
currencies = CryptoCurrency.all, currencies = CryptoCurrency.all,
_contact = contact { _contact = contact {
name = _contact?.name; name = _contact?.name;
address = _contact?.address; address = _contact?.address;
currency = _contact?.type; //_wallet.currency; currency = _contact?.type;
} }
@observable @observable
@ -40,7 +39,6 @@ abstract class ContactViewModelBase with Store {
(address?.isNotEmpty ?? false); (address?.isNotEmpty ?? false);
final List<CryptoCurrency> currencies; final List<CryptoCurrency> currencies;
final WalletBase _wallet;
final Box<Contact> _contacts; final Box<Contact> _contacts;
final ContactRecord _contact; final ContactRecord _contact;
@ -60,10 +58,7 @@ abstract class ContactViewModelBase with Store {
_contact.address = address; _contact.address = address;
_contact.type = currency; _contact.type = currency;
await _contact.save(); await _contact.save();
// await _contacts.put(_contact.key, _contact);
} else { } else {
// final contact = ContactRecordBase.create(_contacts, name, address, currency);
// await contact.save();
await _contacts await _contacts
.add(Contact(name: name, address: address, type: currency)); .add(Contact(name: name, address: address, type: currency));
} }

View file

@ -70,15 +70,17 @@ abstract class SendViewModelBase with Store {
@computed @computed
String get balance { String get balance {
String balance = '0.0';
if (_wallet is MoneroWallet) { if (_wallet is MoneroWallet) {
_wallet.balance.formattedUnlockedBalance; balance = _wallet.balance.formattedUnlockedBalance as String ?? '';
} }
if (_wallet is BitcoinWallet) { if (_wallet is BitcoinWallet) {
_wallet.balance.confirmedFormatted; balance = _wallet.balance.confirmedFormatted as String ?? '';
} }
return '0.0'; return balance;
} }
@computed @computed

View file

@ -1,27 +1,24 @@
import 'package:cake_wallet/core/wallet_base.dart';
import 'package:cake_wallet/entities/biometric_auth.dart';
import 'package:cake_wallet/entities/wallet_type.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/store/theme_changer_store.dart';
import 'package:cake_wallet/themes.dart';
import 'package:cake_wallet/view_model/settings/version_list_item.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:package_info/package_info.dart';
import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/core/wallet_base.dart';
import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/entities/biometric_auth.dart';
import 'package:cake_wallet/entities/wallet_type.dart';
import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart';
import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/entities/node.dart'; import 'package:cake_wallet/entities/node.dart';
import 'package:cake_wallet/entities/transaction_priority.dart'; import 'package:cake_wallet/entities/transaction_priority.dart';
import 'package:cake_wallet/entities/action_list_display_mode.dart'; import 'package:cake_wallet/entities/action_list_display_mode.dart';
import 'package:cake_wallet/src/screens/auth/auth_page.dart'; import 'package:cake_wallet/view_model/settings/version_list_item.dart';
import 'package:cake_wallet/view_model/settings/link_list_item.dart'; import 'package:cake_wallet/view_model/settings/link_list_item.dart';
import 'package:cake_wallet/view_model/settings/picker_list_item.dart'; import 'package:cake_wallet/view_model/settings/picker_list_item.dart';
import 'package:cake_wallet/view_model/settings/regular_list_item.dart'; import 'package:cake_wallet/view_model/settings/regular_list_item.dart';
import 'package:cake_wallet/view_model/settings/settings_list_item.dart'; import 'package:cake_wallet/view_model/settings/settings_list_item.dart';
import 'package:cake_wallet/view_model/settings/switcher_list_item.dart'; import 'package:cake_wallet/view_model/settings/switcher_list_item.dart';
import 'package:package_info/package_info.dart'; import 'package:cake_wallet/src/screens/auth/auth_page.dart';
part 'settings_view_model.g.dart'; part 'settings_view_model.g.dart';
@ -111,13 +108,8 @@ abstract class SettingsViewModelBase with Store {
SwitcherListItem( SwitcherListItem(
title: S.current.settings_dark_mode, title: S.current.settings_dark_mode,
value: () => _settingsStore.isDarkTheme, value: () => _settingsStore.isDarkTheme,
onValueChange: (_, bool value) { onValueChange: (_, bool value) =>
_settingsStore.isDarkTheme = value; _settingsStore.isDarkTheme = value)
getIt
.get<ThemeChangerStore>()
.themeChanger
.setTheme(value ? Themes.darkTheme : Themes.lightTheme);
})
], ],
[ [
LinkListItem( LinkListItem(

View file

@ -13,7 +13,7 @@ import 'package:cake_wallet/main.dart';
void main() { void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async { testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame. // Build our app and trigger a frame.
await tester.pumpWidget(CakeWalletApp()); await tester.pumpWidget(App());
// Verify that our counter starts at 0. // Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget); expect(find.text('0'), findsOneWidget);