CAKE-329 | added unspent coins list page to the app

This commit is contained in:
OleksandrSobol
2021-05-25 20:32:36 +03:00
parent 5d780d5590
commit aca8e8a292
9 changed files with 220 additions and 17 deletions
+27 -14
View File
@@ -558,22 +558,35 @@ class SendPage extends BasePage {
),
bottomSectionPadding:
EdgeInsets.only(left: 24, right: 24, bottom: 24),
bottomSection: Observer(builder: (_) {
return LoadingPrimaryButton(
onPressed: () async {
if (_formKey.currentState.validate()) {
await sendViewModel.createTransaction();
}
},
text: S.of(context).send,
color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white,
isLoading: sendViewModel.state is IsExecutingState ||
sendViewModel.state is TransactionCommitting,
isDisabled:
bottomSection: Column(
children: [
Observer(builder: (_) {
return LoadingPrimaryButton(
onPressed: () async {
if (_formKey.currentState.validate()) {
await sendViewModel.createTransaction();
}
},
text: S.of(context).send,
color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white,
isLoading: sendViewModel.state is IsExecutingState ||
sendViewModel.state is TransactionCommitting,
isDisabled:
false // FIXME !(syncStore.status is SyncedSyncStatus),
);
})),
}),
Padding(
padding: EdgeInsets.only(top: 12),
child: PrimaryButton(
onPressed: () => Navigator.of(context).pushNamed(Routes.unspentCoinsList),
text: 'Unspent coins',
color: Colors.green,
textColor: Colors.white,
)
)
],
)),
));
}
@@ -0,0 +1,38 @@
import 'package:cake_wallet/src/screens/unspent_coins/widgets/unspent_coins_list_item.dart';
import 'package:cake_wallet/src/widgets/standard_list.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_list_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
class UnspentCoinsListPage extends BasePage {
UnspentCoinsListPage({this.unspentCoinsListViewModel});
@override
String get title => 'Unspent coins';
final UnspentCoinsListViewModel unspentCoinsListViewModel;
@override
Widget body(BuildContext context) {
return SectionStandardList(
sectionCount: 1,
itemCounter: (int _) => unspentCoinsListViewModel.items.length,
itemBuilder: (_, __, index) {
final item = unspentCoinsListViewModel.items[index];
return GestureDetector(
onTap: () {print('Item taped');},
child: UnspentCoinsListItem(
address: item.address,
amount: item.amount,
isFrozen: item.isFrozen,
note: item.note,
isSending: item.isSending,
onCheckBoxTap: (value) {print('CheckBox taped');},
)
);
});
}
}
@@ -0,0 +1,77 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:cake_wallet/src/widgets/standard_checkbox.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
class UnspentCoinsListItem extends StatelessWidget {
UnspentCoinsListItem({
@required this.address,
@required this.amount,
@required this.isFrozen,
@required this.note,
@required this.isSending,
@required this.onCheckBoxTap,
});
final String address;
final String amount;
final bool isFrozen;
final String note;
final bool isSending;
final Function(bool) onCheckBoxTap;
@override
Widget build(BuildContext context) {
final textStyle = TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.primaryTextTheme
.title
.color);
return Container(
padding: EdgeInsets.fromLTRB(24, 16, 24, 16),
color: Theme.of(context).backgroundColor,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
address ?? 'Address',
style: textStyle,
),
Padding(
padding: EdgeInsets.only(top: 12),
child: Text(
amount ?? 'Amount',
style: textStyle,
)
),
if (isFrozen ?? false) Padding(
padding: EdgeInsets.only(top: 12),
child: Text(
'Freeze',
style: textStyle,
)
),
if (note?.isNotEmpty ?? false) Padding(
padding: EdgeInsets.only(top: 12),
child: AutoSizeText(
note,
style: textStyle,
maxLines: 1
)
),
Padding(
padding: EdgeInsets.only(top: 12),
child: StandardCheckbox(
value: isSending,
caption: 'Sending',
onChanged: onCheckBoxTap
)
)
],
)
);
}
}