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

View file

@ -40,6 +40,7 @@ import 'package:cake_wallet/src/screens/setup_pin_code/setup_pin_code.dart';
import 'package:cake_wallet/src/screens/support/support_page.dart';
import 'package:cake_wallet/src/screens/trade_details/trade_details_page.dart';
import 'package:cake_wallet/src/screens/transaction_details/transaction_details_page.dart';
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_list_page.dart';
import 'package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart';
import 'package:cake_wallet/src/screens/exchange/exchange_page.dart';
import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart';
@ -76,6 +77,7 @@ import 'package:cake_wallet/view_model/setup_pin_code_view_model.dart';
import 'package:cake_wallet/view_model/support_view_model.dart';
import 'package:cake_wallet/view_model/transaction_details_view_model.dart';
import 'package:cake_wallet/view_model/trade_details_view_model.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_list_view_model.dart';
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart';
import 'package:cake_wallet/view_model/auth_view_model.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
@ -561,5 +563,11 @@ Future setup(
getIt.registerFactory(() => SupportPage(getIt.get<SupportViewModel>()));
getIt.registerFactory(() => UnspentCoinsListViewModel());
getIt.registerFactory(() => UnspentCoinsListPage(
unspentCoinsListViewModel: getIt.get<UnspentCoinsListViewModel>()
));
_isSetupFinished = true;
}

View file

@ -9,6 +9,7 @@ import 'package:cake_wallet/src/screens/restore/restore_from_backup_page.dart';
import 'package:cake_wallet/src/screens/restore/wallet_restore_page.dart';
import 'package:cake_wallet/src/screens/seed/pre_seed_page.dart';
import 'package:cake_wallet/src/screens/support/support_page.dart';
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_list_page.dart';
import 'package:cake_wallet/src/screens/wyre/wyre_page.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
@ -355,6 +356,10 @@ Route<dynamic> createRoute(RouteSettings settings) {
return CupertinoPageRoute<void>(
builder: (_) => getIt.get<SupportPage>());
case Routes.unspentCoinsList:
return MaterialPageRoute<void>(
builder: (_) => getIt.get<UnspentCoinsListPage>());
default:
return MaterialPageRoute<void>(
builder: (_) => Scaffold(

View file

@ -54,4 +54,5 @@ class Routes {
static const support = '/support';
static const orderDetails = '/order_details';
static const wyre = '/wyre';
static const unspentCoinsList = '/unspent_coins_list';
}

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,
)
)
],
)),
));
}

View file

@ -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');},
)
);
});
}
}

View file

@ -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
)
)
],
)
);
}
}

View file

@ -0,0 +1,14 @@
class UnspentCoinsItem {
UnspentCoinsItem({
this.address,
this.amount,
this.isFrozen,
this.note,
this.isSending = true});
final String address;
final String amount;
final bool isFrozen;
final String note;
final bool isSending;
}

View file

@ -0,0 +1,47 @@
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart';
import 'package:mobx/mobx.dart';
part 'unspent_coins_list_view_model.g.dart';
const List<Map<String, dynamic>> unspentCoinsMap = [
<String, dynamic>{
"address" : "11111111111111121111132432432432432432432443124324324234324324324324332424",
"amount" : "222",
"isFrozen" : true,
"note" : "333cvgf23132132132132131321321314rwrtdggfdddewq ewqasfdxgdhgfgfszczcxgbhhhbcgbc"},
<String, dynamic>{
"address" : "444",
"amount" : "555",
"note" : "sfjskf"},
<String, dynamic>{
"address" : "777",
"amount" : "888",
"isFrozen" : false},
<String, dynamic>{
"address" : "11111111111111121111132432432432432432432443124324324234324324324324332424",
"amount" : "222",
"isFrozen" : true,
"note" : "333cvgf23132132132132131321321314rwrtdggfdddewq ewqasfdxgdhgfgfszczcxgbhhhbcgbc"},
<String, dynamic>{
"address" : "444",
"amount" : "555",
"note" : "sffsfsdsgs"},
<String, dynamic>{
"address" : "777",
"amount" : "888",
"isFrozen" : false},
<String, dynamic>{},
];
class UnspentCoinsListViewModel = UnspentCoinsListViewModelBase with _$UnspentCoinsListViewModel;
abstract class UnspentCoinsListViewModelBase with Store {
@computed
List<UnspentCoinsItem> get items => unspentCoinsMap.map((elem) =>
UnspentCoinsItem(
address: elem["address"] as String,
amount: elem["amount"] as String,
isFrozen: elem["isFrozen"] as bool,
note: elem["note"] as String
)).toList();
}

View file

@ -70,7 +70,7 @@ packages:
path: "."
ref: cake
resolved-ref: "02fef082f20af13de00b4e64efb93a2c1e5e1cf2"
url: "git@github.com:cake-tech/bech32.git"
url: "https://github.com/cake-tech/bech32.git"
source: git
version: "0.2.0"
bip32:
@ -92,8 +92,8 @@ packages:
description:
path: "."
ref: cake
resolved-ref: b3ab2926c665f0e68b74a4a5f31059f7fcd817b7
url: "git@github.com:cake-tech/bitcoin_flutter.git"
resolved-ref: cbabfd87b6ce3cae6051a3e86ddb56e7a934e188
url: "https://github.com/cake-tech/bitcoin_flutter.git"
source: git
version: "2.0.2"
boolean_selector: