mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-25 13:09:32 +00:00
Initial commit
This commit is contained in:
parent
2333949a81
commit
af9ef76260
1 changed files with 110 additions and 67 deletions
|
@ -18,7 +18,10 @@ import 'package:cake_wallet/view_model/wallet_seed_view_model.dart';
|
||||||
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
|
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
|
||||||
|
|
||||||
class WalletSeedPage extends BasePage {
|
class WalletSeedPage extends BasePage {
|
||||||
WalletSeedPage(this.walletSeedViewModel, {required this.isNewWalletCreated});
|
WalletSeedPage(this.walletSeedViewModel, {required this.isNewWalletCreated})
|
||||||
|
: seedController = TextEditingController(),
|
||||||
|
nameController = TextEditingController();
|
||||||
|
|
||||||
|
|
||||||
final imageLight = Image.asset('assets/images/crypto_lock_light.png');
|
final imageLight = Image.asset('assets/images/crypto_lock_light.png');
|
||||||
final imageDark = Image.asset('assets/images/crypto_lock.png');
|
final imageDark = Image.asset('assets/images/crypto_lock.png');
|
||||||
|
@ -29,20 +32,23 @@ class WalletSeedPage extends BasePage {
|
||||||
final bool isNewWalletCreated;
|
final bool isNewWalletCreated;
|
||||||
final WalletSeedViewModel walletSeedViewModel;
|
final WalletSeedViewModel walletSeedViewModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose(BuildContext context) async {
|
void onClose(BuildContext context) async {
|
||||||
|
|
||||||
if (isNewWalletCreated) {
|
if (isNewWalletCreated) {
|
||||||
final confirmed = await showPopUp<bool>(
|
final confirmed = await showPopUp<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertWithTwoActions(
|
return AlertWithTwoActions(
|
||||||
alertTitle: S.of(context).seed_alert_title,
|
alertTitle: S.of(context).seed_alert_title,
|
||||||
alertContent: S.of(context).seed_alert_content,
|
alertContent: S.of(context).seed_alert_content,
|
||||||
leftButtonText: S.of(context).seed_alert_back,
|
leftButtonText: S.of(context).seed_alert_back,
|
||||||
rightButtonText: S.of(context).seed_alert_yes,
|
rightButtonText: S.of(context).seed_alert_yes,
|
||||||
actionLeftButton: () => Navigator.of(context).pop(false),
|
actionLeftButton: () => Navigator.of(context).pop(false),
|
||||||
actionRightButton: () => Navigator.of(context).pop(true));
|
actionRightButton: () => Navigator.of(context).pop(true));
|
||||||
}) ??
|
}) ??
|
||||||
false;
|
false;
|
||||||
|
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
|
@ -62,31 +68,48 @@ class WalletSeedPage extends BasePage {
|
||||||
Widget trailing(BuildContext context) {
|
Widget trailing(BuildContext context) {
|
||||||
return isNewWalletCreated
|
return isNewWalletCreated
|
||||||
? GestureDetector(
|
? GestureDetector(
|
||||||
onTap: () => onClose(context),
|
onTap: () => onClose(context),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 100,
|
width: 100,
|
||||||
height: 32,
|
height: 32,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
margin: EdgeInsets.only(left: 10),
|
margin: EdgeInsets.only(left: 10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||||
color: Theme.of(context).cardColor),
|
color: Theme.of(context).cardColor),
|
||||||
child: Text(
|
child: Text(
|
||||||
S.of(context).seed_language_next,
|
S.of(context).seed_language_next,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14, fontWeight: FontWeight.w600, color: Theme.of(context)
|
fontSize: 14, fontWeight: FontWeight.w600, color: Theme.of(context)
|
||||||
.extension<CakeTextTheme>()!
|
.extension<CakeTextTheme>()!
|
||||||
.buttonTextColor),
|
.buttonTextColor),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Offstage();
|
: Offstage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final TextEditingController nameController;
|
||||||
|
final TextEditingController seedController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
|
|
||||||
final image = currentTheme.type == ThemeType.dark ? imageDark : imageLight;
|
final image = currentTheme.type == ThemeType.dark ? imageDark : imageLight;
|
||||||
|
|
||||||
|
TextFormField(
|
||||||
|
autofillHints: [AutofillHints.newUsername],
|
||||||
|
//initialValue: walletSeedViewModel.name,
|
||||||
|
controller: nameController,
|
||||||
|
);
|
||||||
|
TextFormField(
|
||||||
|
autofillHints: [AutofillHints.password],
|
||||||
|
//initialValue: walletSeedViewModel.seed,
|
||||||
|
controller: seedController
|
||||||
|
//walletSeedViewModel.seed,
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () async => false,
|
onWillPop: () async => false,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -105,8 +128,10 @@ class WalletSeedPage extends BasePage {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
TextFormField(
|
||||||
walletSeedViewModel.name,
|
//initialValue: walletSeedViewModel.name,
|
||||||
|
controller: nameController,
|
||||||
|
autofillHints: [AutofillHints.newUsername],
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
|
@ -114,8 +139,10 @@ class WalletSeedPage extends BasePage {
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: 20, left: 16, right: 16),
|
padding: EdgeInsets.only(top: 20, left: 16, right: 16),
|
||||||
child: Text(
|
child: TextFormField(
|
||||||
walletSeedViewModel.seed,
|
//initialValue: walletSeedViewModel.seed,
|
||||||
|
controller: seedController,
|
||||||
|
autofillHints: [AutofillHints.password],
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
|
@ -130,48 +157,64 @@ class WalletSeedPage extends BasePage {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
isNewWalletCreated
|
isNewWalletCreated
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: EdgeInsets.only(bottom: 43, left: 43, right: 43),
|
padding: EdgeInsets.only(bottom: 43, left: 43, right: 43),
|
||||||
child: Text(
|
child: Text(
|
||||||
S.of(context).seed_reminder,
|
S.of(context).seed_reminder,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
|
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Offstage(),
|
: Offstage(),
|
||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(right: 8.0),
|
padding: EdgeInsets.only(right: 8.0),
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
ShareUtil.share(
|
ShareUtil.share(
|
||||||
text: walletSeedViewModel.seed,
|
text: walletSeedViewModel.seed,
|
||||||
context: context,
|
context: context,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
text: S.of(context).save,
|
text: S.of(context).save,
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
textColor: Colors.white),
|
textColor: Colors.white),
|
||||||
)),
|
)),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(left: 8.0),
|
padding: EdgeInsets.only(left: 8.0),
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (context) => PrimaryButton(
|
builder: (context) => PrimaryButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
ClipboardUtil.setSensitiveDataToClipboard(
|
ClipboardUtil.setSensitiveDataToClipboard(
|
||||||
ClipboardData(text: walletSeedViewModel.seed));
|
ClipboardData(text: walletSeedViewModel.seed));
|
||||||
showBar<void>(context, S.of(context).copied_to_clipboard);
|
showBar<void>(context, S.of(context).copied_to_clipboard);
|
||||||
},
|
},
|
||||||
text: S.of(context).copy,
|
text: S.of(context).copy,
|
||||||
color: Theme.of(context).extension<PinCodeTheme>()!.indicatorsColor,
|
color: Theme.of(context).extension<PinCodeTheme>()!.indicatorsColor,
|
||||||
textColor: Colors.white)),
|
textColor: Colors.white)),
|
||||||
))
|
)),
|
||||||
|
Flexible(
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.only(left: 8.0),
|
||||||
|
child: Builder(
|
||||||
|
builder: (context) => PrimaryButton(
|
||||||
|
onPressed: () async {
|
||||||
|
|
||||||
|
nameController.text = walletSeedViewModel.name;
|
||||||
|
seedController.text = walletSeedViewModel.seed;
|
||||||
|
|
||||||
|
TextInput.finishAutofillContext();
|
||||||
|
},
|
||||||
|
text: "Save2",
|
||||||
|
color: Colors.blue,
|
||||||
|
textColor: Colors.white)),
|
||||||
|
))
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue