dev
dart 82 lines 2.84 KB
Raw
1 import 'package:cake_wallet/generated/i18n.dart';
2 import 'package:cake_wallet/new-ui/widgets/send_page/floating_icon_button.dart';
3 import 'package:flutter/material.dart';
4 import 'package:flutter/services.dart';
5
6 class NewSendMemoInput extends StatelessWidget {
7 const NewSendMemoInput(
8 {super.key,
9 required this.memoController,
10 required this.maxMemoLength,
11 required this.memoLength,
12 this.hintText,
13 this.disclaimerText});
14
15 final TextEditingController memoController;
16 final int maxMemoLength;
17 final int memoLength;
18 final String? hintText;
19 final String? disclaimerText;
20
21 @override
22 Widget build(BuildContext context) {
23 return Column(
24 spacing: 8,
25 children: [
26 Container(
27 decoration: BoxDecoration(
28 borderRadius: BorderRadius.circular(12),
29 color: Theme.of(context).colorScheme.surfaceContainer,
30 ),
31 child: Row(
32 children: [
33 Expanded(
34 child: MergeSemantics(
35 child: Semantics(
36 label: hintText ?? S.of(context).memo_optional,
37 child: TextField(
38 maxLength: maxMemoLength,
39 controller: memoController,
40 decoration: InputDecoration(
41 hintText: hintText ?? S.of(context).memo_optional, counterText: ""),
42 ),
43 ),
44 ),
45 ),
46 SizedBox(width: 12),
47 FloatingIconButton(
48 iconPath: "assets/new-ui/paste.svg",
49 semanticLabel: S.of(context).paste,
50 onPressed: () async {
51 final data = await Clipboard.getData(Clipboard.kTextPlain);
52 if (data != null && data.text != null) {
53 memoController.text = data.text!;
54 }
55 }),
56 SizedBox(width: 12)
57 ],
58 ),
59 ),
60 Padding(
61 padding: const EdgeInsets.symmetric(horizontal: 4.0),
62 child: Row(
63 mainAxisAlignment: MainAxisAlignment.spaceBetween,
64 children: [
65 Expanded(
66 child: Text(disclaimerText ?? S.of(context).memo_disclaimer,
67 style: TextStyle(
68 fontSize: 12, color: Theme.of(context).colorScheme.onSurfaceVariant)),
69 ),
70 // The field itself already reports the character count through
71 // maxValueLength/currentValueLength, so this visual counter stays silent.
72 ExcludeSemantics(
73 child: Text("${memoController.text.length} / ${maxMemoLength}",
74 style: TextStyle(fontSize: 12, color: Theme.of(context).colorScheme.primary)),
75 )
76 ],
77 ),
78 )
79 ],
80 );
81 }
82 }