mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-23 15:48:47 +00:00
Some checks are pending
Cache Dependencies / test (push) Waiting to run
* feat: Integration tests setup and tests for Disclaimer, Welcome and Setup Pin Code pages * feat: Integration test flow from start to restoring a wallet successfully done * test: Dashboard view test and linking to flow * feat: Testing the Exchange flow section, selecting sending and receiving currencies * test: Successfully create an exchange section * feat: Implement flow up to sending section * test: Complete Exchange flow * fix dependency issue * test: Final cleanups * feat: Add CI to run automated integration tests withan android emulator * feat: Adjust Automated integration test CI to run on ubuntu 20.04-a * fix: Move integration test CI into PR test build CI * ci: Add automated test ci which is a streamlined replica of pr test build ci * ci: Re-add step to access branch name * ci: Add KVM * ci: Add filepath to trigger the test run from * ci: Add required key * ci: Add required key * ci: Add missing secret key * ci: Add missing secret key * ci: Add nano secrets to workflow * ci: Switch step to free space on runner * ci: Remove timeout from workflow * ci: Confirm impact that removing copy_monero_deps would have on entire workflow time * ci: Update CI and temporarily remove cache related to emulator * ci: Remove dynamic java version * ci: Temporarily switch CI * ci: Switch to 11.x jdk * ci: Temporarily switch CI * ci: Revert ubuntu version * ci: Add more api levels * ci: Add more target options * ci: Settled on stable emulator matrix options * ci: Add more target options * ci: Modify flow * ci: Streamline api levels to 28 and 29 * ci: One more trial * ci: Switch to flutter drive * ci: Reduce options * ci: Remove haven from test * ci: Check for solana in list * ci: Adjust amounts and currencies for exchange flow * ci: Set write response on failure to true * ci: Split ci to funds and non funds related tests * test: Test for Send flow scenario and minor restructuring for test folders and files * chore: cleanup * ci: Pause CI for now * ci: Pause CI for now * ci: Pause CI for now * Fix: Add keys back to currency amount textfield widget * fix: Switch variable name * fix: remove automation for now * test: Updating send page robot and also syncing branch with main --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
149 lines
5.1 KiB
Dart
149 lines
5.1 KiB
Dart
import 'package:cake_wallet/core/seed_validator.dart';
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
import 'package:cake_wallet/src/widgets/validable_annotated_editable_text.dart';
|
|
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
|
|
import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
class SeedWidget extends StatefulWidget {
|
|
SeedWidget({
|
|
required this.language,
|
|
required this.type,
|
|
this.onSeedChange,
|
|
this.pasteButtonKey,
|
|
this.seedTextFieldKey,
|
|
super.key,
|
|
});
|
|
final Key? seedTextFieldKey;
|
|
final Key? pasteButtonKey;
|
|
final String language;
|
|
final WalletType type;
|
|
final void Function(String)? onSeedChange;
|
|
|
|
@override
|
|
SeedWidgetState createState() => SeedWidgetState(language, type);
|
|
}
|
|
|
|
class SeedWidgetState extends State<SeedWidget> {
|
|
SeedWidgetState(String language, this.type)
|
|
: controller = TextEditingController(),
|
|
focusNode = FocusNode(),
|
|
words = SeedValidator.getWordList(type: type, language: language),
|
|
_showPlaceholder = false {
|
|
focusNode.addListener(() {
|
|
setState(() {
|
|
if (!focusNode.hasFocus && controller.text.isEmpty) {
|
|
_showPlaceholder = true;
|
|
}
|
|
|
|
if (focusNode.hasFocus) {
|
|
_showPlaceholder = false;
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
final TextEditingController controller;
|
|
final FocusNode focusNode;
|
|
final WalletType type;
|
|
List<String> words;
|
|
bool normalizeSeed = false;
|
|
bool _showPlaceholder;
|
|
|
|
String get text => controller.text;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_showPlaceholder = true;
|
|
controller.addListener(() => widget.onSeedChange?.call(text));
|
|
}
|
|
|
|
void changeSeedLanguage(String language) {
|
|
setState(() {
|
|
words = SeedValidator.getWordList(type: type, language: language);
|
|
normalizeSeed = SeedValidator.needsNormalization(language);
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Stack(children: [
|
|
SizedBox(height: 35),
|
|
if (_showPlaceholder)
|
|
Positioned(
|
|
top: 10,
|
|
left: 0,
|
|
child: Text(S.of(context).enter_seed_phrase,
|
|
style: TextStyle(fontSize: 16.0, color: Theme.of(context).hintColor))),
|
|
Padding(
|
|
padding: EdgeInsets.only(right: 40, top: 10),
|
|
child: ValidatableAnnotatedEditableText(
|
|
key: widget.seedTextFieldKey,
|
|
cursorColor: Colors.blue,
|
|
backgroundCursorColor: Colors.blue,
|
|
validStyle: TextStyle(
|
|
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
|
backgroundColor: Colors.transparent,
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16),
|
|
invalidStyle: TextStyle(
|
|
fontSize: 16,
|
|
color: Colors.red,
|
|
fontWeight: FontWeight.normal,
|
|
backgroundColor: Colors.transparent),
|
|
focusNode: focusNode,
|
|
controller: controller,
|
|
words: words,
|
|
normalizeSeed: normalizeSeed,
|
|
textStyle: TextStyle(
|
|
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
|
backgroundColor: Colors.transparent,
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 16),
|
|
)),
|
|
Positioned(
|
|
top: 0,
|
|
right: 8,
|
|
child: Container(
|
|
width: 32,
|
|
height: 32,
|
|
child: InkWell(
|
|
key: widget.pasteButtonKey,
|
|
onTap: () async => _pasteText(),
|
|
child: Container(
|
|
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)
|
|
.extension<SendPageTheme>()!
|
|
.textFieldButtonIconColor)),
|
|
)))
|
|
]),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 15),
|
|
height: 1.0,
|
|
color: Theme.of(context).extension<CakeTextTheme>()!.textfieldUnderlineColor),
|
|
]));
|
|
}
|
|
|
|
Future<void> _pasteText() async {
|
|
final value = await Clipboard.getData('text/plain');
|
|
|
|
if (value?.text?.isNotEmpty ?? false) {
|
|
setState(() {
|
|
_showPlaceholder = false;
|
|
controller.text = value!.text!;
|
|
});
|
|
}
|
|
}
|
|
}
|