mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 09:17:35 +00:00
Fixes
This commit is contained in:
parent
51cf11127c
commit
e3678d2cf9
32 changed files with 482 additions and 904 deletions
|
@ -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);
|
||||
}
|
||||
}
|
31
lib/di.dart
31
lib/di.dart
|
@ -1,5 +1,4 @@
|
|||
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/entities/biometric_auth.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/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_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/faq/faq_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/rescan/rescan_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/settings/change_language.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/wallet_keys/wallet_keys_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/store/contact_list_store.dart';
|
||||
import 'package:cake_wallet/store/node_list_store.dart';
|
||||
import 'package:cake_wallet/store/settings_store.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/subaddress/address_edit_or_create_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/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_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_seed_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:get_it/get_it.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.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(AuthenticationStore());
|
||||
getIt.registerSingleton<WalletListStore>(WalletListStore());
|
||||
getIt.registerSingleton(ContactListStore());
|
||||
getIt.registerSingleton(NodeListStoreBase.instance);
|
||||
getIt.registerSingleton<SettingsStore>(settingsStore);
|
||||
getIt.registerSingleton<AppStore>(AppStore(
|
||||
authenticationStore: getIt.get<AuthenticationStore>(),
|
||||
walletList: getIt.get<WalletListStore>(),
|
||||
settingsStore: getIt.get<SettingsStore>(),
|
||||
contactListStore: getIt.get<ContactListStore>(),
|
||||
nodeListStore: getIt.get<NodeListStore>()));
|
||||
getIt.registerSingleton<ContactService>(
|
||||
ContactService(contactSource, getIt.get<AppStore>().contactListStore));
|
||||
getIt.registerSingleton<TradesStore>(TradesStore(
|
||||
tradesSource: tradesSource, settingsStore: getIt.get<SettingsStore>()));
|
||||
getIt.registerSingleton<TradeFilterStore>(TradeFilterStore());
|
||||
|
@ -285,14 +275,10 @@ Future setup(
|
|||
getIt.registerFactory(() => WalletKeysPage(getIt.get<WalletKeysViewModel>()));
|
||||
|
||||
getIt.registerFactoryParam<ContactViewModel, ContactRecord, void>(
|
||||
(ContactRecord contact, _) => ContactViewModel(
|
||||
contactSource, getIt.get<AppStore>().wallet,
|
||||
contact: contact));
|
||||
(ContactRecord contact, _) =>
|
||||
ContactViewModel(contactSource, contact: contact));
|
||||
|
||||
getIt.registerFactory(() => ContactListViewModel(
|
||||
getIt.get<AppStore>().contactListStore,
|
||||
getIt.get<ContactService>(),
|
||||
contactSource));
|
||||
getIt.registerFactory(() => ContactListViewModel(contactSource));
|
||||
|
||||
getIt.registerFactoryParam<ContactListPage, bool, void>(
|
||||
(bool isEditable, _) => ContactListPage(getIt.get<ContactListViewModel>(),
|
||||
|
@ -366,9 +352,8 @@ Future setup(
|
|||
getIt.registerFactory(() => RescanViewModel(getIt.get<AppStore>().wallet));
|
||||
|
||||
getIt.registerFactory(() => RescanPage(getIt.get<RescanViewModel>()));
|
||||
}
|
||||
|
||||
void setupThemeChangerStore(ThemeChanger themeChanger) {
|
||||
getIt.registerSingleton<ThemeChangerStore>(
|
||||
ThemeChangerStore(themeChanger: themeChanger));
|
||||
getIt.registerFactory(() => FaqPage(getIt.get<SettingsStore>()));
|
||||
|
||||
getIt.registerFactory(() => LanguageListPage(getIt.get<SettingsStore>()));
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
}
|
26
lib/entities/language_service.dart
Normal file
26
lib/entities/language_service.dart
Normal 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';
|
||||
}
|
||||
}
|
|
@ -61,6 +61,7 @@ class Node extends HiveObject with Keyable {
|
|||
}
|
||||
|
||||
Future<bool> requestMoneroNode() async {
|
||||
try {
|
||||
Map<String, dynamic> resBody;
|
||||
|
||||
if (login != null && password != null) {
|
||||
|
@ -79,6 +80,9 @@ class Node extends HiveObject with Keyable {
|
|||
}
|
||||
|
||||
return !(resBody['result']['offline'] as bool);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> requestBitcoinElectrumServer() async {
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:hive/hive.dart';
|
|||
|
||||
abstract class Record<T extends HiveObject> with Keyable {
|
||||
Record(this._source, this.original) {
|
||||
key = original.key;
|
||||
_listener?.cancel();
|
||||
_listener = _source.watch(key: original.key).listen((event) {
|
||||
if (!event.deleted) {
|
||||
|
@ -16,7 +17,7 @@ abstract class Record<T extends HiveObject> with Keyable {
|
|||
toBind(original);
|
||||
}
|
||||
|
||||
dynamic get key => original.key;
|
||||
dynamic key;
|
||||
|
||||
@override
|
||||
dynamic get keyIndex => key;
|
||||
|
|
165
lib/main.dart
165
lib/main.dart
|
@ -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/services.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:cake_wallet/router.dart';
|
||||
import 'theme_changer.dart';
|
||||
import 'themes.dart';
|
||||
import 'package:cake_wallet/routes.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/contact.dart';
|
||||
import 'package:cake_wallet/entities/node.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/fiat_currency.dart';
|
||||
import 'package:cake_wallet/entities/transaction_priority.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.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/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;
|
||||
import 'package:cake_wallet/src/screens/root/root.dart';
|
||||
|
||||
final navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
|
@ -94,41 +58,6 @@ void main() async {
|
|||
final templates = await Hive.openBox<Template>(Template.boxName);
|
||||
final exchangeTemplates =
|
||||
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(
|
||||
sharedPreferences: await SharedPreferences.getInstance(),
|
||||
nodes: nodes,
|
||||
|
@ -139,15 +68,7 @@ void main() async {
|
|||
templates: templates,
|
||||
exchangeTemplates: exchangeTemplates,
|
||||
initialMigrationVersion: 4);
|
||||
// setReactions(
|
||||
// settingsStore: settingsStore,
|
||||
// priceStore: priceStore,
|
||||
// syncStore: syncStore,
|
||||
// walletStore: walletStore,
|
||||
// walletService: walletService,
|
||||
// // authenticationStore: authenticationStore,
|
||||
// loginStore: loginStore);
|
||||
runApp(CakeWalletApp());
|
||||
runApp(App());
|
||||
}
|
||||
|
||||
Future<void> initialSetup(
|
||||
|
@ -178,63 +99,25 @@ Future<void> initialSetup(
|
|||
monero_wallet.onStartup();
|
||||
}
|
||||
|
||||
class CakeWalletApp extends StatelessWidget {
|
||||
CakeWalletApp() {
|
||||
class App extends StatelessWidget {
|
||||
App() {
|
||||
SystemChrome.setPreferredOrientations(
|
||||
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//final settingsStore = Provider.of<SettingsStore>(context);
|
||||
final settingsStore = getIt.get<AppStore>().settingsStore;
|
||||
|
||||
return ChangeNotifierProvider<ThemeChanger>(
|
||||
create: (_) => ThemeChanger(
|
||||
settingsStore.isDarkTheme ? Themes.darkTheme : Themes.lightTheme),
|
||||
child: ChangeNotifierProvider<Language>(
|
||||
create: (_) => Language(settingsStore.languageCode),
|
||||
child: MaterialAppWithTheme()));
|
||||
if (settingsStore.theme == null) {
|
||||
settingsStore.isDarkTheme = false;
|
||||
}
|
||||
}
|
||||
|
||||
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 statusBarBrightness =
|
||||
_settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
|
||||
settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
|
||||
final statusBarIconBrightness =
|
||||
_settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
|
||||
settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
|
||||
final authenticationStore = getIt.get<AuthenticationStore>();
|
||||
final initialRoute = authenticationStore.state == AuthenticationState.denied
|
||||
? Routes.welcome
|
||||
|
@ -245,12 +128,13 @@ class MaterialAppWithTheme extends StatelessWidget {
|
|||
statusBarBrightness: statusBarBrightness,
|
||||
statusBarIconBrightness: statusBarIconBrightness));
|
||||
|
||||
return Observer(builder: (BuildContext context) {
|
||||
return Root(
|
||||
authenticationStore: authenticationStore,
|
||||
child: MaterialApp(
|
||||
navigatorKey: navigatorKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: theme.getTheme(),
|
||||
theme: settingsStore.theme,
|
||||
localizationsDelegates: [
|
||||
S.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
|
@ -258,9 +142,10 @@ class MaterialAppWithTheme extends StatelessWidget {
|
|||
GlobalWidgetsLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
locale: Locale(currentLanguage.getCurrentLanguage()),
|
||||
locale: Locale(settingsStore.languageCode),
|
||||
onGenerateRoute: (settings) => Router.generateRoute(settings),
|
||||
initialRoute: initialRoute,
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,8 +252,8 @@ class Router {
|
|||
|
||||
case Routes.addressBookAddContact:
|
||||
return CupertinoPageRoute<void>(
|
||||
builder: (_) =>
|
||||
getIt.get<ContactPage>(param1: settings.arguments as ContactRecord));
|
||||
builder: (_) => getIt.get<ContactPage>(
|
||||
param1: settings.arguments as ContactRecord));
|
||||
|
||||
case Routes.showKeys:
|
||||
return MaterialPageRoute<void>(
|
||||
|
@ -297,10 +297,11 @@ class Router {
|
|||
return MaterialPageRoute<void>(builder: (_) => getIt.get<RescanPage>());
|
||||
|
||||
case Routes.faq:
|
||||
return MaterialPageRoute<void>(builder: (_) => FaqPage());
|
||||
return MaterialPageRoute<void>(builder: (_) => getIt.get<FaqPage>());
|
||||
|
||||
case Routes.changeLanguage:
|
||||
return MaterialPageRoute<void>(builder: (_) => ChangeLanguage());
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (_) => getIt.get<LanguageListPage>());
|
||||
|
||||
default:
|
||||
return MaterialPageRoute<void>(
|
||||
|
|
|
@ -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);
|
||||
// }
|
||||
// });
|
||||
// }
|
|
@ -1,14 +1,22 @@
|
|||
import 'package:flutter/cupertino.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/di.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/src/widgets/nav_bar.dart';
|
||||
|
||||
enum AppBarStyle { regular, withShadow, transparent }
|
||||
|
||||
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;
|
||||
|
||||
bool get isModalBackButton => false;
|
||||
|
@ -29,11 +37,7 @@ abstract class BasePage extends StatelessWidget {
|
|||
|
||||
Widget Function(BuildContext, Widget) get rootWrapper => null;
|
||||
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
final _closeButtonImage = Image.asset('assets/images/close_button.png');
|
||||
final _closeButtonImageDarkTheme =
|
||||
Image.asset('assets/images/close_button_dark_theme.png');
|
||||
bool get _isDarkTheme => getIt.get<SettingsStore>().isDarkTheme;
|
||||
|
||||
void onOpenEndDrawer() => _scaffoldKey.currentState.openEndDrawer();
|
||||
|
||||
|
@ -46,11 +50,8 @@ abstract class BasePage extends StatelessWidget {
|
|||
|
||||
final _backButton = Image.asset('assets/images/back_arrow.png',
|
||||
color: titleColor ?? Theme.of(context).primaryTextTheme.title.color);
|
||||
|
||||
final _themeChanger = Provider.of<ThemeChanger>(context);
|
||||
final _closeButton = _themeChanger.getTheme() == Themes.darkTheme
|
||||
? _closeButtonImageDarkTheme
|
||||
: _closeButtonImage;
|
||||
final _closeButton =
|
||||
_isDarkTheme ? _closeButtonImageDarkTheme : _closeButtonImage;
|
||||
|
||||
return SizedBox(
|
||||
height: 37,
|
||||
|
@ -86,10 +87,8 @@ abstract class BasePage extends StatelessWidget {
|
|||
Widget floatingActionButton(BuildContext context) => null;
|
||||
|
||||
ObstructingPreferredSizeWidget appBar(BuildContext context) {
|
||||
final _themeChanger = Provider.of<ThemeChanger>(context);
|
||||
final _isDarkTheme = _themeChanger.getTheme() == Themes.darkTheme;
|
||||
final appBarColor = _isDarkTheme
|
||||
? backgroundDarkColor : backgroundLightColor;
|
||||
final appBarColor =
|
||||
_isDarkTheme ? backgroundDarkColor : backgroundLightColor;
|
||||
|
||||
switch (appBarStyle) {
|
||||
case AppBarStyle.regular:
|
||||
|
@ -131,9 +130,6 @@ abstract class BasePage extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final _themeChanger = Provider.of<ThemeChanger>(context);
|
||||
final _isDarkTheme = _themeChanger.getTheme() == Themes.darkTheme;
|
||||
|
||||
final root = Scaffold(
|
||||
key: _scaffoldKey,
|
||||
backgroundColor:
|
||||
|
@ -142,7 +138,7 @@ abstract class BasePage extends StatelessWidget {
|
|||
extendBodyBehindAppBar: extendBodyBehindAppBar,
|
||||
endDrawer: endDrawer,
|
||||
appBar: appBar(context),
|
||||
body: body(context), //SafeArea(child: ),
|
||||
body: body(context),
|
||||
floatingActionButton: floatingActionButton(context));
|
||||
|
||||
return rootWrapper?.call(context, root) ?? root;
|
||||
|
|
|
@ -164,10 +164,10 @@ class ContactListPage extends BasePage {
|
|||
final isDelete =
|
||||
await showAlertDialog(context) ?? false;
|
||||
|
||||
// if (isDelete) {
|
||||
// await contactListViewModel
|
||||
// .delete(contact);
|
||||
// }
|
||||
if (isDelete) {
|
||||
await contactListViewModel
|
||||
.delete(contact);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
@ -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());
|
|
@ -105,7 +105,7 @@ class DashboardPage extends BasePage {
|
|||
Container(
|
||||
padding: EdgeInsets.only(left: 45, right: 45, bottom: 24),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
ActionButton(
|
||||
image: sendImage,
|
||||
|
|
|
@ -11,11 +11,8 @@ class BalancePage extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(24),
|
||||
child: Center(
|
||||
child: Container(
|
||||
height: 160,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Observer(builder: (_) {
|
||||
|
@ -28,6 +25,7 @@ class BalancePage extends StatelessWidget {
|
|||
height: 1),
|
||||
);
|
||||
}),
|
||||
SizedBox(height: 10),
|
||||
Observer(builder: (_) {
|
||||
return Text(dashboardViewModel.balanceViewModel.cryptoBalance,
|
||||
style: TextStyle(
|
||||
|
@ -37,6 +35,7 @@ class BalancePage extends StatelessWidget {
|
|||
height: 1),
|
||||
textAlign: TextAlign.center);
|
||||
}),
|
||||
SizedBox(height: 10),
|
||||
Observer(builder: (_) {
|
||||
return Text(dashboardViewModel.balanceViewModel.fiatBalance,
|
||||
style: TextStyle(
|
||||
|
@ -48,8 +47,6 @@ class BalancePage extends StatelessWidget {
|
|||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,11 +146,11 @@ class ExchangeCardState extends State<ExchangeCard> {
|
|||
textAlign: TextAlign.left,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(15),
|
||||
BlacklistingTextInputFormatter(
|
||||
RegExp('[\\-|\\ |\\,]'))
|
||||
],
|
||||
// inputFormatters: [
|
||||
// LengthLimitingTextInputFormatter(15),
|
||||
// BlacklistingTextInputFormatter(
|
||||
// RegExp('[\\-|\\ |\\,]'))
|
||||
// ],
|
||||
hintText: '0.0000',
|
||||
borderColor: widget.borderColor,
|
||||
textStyle: TextStyle(
|
||||
|
|
61
lib/src/screens/faq/faq_item.dart
Normal file
61
lib/src/screens/faq/faq_item.dart
Normal 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),
|
||||
),
|
||||
))
|
||||
])
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,46 +1,30 @@
|
|||
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/services.dart';
|
||||
import 'package:provider/provider.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/widgets/standard_list.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
|
||||
class FaqPage extends BasePage {
|
||||
FaqPage(this.settingsStore);
|
||||
|
||||
final SettingsStore settingsStore;
|
||||
|
||||
@override
|
||||
String get title => S.current.faq;
|
||||
|
||||
@override
|
||||
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;
|
||||
String get path => 'assets/faq/faq_' + settingsStore.languageCode + '.json';
|
||||
|
||||
@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);
|
||||
|
||||
Widget body(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 12, left: 24),
|
||||
child: FutureBuilder(
|
||||
builder: (context, snapshot) {
|
||||
final faqItems = jsonDecode(snapshot.data.toString()) as List;
|
||||
|
||||
if (snapshot.hasData) {
|
||||
setIconsAndColors(context, faqItems.length, addIcon);
|
||||
}
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
|
@ -49,112 +33,20 @@ class FaqFormState extends State<FaqForm> {
|
|||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final itemTitle = faqItems[index]["question"].toString();
|
||||
final itemChild = faqItems[index]["answer"].toString();
|
||||
final title = faqItems[index]["question"].toString();
|
||||
final text = faqItems[index]["answer"].toString();
|
||||
|
||||
return ListTileTheme(
|
||||
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;
|
||||
}
|
||||
});
|
||||
return FAQItem(title, text);
|
||||
},
|
||||
children: <Widget>[
|
||||
Row(
|
||||
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: (_, __) => StandardListSeparator(),
|
||||
itemCount: faqItems?.length ?? 0,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) =>
|
||||
StandardListSeparator(),
|
||||
itemCount: faqItems == null ? 0 : faqItems.length,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
future: rootBundle.loadString(getFaqPath(context)),
|
||||
future: rootBundle.loadString(path),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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 '';
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:ui';
|
||||
|
||||
// import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
import 'package:cake_wallet/core/execution_state.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_two_actions.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/widgets/template_tile.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
|
@ -70,8 +72,7 @@ class SendPage extends BasePage {
|
|||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(24),
|
||||
bottomRight: Radius.circular(24)
|
||||
),
|
||||
bottomRight: Radius.circular(24)),
|
||||
gradient: LinearGradient(colors: [
|
||||
Theme.of(context).primaryTextTheme.subhead.color,
|
||||
Theme.of(context).primaryTextTheme.subhead.decorationColor,
|
||||
|
@ -106,10 +107,14 @@ class SendPage extends BasePage {
|
|||
AddressTextFieldOption.qrCode,
|
||||
AddressTextFieldOption.addressBook
|
||||
],
|
||||
buttonColor:
|
||||
Theme.of(context).primaryTextTheme.display1.color,
|
||||
borderColor:
|
||||
Theme.of(context).primaryTextTheme.headline.color,
|
||||
buttonColor: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.display1
|
||||
.color,
|
||||
borderColor: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.headline
|
||||
.color,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
|
@ -123,17 +128,12 @@ class SendPage extends BasePage {
|
|||
.decorationColor),
|
||||
validator: sendViewModel.addressValidator,
|
||||
),
|
||||
Observer(builder: (_) {
|
||||
return Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: BaseTextFormField(
|
||||
controller: _cryptoAmountController,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
inputFormatters: [
|
||||
BlacklistingTextInputFormatter(
|
||||
RegExp('[\\-|\\ |\\,]'))
|
||||
],
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.only(top: 9),
|
||||
child:
|
||||
|
@ -157,8 +157,7 @@ class SendPage extends BasePage {
|
|||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(6))),
|
||||
child: InkWell(
|
||||
onTap: () =>
|
||||
sendViewModel.setSendAll(),
|
||||
onTap: () => sendViewModel.setSendAll(),
|
||||
child: Center(
|
||||
child: Text(S.of(context).all,
|
||||
textAlign: TextAlign.center,
|
||||
|
@ -188,8 +187,7 @@ class SendPage extends BasePage {
|
|||
.decorationColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14),
|
||||
validator: sendViewModel.amountValidator));
|
||||
}),
|
||||
validator: sendViewModel.amountValidator)),
|
||||
Observer(
|
||||
builder: (_) => Padding(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
|
@ -228,10 +226,6 @@ class SendPage extends BasePage {
|
|||
controller: _fiatAmountController,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
inputFormatters: [
|
||||
BlacklistingTextInputFormatter(
|
||||
RegExp('[\\-|\\ |\\,]'))
|
||||
],
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.only(top: 9),
|
||||
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: (_) {
|
||||
return LoadingPrimaryButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState.validate()) {
|
||||
|
||||
}
|
||||
if (_formKey.currentState.validate()) {}
|
||||
},
|
||||
text: S.of(context).send,
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
|
@ -443,8 +436,7 @@ class SendPage extends BasePage {
|
|||
isDisabled:
|
||||
false // FIXME !(syncStore.status is SyncedSyncStatus),
|
||||
);
|
||||
})
|
||||
),
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -565,7 +557,10 @@ class SendPage extends BasePage {
|
|||
onPressed: () =>
|
||||
Navigator.of(context).pop(),
|
||||
text: S.of(context).send_got_it,
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.body2
|
||||
.color,
|
||||
textColor: Colors.white))
|
||||
],
|
||||
);
|
||||
|
|
|
@ -1,67 +1,67 @@
|
|||
import 'package:cake_wallet/src/screens/settings/widgets/language_row.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/cupertino.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:provider/provider.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/screens/base_page.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
|
||||
String get title => S.current.settings_change_language;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
// final settingsStore = Provider.of<SettingsStore>(context);
|
||||
// final currentLanguage = Provider.of<Language>(context);
|
||||
//
|
||||
// return Container(
|
||||
// padding: EdgeInsets.only(top: 10.0),
|
||||
// child: SectionStandardList(
|
||||
// sectionCount: 1,
|
||||
// context: context,
|
||||
// itemCounter: (int sectionIndex) => languages.values.length,
|
||||
// itemBuilder: (_, sectionIndex, index) {
|
||||
// final item = languages.values.elementAt(index);
|
||||
// final code = languages.keys.elementAt(index);
|
||||
//
|
||||
// final isCurrent = settingsStore.languageCode == null
|
||||
// ? false
|
||||
// : code == settingsStore.languageCode;
|
||||
//
|
||||
// return LanguageRow(
|
||||
// title: item,
|
||||
// isSelected: isCurrent,
|
||||
// handler: (context) async {
|
||||
// if (!isCurrent) {
|
||||
// await showPopUp<void>(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return AlertWithTwoActions(
|
||||
// alertTitle: S.of(context).change_language,
|
||||
// alertContent: S.of(context).change_language_to(item),
|
||||
// rightButtonText: S.of(context).change,
|
||||
// leftButtonText: S.of(context).cancel,
|
||||
// actionRightButton: () {
|
||||
// settingsStore.saveLanguageCode(
|
||||
// languageCode: code);
|
||||
// currentLanguage.setCurrentLanguage(code);
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// actionLeftButton: () => Navigator.of(context).pop()
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// )
|
||||
// );
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 10.0),
|
||||
child: SectionStandardList(
|
||||
sectionCount: 1,
|
||||
context: context,
|
||||
itemCounter: (int sectionIndex) => LanguageService.list.values.length,
|
||||
itemBuilder: (_, sectionIndex, index) {
|
||||
return Observer(builder: (BuildContext context) {
|
||||
final item = LanguageService.list.values.elementAt(index);
|
||||
final code = LanguageService.list.keys.elementAt(index);
|
||||
final isCurrent = code == settingsStore.languageCode ?? false;
|
||||
|
||||
return LanguageRow(
|
||||
title: item,
|
||||
isSelected: isCurrent,
|
||||
handler: (context) async {
|
||||
if (!isCurrent) {
|
||||
await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithTwoActions(
|
||||
alertTitle: S.of(context).change_language,
|
||||
alertContent:
|
||||
S.of(context).change_language_to(item),
|
||||
rightButtonText: S.of(context).change,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
actionRightButton: () {
|
||||
settingsStore.languageCode = code;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
actionLeftButton: () =>
|
||||
Navigator.of(context).pop());
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
},
|
||||
));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ class AlertCloseButton extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Positioned(
|
||||
bottom: 24,
|
||||
bottom: 60,
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.of(context).pop(),
|
||||
child: Container(
|
||||
|
|
|
@ -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/settings_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';
|
||||
|
||||
|
@ -15,7 +14,6 @@ abstract class AppStoreBase with Store {
|
|||
{this.authenticationStore,
|
||||
this.walletList,
|
||||
this.settingsStore,
|
||||
this.contactListStore,
|
||||
this.nodeListStore});
|
||||
|
||||
AuthenticationStore authenticationStore;
|
||||
|
@ -27,7 +25,5 @@ abstract class AppStoreBase with Store {
|
|||
|
||||
SettingsStore settingsStore;
|
||||
|
||||
ContactListStore contactListStore;
|
||||
|
||||
NodeListStore nodeListStore;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||
import 'package:cake_wallet/themes.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.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/entities/wallet_type.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/fiat_currency.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
|
@ -29,7 +31,7 @@ abstract class SettingsStoreBase with Store {
|
|||
@required bool initialDarkTheme,
|
||||
@required int initialPinLength,
|
||||
@required String initialLanguageCode,
|
||||
@required String initialCurrentLocale,
|
||||
// @required String initialCurrentLocale,
|
||||
@required this.appVersion,
|
||||
@required Map<WalletType, Node> nodes,
|
||||
this.actionlistDisplayMode}) {
|
||||
|
@ -41,7 +43,6 @@ abstract class SettingsStoreBase with Store {
|
|||
isDarkTheme = initialDarkTheme;
|
||||
pinCodeLength = initialPinLength;
|
||||
languageCode = initialLanguageCode;
|
||||
currentLocale = initialCurrentLocale;
|
||||
currentNode = nodes[WalletType.monero];
|
||||
this.nodes = ObservableMap<WalletType, Node>.of(nodes);
|
||||
_sharedPreferences = sharedPreferences;
|
||||
|
@ -59,6 +60,10 @@ abstract class SettingsStoreBase with Store {
|
|||
|
||||
reaction((_) => currentNode,
|
||||
(Node node) => _saveCurrentNode(node, WalletType.monero));
|
||||
|
||||
reaction((_) => languageCode,
|
||||
(String languageCode) => sharedPreferences.setString(
|
||||
PreferencesKey.currentLanguageCode, languageCode));
|
||||
}
|
||||
|
||||
static const defaultPinLength = 4;
|
||||
|
@ -91,9 +96,11 @@ abstract class SettingsStoreBase with Store {
|
|||
@observable
|
||||
Node currentNode;
|
||||
|
||||
String languageCode;
|
||||
@computed
|
||||
ThemeData get theme => isDarkTheme ? Themes.darkTheme : Themes.lightTheme;
|
||||
|
||||
String currentLocale;
|
||||
@observable
|
||||
String languageCode;
|
||||
|
||||
String appVersion;
|
||||
|
||||
|
@ -135,8 +142,7 @@ abstract class SettingsStoreBase with Store {
|
|||
defaultPinLength;
|
||||
final savedLanguageCode =
|
||||
sharedPreferences.getString(PreferencesKey.currentLanguageCode) ??
|
||||
await Language.localeDetection();
|
||||
final initialCurrentLocale = await Devicelocale.currentLocale;
|
||||
await LanguageService.localeDetection();
|
||||
final nodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey);
|
||||
final bitcoinElectrumServerId = sharedPreferences
|
||||
.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey);
|
||||
|
@ -159,8 +165,8 @@ abstract class SettingsStoreBase with Store {
|
|||
initialDarkTheme: savedDarkTheme,
|
||||
actionlistDisplayMode: actionListDisplayMode,
|
||||
initialPinLength: pinLength,
|
||||
initialLanguageCode: savedLanguageCode,
|
||||
initialCurrentLocale: initialCurrentLocale);
|
||||
initialLanguageCode: savedLanguageCode
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _saveCurrentNode(Node node, WalletType walletType) async {
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ import 'package:cake_wallet/store/settings_store.dart';
|
|||
|
||||
class DateFormatter {
|
||||
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';
|
||||
|
||||
return format;
|
||||
|
|
|
@ -84,7 +84,8 @@ extension MobxBindable<T extends Keyable> on Box<T> {
|
|||
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;
|
||||
controller.add(EntityChange(value, type));
|
||||
controller.add(EntityChange(value, type,
|
||||
key: type == ChangeType.delete ? change.index : value.keyIndex));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'package:cake_wallet/entities/contact_record.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/core/contact_service.dart';
|
||||
import 'package:cake_wallet/store/contact_list_store.dart';
|
||||
import 'package:cake_wallet/entities/contact_record.dart';
|
||||
import 'package:cake_wallet/entities/contact.dart';
|
||||
import 'package:cake_wallet/utils/mobx.dart';
|
||||
|
||||
|
@ -13,24 +11,16 @@ class ContactListViewModel = ContactListViewModelBase
|
|||
with _$ContactListViewModel;
|
||||
|
||||
abstract class ContactListViewModelBase with Store {
|
||||
ContactListViewModelBase(
|
||||
this.addressBookStore, this.contactService, this.contactSource) {
|
||||
_subscription = contactSource.bindToListWithTransform(addressBookStore.contacts,
|
||||
(Contact contact) => ContactRecord(contactSource, contact),
|
||||
ContactListViewModelBase(this.contactSource)
|
||||
: contacts = ObservableList<ContactRecord>() {
|
||||
_subscription = contactSource.bindToListWithTransform(
|
||||
contacts, (Contact contact) => ContactRecord(contactSource, contact),
|
||||
initialFire: true);
|
||||
}
|
||||
|
||||
final ContactListStore addressBookStore;
|
||||
final ContactService contactService;
|
||||
final Box<Contact> contactSource;
|
||||
|
||||
ObservableList<ContactRecord> get contacts => addressBookStore.contacts;
|
||||
|
||||
final ObservableList<ContactRecord> contacts;
|
||||
StreamSubscription<BoxEvent> _subscription;
|
||||
|
||||
void dispose() {
|
||||
// _subscription.cancel();
|
||||
}
|
||||
|
||||
Future<void> delete(Contact contact) async => contactService.delete(contact);
|
||||
Future<void> delete(ContactRecord contact) async => contact.original.delete();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:hive/hive.dart';
|
|||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/core/execution_state.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/crypto_currency.dart';
|
||||
|
||||
|
@ -12,13 +11,13 @@ part 'contact_view_model.g.dart';
|
|||
class ContactViewModel = ContactViewModelBase with _$ContactViewModel;
|
||||
|
||||
abstract class ContactViewModelBase with Store {
|
||||
ContactViewModelBase(this._contacts, this._wallet, {ContactRecord contact})
|
||||
ContactViewModelBase(this._contacts, {ContactRecord contact})
|
||||
: state = InitialExecutionState(),
|
||||
currencies = CryptoCurrency.all,
|
||||
_contact = contact {
|
||||
name = _contact?.name;
|
||||
address = _contact?.address;
|
||||
currency = _contact?.type; //_wallet.currency;
|
||||
currency = _contact?.type;
|
||||
}
|
||||
|
||||
@observable
|
||||
|
@ -40,7 +39,6 @@ abstract class ContactViewModelBase with Store {
|
|||
(address?.isNotEmpty ?? false);
|
||||
|
||||
final List<CryptoCurrency> currencies;
|
||||
final WalletBase _wallet;
|
||||
final Box<Contact> _contacts;
|
||||
final ContactRecord _contact;
|
||||
|
||||
|
@ -60,10 +58,7 @@ abstract class ContactViewModelBase with Store {
|
|||
_contact.address = address;
|
||||
_contact.type = currency;
|
||||
await _contact.save();
|
||||
// await _contacts.put(_contact.key, _contact);
|
||||
} else {
|
||||
// final contact = ContactRecordBase.create(_contacts, name, address, currency);
|
||||
// await contact.save();
|
||||
await _contacts
|
||||
.add(Contact(name: name, address: address, type: currency));
|
||||
}
|
||||
|
|
|
@ -70,15 +70,17 @@ abstract class SendViewModelBase with Store {
|
|||
|
||||
@computed
|
||||
String get balance {
|
||||
String balance = '0.0';
|
||||
|
||||
if (_wallet is MoneroWallet) {
|
||||
_wallet.balance.formattedUnlockedBalance;
|
||||
balance = _wallet.balance.formattedUnlockedBalance as String ?? '';
|
||||
}
|
||||
|
||||
if (_wallet is BitcoinWallet) {
|
||||
_wallet.balance.confirmedFormatted;
|
||||
balance = _wallet.balance.confirmedFormatted as String ?? '';
|
||||
}
|
||||
|
||||
return '0.0';
|
||||
return balance;
|
||||
}
|
||||
|
||||
@computed
|
||||
|
|
|
@ -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:mobx/mobx.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'package:cake_wallet/routes.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/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/fiat_currency.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
import 'package:cake_wallet/entities/transaction_priority.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/picker_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/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';
|
||||
|
||||
|
@ -111,13 +108,8 @@ abstract class SettingsViewModelBase with Store {
|
|||
SwitcherListItem(
|
||||
title: S.current.settings_dark_mode,
|
||||
value: () => _settingsStore.isDarkTheme,
|
||||
onValueChange: (_, bool value) {
|
||||
_settingsStore.isDarkTheme = value;
|
||||
getIt
|
||||
.get<ThemeChangerStore>()
|
||||
.themeChanger
|
||||
.setTheme(value ? Themes.darkTheme : Themes.lightTheme);
|
||||
})
|
||||
onValueChange: (_, bool value) =>
|
||||
_settingsStore.isDarkTheme = value)
|
||||
],
|
||||
[
|
||||
LinkListItem(
|
||||
|
|
|
@ -13,7 +13,7 @@ import 'package:cake_wallet/main.dart';
|
|||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(CakeWalletApp());
|
||||
await tester.pumpWidget(App());
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
|
|
Loading…
Reference in a new issue