CAKE-329 | show unspent coins alert when unspent coins list page is started

OleksandrSobol committed Jun 2, 2021 at 17:36 UTC 61375468a5ff43f964de4d77650faa92b7030143
1 file changed +63 -29
lib/src/screens/unspent_coins/unspent_coins_list_page.dart
+63 -29
@@ -28,15 +28,7 @@ class UnspentCoinsListPage extends BasePage {
28 highlightColor: Colors.transparent,
29 splashColor: Colors.transparent,
30 padding: EdgeInsets.all(0),
31 - onPressed: () => showPopUp<void>(
32 - context: context,
33 - builder: (BuildContext context) {
34 - return AlertWithOneAction(
35 - alertTitle: '',
36 - alertContent: 'Information about unspent coins',
37 - buttonText: S.of(context).ok,
38 - buttonAction: () => Navigator.of(context).pop());
39 - }),
31 + onPressed: () => showUnspentCoinsAlert(context),
32 child: questionImage),
33 ),
34 );
@@ -45,28 +37,70 @@ class UnspentCoinsListPage extends BasePage {
37 final UnspentCoinsListViewModel unspentCoinsListViewModel;
38
39 @override
48 - Widget body(BuildContext context) {
40 + Widget body(BuildContext context) =>
41 + UnspentCoinsListForm(unspentCoinsListViewModel);
42 +}
43 +
44 +class UnspentCoinsListForm extends StatefulWidget {
45 + UnspentCoinsListForm(this.unspentCoinsListViewModel);
46 +
47 + final UnspentCoinsListViewModel unspentCoinsListViewModel;
48 +
49 + @override
50 + UnspentCoinsListFormState createState() =>
51 + UnspentCoinsListFormState(unspentCoinsListViewModel);
52 +}
53 +
54 +class UnspentCoinsListFormState extends State<UnspentCoinsListForm> {
55 + UnspentCoinsListFormState(this.unspentCoinsListViewModel);
56 +
57 + final UnspentCoinsListViewModel unspentCoinsListViewModel;
58 +
59 + @override
60 + void initState() {
61 + super.initState();
62 + WidgetsBinding.instance.addPostFrameCallback(afterLayout);
63 + }
64 +
65 + void afterLayout(dynamic _) {
66 + showUnspentCoinsAlert(context);
67 + }
68 +
69 + @override
70 + Widget build(BuildContext context) {
71 return Container(
50 - padding: EdgeInsets.fromLTRB(24, 12, 24, 24),
51 - child: Observer(
52 - builder: (_) => ListView.separated(
53 - itemCount: unspentCoinsListViewModel.items.length,
54 - separatorBuilder: (_, __) =>
55 - SizedBox(height: 15),
56 - itemBuilder: (_, int index) {
57 - final item = unspentCoinsListViewModel.items[index];
58 -
59 - return GestureDetector(
60 - onTap: () {print('Item taped');},
61 - child: UnspentCoinsListItem(
62 - address: item.address,
63 - amount: item.amount,
64 - isSending: item.isSending,
65 - onCheckBoxTap: (value) {},
66 - ));
67 - }
72 + padding: EdgeInsets.fromLTRB(24, 12, 24, 24),
73 + child: Observer(
74 + builder: (_) => ListView.separated(
75 + itemCount: unspentCoinsListViewModel.items.length,
76 + separatorBuilder: (_, __) =>
77 + SizedBox(height: 15),
78 + itemBuilder: (_, int index) {
79 + final item = unspentCoinsListViewModel.items[index];
80 +
81 + return GestureDetector(
82 + onTap: () {print('Item taped');},
83 + child: UnspentCoinsListItem(
84 + address: item.address,
85 + amount: item.amount,
86 + isSending: item.isSending,
87 + onCheckBoxTap: (value) {},
88 + ));
89 + }
90 + )
91 )
69 - )
92 );
93 }
94 +}
95 +
96 +void showUnspentCoinsAlert(BuildContext context) {
97 + showPopUp<void>(
98 + context: context,
99 + builder: (BuildContext context) {
100 + return AlertWithOneAction(
101 + alertTitle: '',
102 + alertContent: 'Information about unspent coins',
103 + buttonText: S.of(context).ok,
104 + buttonAction: () => Navigator.of(context).pop());
105 + });
106 }
\ No newline at end of file