cake_wallet/lib/src/widgets/seed_widget.dart

105 lines
3.6 KiB
Dart
Raw Normal View History

2020-10-09 18:34:21 +00:00
import 'package:cake_wallet/entities/wallet_type.dart';
2020-10-13 21:11:04 +00:00
import 'package:cake_wallet/src/widgets/annotated_editable_text.dart';
2020-10-09 18:34:21 +00:00
import 'package:cake_wallet/src/widgets/blockchain_height_widget.dart';
2020-01-04 19:31:52 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:cake_wallet/palette.dart';
2020-06-20 07:10:00 +00:00
import 'package:cake_wallet/core/seed_validator.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
2020-09-21 11:50:26 +00:00
import 'package:cake_wallet/entities/mnemonic_item.dart';
2020-01-04 19:31:52 +00:00
import 'package:cake_wallet/generated/i18n.dart';
import 'package:flutter/widgets.dart';
2020-01-04 19:31:52 +00:00
class SeedWidget extends StatefulWidget {
2020-10-13 21:11:04 +00:00
SeedWidget({Key key}) : super(key: key);
2020-01-08 12:26:34 +00:00
@override
2020-10-13 21:11:04 +00:00
SeedWidgetState createState() => SeedWidgetState();
2020-01-04 19:31:52 +00:00
}
class SeedWidgetState extends State<SeedWidget> {
2020-10-13 21:11:04 +00:00
SeedWidgetState()
: controller = TextEditingController(),
focusNode = FocusNode(),
words =
SeedValidator.getWordList(type: WalletType.monero, language: 'en');
2020-10-13 21:11:04 +00:00
final TextEditingController controller;
final FocusNode focusNode;
final List<String> words;
bool _showPlaceholder;
2020-01-04 19:31:52 +00:00
2020-10-13 21:11:04 +00:00
String get text => controller.text;
2020-01-04 19:31:52 +00:00
@override
void initState() {
super.initState();
2020-10-13 21:11:04 +00:00
_showPlaceholder = true;
2020-01-04 19:31:52 +00:00
}
2020-10-09 18:34:21 +00:00
Future<void> _pasteAddress() async {
final value = await Clipboard.getData('text/plain');
if (value?.text?.isNotEmpty ?? false) {
controller.text = value.text;
}
}
2020-01-04 19:31:52 +00:00
@override
Widget build(BuildContext context) {
return Container(
2020-10-09 18:34:21 +00:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Stack(children: [
SizedBox(height: 35),
2020-10-13 21:11:04 +00:00
if (_showPlaceholder)
2020-10-09 18:34:21 +00:00
Positioned(
top: 10,
left: 0,
child: Text('Enter your seed',
2020-06-20 07:10:00 +00:00
style: TextStyle(
2020-10-09 18:34:21 +00:00
fontSize: 16.0, color: Theme.of(context).hintColor))),
Padding(
padding: EdgeInsets.only(right: 40, top: 10),
child: AnnotatedEditableText(
cursorColor: Colors.green,
backgroundCursorColor: Colors.blue,
style: TextStyle(
fontSize: 20,
color: Colors.red,
fontWeight: FontWeight.normal,
backgroundColor: Colors.transparent),
focusNode: focusNode,
controller: controller,
words: words)),
Positioned(
top: 0,
right: 0,
child: Container(
width: 34,
height: 34,
child: InkWell(
onTap: () async => _pasteAddress(),
child: Container(
2020-10-13 21:11:04 +00:00
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)
2020-06-20 07:10:00 +00:00
),
2020-10-09 18:34:21 +00:00
)))
]),
Container(
margin: EdgeInsets.only(top: 15),
height: 1.0,
color: Theme.of(context).primaryTextTheme.title.backgroundColor),
]));
2020-01-04 19:31:52 +00:00
}
}