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 = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -493,7 +493,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -526,7 +526,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (

View file

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

View file

@ -50,8 +50,7 @@ class AddressCell extends StatelessWidget {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
fontSize: 14,
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';
class WalletRestoreFromSeedForm extends StatefulWidget {
WalletRestoreFromSeedForm({Key key}) : super(key: key);
WalletRestoreFromSeedForm({Key key, this.blockHeightFocusNode})
: super(key: key);
final FocusNode blockHeightFocusNode;
@override
WalletRestoreFromSeedFormState createState() =>
@ -36,7 +39,7 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
return Container(
padding: EdgeInsets.only(left: 25, right: 25),
child: Column(children: [
SeedWidget(key: seedWidgetStateKey),
SeedWidget(key: seedWidgetStateKey, language: language),
GestureDetector(
onTap: () async {
final selected = await showPopUp<String>(
@ -54,16 +57,15 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
enableInteractiveSelection: false,
readOnly: true)))),
BlockchainHeightWidget(
key: blockchainHeightKey,
onHeightChange: (height) {
print(height);
})
focusNode: widget.blockHeightFocusNode,
key: blockchainHeightKey)
]));
}
void _changeLanguage(String language) {
setState(() {
this.language = language;
seedWidgetStateKey.currentState.changeSeedLanguage(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/material.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
import 'package:mobx/mobx.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
@ -20,9 +23,12 @@ class WalletRestorePage extends BasePage {
walletRestoreFromKeysFormKey =
GlobalKey<WalletRestoreFromKeysFromState>(),
_pages = [],
_blockHeightFocusNode = FocusNode(),
_controller = PageController(initialPage: 0) {
_pages.addAll([
WalletRestoreFromSeedForm(key: walletRestoreFromSeedFormKey),
WalletRestoreFromSeedForm(
key: walletRestoreFromSeedFormKey,
blockHeightFocusNode: _blockHeightFocusNode),
WalletRestoreFromKeysFrom(key: walletRestoreFromKeysFormKey)
]);
}
@ -49,6 +55,7 @@ class WalletRestorePage extends BasePage {
final List<Widget> _pages;
final GlobalKey<WalletRestoreFromSeedFormState> walletRestoreFromSeedFormKey;
final GlobalKey<WalletRestoreFromKeysFromState> walletRestoreFromKeysFormKey;
final FocusNode _blockHeightFocusNode;
@override
Widget body(BuildContext context) {
@ -77,7 +84,7 @@ class WalletRestorePage extends BasePage {
},
controller: _controller,
itemCount: _pages.length,
itemBuilder: (_, index) => _pages[index])),
itemBuilder: (_, index) => SingleChildScrollView(child: _pages[index]))),
Padding(
padding: EdgeInsets.only(top: 10),
child: SmoothPageIndicator(
@ -93,13 +100,17 @@ class WalletRestorePage extends BasePage {
)),
Padding(
padding: EdgeInsets.only(top: 20, bottom: 40, left: 25, right: 25),
child: PrimaryButton(
text: S.of(context).restore_recover,
isDisabled: false,
onPressed: () =>
walletRestoreViewModel.create(options: _credentials()),
color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white)),
child: Observer(
builder: (context) {
return LoadingPrimaryButton(
onPressed: () =>
walletRestoreViewModel.create(options: _credentials()),
text: S.of(context).seed_language_next,
color: Colors.green,
textColor: Colors.white,
isLoading: walletRestoreViewModel.state is IsExecutingState);
},
))
]);
}

View file

@ -40,7 +40,7 @@ class AnnotatedEditableText extends EditableText {
color: Colors.black,
backgroundColor: Colors.transparent,
fontWeight: FontWeight.normal,
fontSize: 20)))
fontSize: 16)))
.toList(),
super(
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';
class BlockchainHeightWidget extends StatefulWidget {
BlockchainHeightWidget({GlobalKey key, this.onHeightChange})
BlockchainHeightWidget({GlobalKey key, this.onHeightChange, this.focusNode})
: super(key: key);
final Function(int) onHeightChange;
final FocusNode focusNode;
@override
State<StatefulWidget> createState() => BlockchainHeightState();
@ -47,14 +48,14 @@ class BlockchainHeightState extends State<BlockchainHeightWidget> {
children: <Widget>[
Flexible(
child: Container(
padding: EdgeInsets.only(top: 20.0, bottom: 10.0),
child: BaseTextFormField(
controller: restoreHeightController,
keyboardType: TextInputType.numberWithOptions(
signed: false, decimal: false),
hintText: S.of(context).widgets_restore_from_blockheight,
)
))
padding: EdgeInsets.only(top: 20.0, bottom: 10.0),
child: BaseTextFormField(
focusNode: widget.focusNode,
controller: restoreHeightController,
keyboardType: TextInputType.numberWithOptions(
signed: false, decimal: false),
hintText: S.of(context).widgets_restore_from_blockheight,
)))
],
),
Padding(
@ -74,11 +75,10 @@ class BlockchainHeightState extends State<BlockchainHeightWidget> {
child: InkWell(
onTap: () => _selectDate(context),
child: IgnorePointer(
child: BaseTextFormField(
controller: dateController,
hintText: S.of(context).widgets_restore_from_date,
)
),
child: BaseTextFormField(
controller: dateController,
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';
class SeedWidget extends StatefulWidget {
SeedWidget({Key key}) : super(key: key);
SeedWidget({Key key, this.language}) : super(key: key);
final String language;
@override
SeedWidgetState createState() => SeedWidgetState();
SeedWidgetState createState() => SeedWidgetState(language);
}
class SeedWidgetState extends State<SeedWidget> {
SeedWidgetState()
SeedWidgetState(String language)
: controller = TextEditingController(),
focusNode = FocusNode(),
words =
SeedValidator.getWordList(type: WalletType.monero, language: 'en');
words = SeedValidator.getWordList(
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 FocusNode focusNode;
final List<String> words;
List<String> words;
bool _showPlaceholder;
String get text => controller.text;
@ -38,12 +52,11 @@ class SeedWidgetState extends State<SeedWidget> {
_showPlaceholder = true;
}
Future<void> _pasteAddress() async {
final value = await Clipboard.getData('text/plain');
if (value?.text?.isNotEmpty ?? false) {
controller.text = value.text;
}
void changeSeedLanguage(String language) {
setState(() {
words = SeedValidator.getWordList(
type: WalletType.monero, language: language);
});
}
@override
@ -84,15 +97,16 @@ class SeedWidgetState extends State<SeedWidget> {
child: InkWell(
onTap: () async => _pasteAddress(),
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).hintColor,
borderRadius: BorderRadius.all(Radius.circular(6))),
// child: Image.asset('assets/images/duplicate.png',
// color: Theme.of(context)
// .primaryTextTheme
// .display1
// .decorationColor)
),
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Theme.of(context).hintColor,
borderRadius:
BorderRadius.all(Radius.circular(6))),
child: Image.asset('assets/images/paste_ios.png',
color: Theme.of(context)
.primaryTextTheme
.display1
.decorationColor)),
)))
]),
Container(
@ -101,4 +115,15 @@ class SeedWidgetState extends State<SeedWidget> {
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:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:uuid/uuid.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:cake_wallet/core/wallet_base.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_info.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';
@ -23,6 +25,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
{@required WalletType type})
: super(appStore, walletInfoSource, type: type, isRecovery: true) {
mode = WalletRestoreMode.seed;
_walletCreationService.changeWalletType(type: WalletType.monero);
}
@observable
@ -33,22 +36,39 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
@override
WalletCredentials getCredentials(dynamic options) {
final password = generateWalletPassword(type);
final height = options['height'] as int;
name = Uuid().v4().substring(0, 10);
// switch (type) {
// case WalletType.monero:
// return MoneroRestoreWalletFromSeedCredentials(
// name: name, height: height, mnemonic: seed, password: password);
// case WalletType.bitcoin:
// return BitcoinRestoreWalletFromSeedCredentials(
// name: name, mnemonic: seed, password: password);
// default:
// return null;
// }
if (mode == WalletRestoreMode.seed) {
final seed = options['seed'] as String;
return MoneroRestoreWalletFromSeedCredentials(
name: name, height: height, mnemonic: seed, password: password);
}
if (mode == WalletRestoreMode.keys) {
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;
}
@override
Future<WalletBase> process(WalletCredentials credentials) async =>
_walletCreationService.restoreFromSeed(credentials);
Future<WalletBase> process(WalletCredentials credentials) async {
if (mode == WalletRestoreMode.keys) {
return _walletCreationService.restoreFromKeys(credentials);
}
return _walletCreationService.restoreFromSeed(credentials);
}
}