This commit is contained in:
M 2020-10-20 15:09:49 +03:00
parent 6b86cfbea2
commit aa120c33b1
9 changed files with 125 additions and 69 deletions

View file

@ -354,7 +354,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 7; CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@ -493,7 +493,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 7; CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@ -526,7 +526,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 7; CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (

View file

@ -157,7 +157,6 @@ class _WalletNameFormState extends State<WalletNameForm> {
builder: (context) { builder: (context) {
return LoadingPrimaryButton( return LoadingPrimaryButton(
onPressed: _confirmForm, onPressed: _confirmForm,
//text: S.of(context).continue_text,
text: S.of(context).seed_language_next, text: S.of(context).seed_language_next,
color: Colors.green, color: Colors.green,
textColor: Colors.white, textColor: Colors.white,

View file

@ -50,8 +50,7 @@ class AddressCell extends StatelessWidget {
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 14,
fontWeight: FontWeight.w600,
color: textColor, color: textColor,
), ),
), ),

View file

@ -7,7 +7,10 @@ import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
import 'package:cake_wallet/src/widgets/blockchain_height_widget.dart'; import 'package:cake_wallet/src/widgets/blockchain_height_widget.dart';
class WalletRestoreFromSeedForm extends StatefulWidget { class WalletRestoreFromSeedForm extends StatefulWidget {
WalletRestoreFromSeedForm({Key key}) : super(key: key); WalletRestoreFromSeedForm({Key key, this.blockHeightFocusNode})
: super(key: key);
final FocusNode blockHeightFocusNode;
@override @override
WalletRestoreFromSeedFormState createState() => WalletRestoreFromSeedFormState createState() =>
@ -36,7 +39,7 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
return Container( return Container(
padding: EdgeInsets.only(left: 25, right: 25), padding: EdgeInsets.only(left: 25, right: 25),
child: Column(children: [ child: Column(children: [
SeedWidget(key: seedWidgetStateKey), SeedWidget(key: seedWidgetStateKey, language: language),
GestureDetector( GestureDetector(
onTap: () async { onTap: () async {
final selected = await showPopUp<String>( final selected = await showPopUp<String>(
@ -54,16 +57,15 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
enableInteractiveSelection: false, enableInteractiveSelection: false,
readOnly: true)))), readOnly: true)))),
BlockchainHeightWidget( BlockchainHeightWidget(
key: blockchainHeightKey, focusNode: widget.blockHeightFocusNode,
onHeightChange: (height) { key: blockchainHeightKey)
print(height);
})
])); ]));
} }
void _changeLanguage(String language) { void _changeLanguage(String language) {
setState(() { setState(() {
this.language = language; this.language = language;
seedWidgetStateKey.currentState.changeSeedLanguage(language);
_setLanguageLabel(language); _setLanguageLabel(language);
}); });
} }

View file

@ -1,5 +1,8 @@
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart';
@ -20,9 +23,12 @@ class WalletRestorePage extends BasePage {
walletRestoreFromKeysFormKey = walletRestoreFromKeysFormKey =
GlobalKey<WalletRestoreFromKeysFromState>(), GlobalKey<WalletRestoreFromKeysFromState>(),
_pages = [], _pages = [],
_blockHeightFocusNode = FocusNode(),
_controller = PageController(initialPage: 0) { _controller = PageController(initialPage: 0) {
_pages.addAll([ _pages.addAll([
WalletRestoreFromSeedForm(key: walletRestoreFromSeedFormKey), WalletRestoreFromSeedForm(
key: walletRestoreFromSeedFormKey,
blockHeightFocusNode: _blockHeightFocusNode),
WalletRestoreFromKeysFrom(key: walletRestoreFromKeysFormKey) WalletRestoreFromKeysFrom(key: walletRestoreFromKeysFormKey)
]); ]);
} }
@ -49,6 +55,7 @@ class WalletRestorePage extends BasePage {
final List<Widget> _pages; final List<Widget> _pages;
final GlobalKey<WalletRestoreFromSeedFormState> walletRestoreFromSeedFormKey; final GlobalKey<WalletRestoreFromSeedFormState> walletRestoreFromSeedFormKey;
final GlobalKey<WalletRestoreFromKeysFromState> walletRestoreFromKeysFormKey; final GlobalKey<WalletRestoreFromKeysFromState> walletRestoreFromKeysFormKey;
final FocusNode _blockHeightFocusNode;
@override @override
Widget body(BuildContext context) { Widget body(BuildContext context) {
@ -77,7 +84,7 @@ class WalletRestorePage extends BasePage {
}, },
controller: _controller, controller: _controller,
itemCount: _pages.length, itemCount: _pages.length,
itemBuilder: (_, index) => _pages[index])), itemBuilder: (_, index) => SingleChildScrollView(child: _pages[index]))),
Padding( Padding(
padding: EdgeInsets.only(top: 10), padding: EdgeInsets.only(top: 10),
child: SmoothPageIndicator( child: SmoothPageIndicator(
@ -93,13 +100,17 @@ class WalletRestorePage extends BasePage {
)), )),
Padding( Padding(
padding: EdgeInsets.only(top: 20, bottom: 40, left: 25, right: 25), padding: EdgeInsets.only(top: 20, bottom: 40, left: 25, right: 25),
child: PrimaryButton( child: Observer(
text: S.of(context).restore_recover, builder: (context) {
isDisabled: false, return LoadingPrimaryButton(
onPressed: () => onPressed: () =>
walletRestoreViewModel.create(options: _credentials()), walletRestoreViewModel.create(options: _credentials()),
color: Theme.of(context).accentTextTheme.body2.color, text: S.of(context).seed_language_next,
textColor: Colors.white)), color: Colors.green,
textColor: Colors.white,
isLoading: walletRestoreViewModel.state is IsExecutingState);
},
))
]); ]);
} }

View file

@ -40,7 +40,7 @@ class AnnotatedEditableText extends EditableText {
color: Colors.black, color: Colors.black,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
fontSize: 20))) fontSize: 16)))
.toList(), .toList(),
super( super(
maxLines: null, maxLines: null,

View file

@ -6,10 +6,11 @@ import 'package:cake_wallet/monero/get_height_by_date.dart';
import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
class BlockchainHeightWidget extends StatefulWidget { class BlockchainHeightWidget extends StatefulWidget {
BlockchainHeightWidget({GlobalKey key, this.onHeightChange}) BlockchainHeightWidget({GlobalKey key, this.onHeightChange, this.focusNode})
: super(key: key); : super(key: key);
final Function(int) onHeightChange; final Function(int) onHeightChange;
final FocusNode focusNode;
@override @override
State<StatefulWidget> createState() => BlockchainHeightState(); State<StatefulWidget> createState() => BlockchainHeightState();
@ -49,12 +50,12 @@ class BlockchainHeightState extends State<BlockchainHeightWidget> {
child: Container( child: Container(
padding: EdgeInsets.only(top: 20.0, bottom: 10.0), padding: EdgeInsets.only(top: 20.0, bottom: 10.0),
child: BaseTextFormField( child: BaseTextFormField(
focusNode: widget.focusNode,
controller: restoreHeightController, controller: restoreHeightController,
keyboardType: TextInputType.numberWithOptions( keyboardType: TextInputType.numberWithOptions(
signed: false, decimal: false), signed: false, decimal: false),
hintText: S.of(context).widgets_restore_from_blockheight, hintText: S.of(context).widgets_restore_from_blockheight,
) )))
))
], ],
), ),
Padding( Padding(
@ -77,8 +78,7 @@ class BlockchainHeightState extends State<BlockchainHeightWidget> {
child: BaseTextFormField( child: BaseTextFormField(
controller: dateController, controller: dateController,
hintText: S.of(context).widgets_restore_from_date, hintText: S.of(context).widgets_restore_from_date,
) )),
),
), ),
)) ))
], ],

View file

@ -12,22 +12,36 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
class SeedWidget extends StatefulWidget { class SeedWidget extends StatefulWidget {
SeedWidget({Key key}) : super(key: key); SeedWidget({Key key, this.language}) : super(key: key);
final String language;
@override @override
SeedWidgetState createState() => SeedWidgetState(); SeedWidgetState createState() => SeedWidgetState(language);
} }
class SeedWidgetState extends State<SeedWidget> { class SeedWidgetState extends State<SeedWidget> {
SeedWidgetState() SeedWidgetState(String language)
: controller = TextEditingController(), : controller = TextEditingController(),
focusNode = FocusNode(), focusNode = FocusNode(),
words = words = SeedValidator.getWordList(
SeedValidator.getWordList(type: WalletType.monero, language: 'en'); type: WalletType.monero, language: language) {
focusNode.addListener(() {
setState(() {
if (!focusNode.hasFocus && controller.text.isEmpty) {
_showPlaceholder = true;
}
if (focusNode.hasFocus) {
_showPlaceholder = false;
}
});
});
}
final TextEditingController controller; final TextEditingController controller;
final FocusNode focusNode; final FocusNode focusNode;
final List<String> words; List<String> words;
bool _showPlaceholder; bool _showPlaceholder;
String get text => controller.text; String get text => controller.text;
@ -38,12 +52,11 @@ class SeedWidgetState extends State<SeedWidget> {
_showPlaceholder = true; _showPlaceholder = true;
} }
Future<void> _pasteAddress() async { void changeSeedLanguage(String language) {
final value = await Clipboard.getData('text/plain'); setState(() {
words = SeedValidator.getWordList(
if (value?.text?.isNotEmpty ?? false) { type: WalletType.monero, language: language);
controller.text = value.text; });
}
} }
@override @override
@ -84,15 +97,16 @@ class SeedWidgetState extends State<SeedWidget> {
child: InkWell( child: InkWell(
onTap: () async => _pasteAddress(), onTap: () async => _pasteAddress(),
child: Container( child: Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).hintColor, color: Theme.of(context).hintColor,
borderRadius: BorderRadius.all(Radius.circular(6))), borderRadius:
// child: Image.asset('assets/images/duplicate.png', BorderRadius.all(Radius.circular(6))),
// color: Theme.of(context) child: Image.asset('assets/images/paste_ios.png',
// .primaryTextTheme color: Theme.of(context)
// .display1 .primaryTextTheme
// .decorationColor) .display1
), .decorationColor)),
))) )))
]), ]),
Container( Container(
@ -101,4 +115,15 @@ class SeedWidgetState extends State<SeedWidget> {
color: Theme.of(context).primaryTextTheme.title.backgroundColor), color: Theme.of(context).primaryTextTheme.title.backgroundColor),
])); ]));
} }
Future<void> _pasteAddress() async {
final value = await Clipboard.getData('text/plain');
if (value?.text?.isNotEmpty ?? false) {
setState(() {
_showPlaceholder = false;
controller.text = value.text;
});
}
}
} }

View file

@ -1,6 +1,7 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:uuid/uuid.dart';
import 'package:cake_wallet/store/app_store.dart'; import 'package:cake_wallet/store/app_store.dart';
import 'package:cake_wallet/core/wallet_base.dart'; import 'package:cake_wallet/core/wallet_base.dart';
import 'package:cake_wallet/core/generate_wallet_password.dart'; import 'package:cake_wallet/core/generate_wallet_password.dart';
@ -9,6 +10,7 @@ import 'package:cake_wallet/core/wallet_credentials.dart';
import 'package:cake_wallet/entities/wallet_type.dart'; import 'package:cake_wallet/entities/wallet_type.dart';
import 'package:cake_wallet/entities/wallet_info.dart'; import 'package:cake_wallet/entities/wallet_info.dart';
import 'package:cake_wallet/view_model/wallet_creation_vm.dart'; import 'package:cake_wallet/view_model/wallet_creation_vm.dart';
import 'package:cake_wallet/monero/monero_wallet_service.dart';
part 'wallet_restore_view_model.g.dart'; part 'wallet_restore_view_model.g.dart';
@ -23,6 +25,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
{@required WalletType type}) {@required WalletType type})
: super(appStore, walletInfoSource, type: type, isRecovery: true) { : super(appStore, walletInfoSource, type: type, isRecovery: true) {
mode = WalletRestoreMode.seed; mode = WalletRestoreMode.seed;
_walletCreationService.changeWalletType(type: WalletType.monero);
} }
@observable @observable
@ -33,22 +36,39 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
@override @override
WalletCredentials getCredentials(dynamic options) { WalletCredentials getCredentials(dynamic options) {
final password = generateWalletPassword(type); final password = generateWalletPassword(type);
final height = options['height'] as int;
name = Uuid().v4().substring(0, 10);
// switch (type) { if (mode == WalletRestoreMode.seed) {
// case WalletType.monero: final seed = options['seed'] as String;
// return MoneroRestoreWalletFromSeedCredentials(
// name: name, height: height, mnemonic: seed, password: password); return MoneroRestoreWalletFromSeedCredentials(
// case WalletType.bitcoin: name: name, height: height, mnemonic: seed, password: password);
// return BitcoinRestoreWalletFromSeedCredentials( }
// name: name, mnemonic: seed, password: password);
// default: if (mode == WalletRestoreMode.keys) {
// return null; final viewKey = options['viewKey'] as String;
// } final spendKey = options['spendKey'] as String;
final address = options['address'] as String;
return MoneroRestoreWalletFromKeysCredentials(
name: name,
height: height,
spendKey: spendKey,
viewKey: viewKey,
address: address,
password: password);
}
return null; return null;
} }
@override @override
Future<WalletBase> process(WalletCredentials credentials) async => Future<WalletBase> process(WalletCredentials credentials) async {
_walletCreationService.restoreFromSeed(credentials); if (mode == WalletRestoreMode.keys) {
return _walletCreationService.restoreFromKeys(credentials);
}
return _walletCreationService.restoreFromSeed(credentials);
}
} }