mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-24 11:36:21 +00:00
CAKE-158 | added isPrimary property to WalletAddressListItem; removed defining primary address cell in the receive_page.dart
This commit is contained in:
parent
a5d5831d99
commit
b200c56c58
4 changed files with 94 additions and 90 deletions
|
@ -95,10 +95,7 @@ class ReceivePage extends BasePage {
|
||||||
amountTextFieldFocusNode: _cryptoAmountFocus),
|
amountTextFieldFocusNode: _cryptoAmountFocus),
|
||||||
),
|
),
|
||||||
Observer(
|
Observer(
|
||||||
builder: (_) {
|
builder: (_) => ListView.separated(
|
||||||
var isPrimaryAddress = true;
|
|
||||||
|
|
||||||
return ListView.separated(
|
|
||||||
padding: EdgeInsets.all(0),
|
padding: EdgeInsets.all(0),
|
||||||
separatorBuilder: (context, _) => Container(
|
separatorBuilder: (context, _) => Container(
|
||||||
height: 1, color: Theme.of(context).dividerColor),
|
height: 1, color: Theme.of(context).dividerColor),
|
||||||
|
@ -138,9 +135,6 @@ class ReceivePage extends BasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is WalletAddressListItem) {
|
if (item is WalletAddressListItem) {
|
||||||
final isPrimary = isPrimaryAddress;
|
|
||||||
isPrimaryAddress = false;
|
|
||||||
|
|
||||||
cell = Observer(builder: (_) {
|
cell = Observer(builder: (_) {
|
||||||
final isCurrent = item.address ==
|
final isCurrent = item.address ==
|
||||||
addressListViewModel.address.address;
|
addressListViewModel.address.address;
|
||||||
|
@ -159,7 +153,6 @@ class ReceivePage extends BasePage {
|
||||||
|
|
||||||
return AddressCell.fromItem(item,
|
return AddressCell.fromItem(item,
|
||||||
isCurrent: isCurrent,
|
isCurrent: isCurrent,
|
||||||
isPrimary: isPrimary,
|
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
textColor: textColor,
|
textColor: textColor,
|
||||||
onTap: (_) => addressListViewModel.setAddress(item),
|
onTap: (_) => addressListViewModel.setAddress(item),
|
||||||
|
@ -177,8 +170,7 @@ class ReceivePage extends BasePage {
|
||||||
topRight: Radius.circular(30)),
|
topRight: Radius.circular(30)),
|
||||||
child: cell,
|
child: cell,
|
||||||
);
|
);
|
||||||
});
|
})),
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
|
@ -6,7 +6,6 @@ import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_i
|
||||||
class AddressCell extends StatelessWidget {
|
class AddressCell extends StatelessWidget {
|
||||||
factory AddressCell.fromItem(WalletAddressListItem item,
|
factory AddressCell.fromItem(WalletAddressListItem item,
|
||||||
{@required bool isCurrent,
|
{@required bool isCurrent,
|
||||||
@required bool isPrimary,
|
|
||||||
@required Color backgroundColor,
|
@required Color backgroundColor,
|
||||||
@required Color textColor,
|
@required Color textColor,
|
||||||
Function(String) onTap,
|
Function(String) onTap,
|
||||||
|
@ -15,7 +14,7 @@ class AddressCell extends StatelessWidget {
|
||||||
address: item.address,
|
address: item.address,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
isCurrent: isCurrent,
|
isCurrent: isCurrent,
|
||||||
isPrimary: isPrimary,
|
isPrimary: item.isPrimary,
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
textColor: textColor,
|
textColor: textColor,
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
|
|
|
@ -2,10 +2,11 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:cake_wallet/utils/list_item.dart';
|
import 'package:cake_wallet/utils/list_item.dart';
|
||||||
|
|
||||||
class WalletAddressListItem extends ListItem {
|
class WalletAddressListItem extends ListItem {
|
||||||
const WalletAddressListItem({@required this.address, this.name, this.id})
|
const WalletAddressListItem({@required this.address, @required this.isPrimary,
|
||||||
: super();
|
this.name, this.id}) : super();
|
||||||
|
|
||||||
final int id;
|
final int id;
|
||||||
|
final bool isPrimary;
|
||||||
final String address;
|
final String address;
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
|
|
|
@ -97,16 +97,28 @@ abstract class WalletAddressListViewModelBase with Store {
|
||||||
final addressList = ObservableList<ListItem>();
|
final addressList = ObservableList<ListItem>();
|
||||||
|
|
||||||
if (wallet is MoneroWallet) {
|
if (wallet is MoneroWallet) {
|
||||||
addressList.addAll(wallet.subaddressList.subaddresses.map((subaddress) =>
|
final primaryAddress = wallet.subaddressList.subaddresses.first;
|
||||||
WalletAddressListItem(
|
addressList.addAll(wallet.subaddressList.subaddresses.map((subaddress) {
|
||||||
|
final isPrimary = subaddress == primaryAddress;
|
||||||
|
|
||||||
|
return WalletAddressListItem(
|
||||||
id: subaddress.id,
|
id: subaddress.id,
|
||||||
|
isPrimary: isPrimary,
|
||||||
name: subaddress.label,
|
name: subaddress.label,
|
||||||
address: subaddress.address)));
|
address: subaddress.address);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wallet is BitcoinWallet) {
|
if (wallet is BitcoinWallet) {
|
||||||
final bitcoinAddresses = wallet.addresses.map((addr) =>
|
final primaryAddress = wallet.addresses.first;
|
||||||
WalletAddressListItem(name: addr.label, address: addr.address));
|
final bitcoinAddresses = wallet.addresses.map((addr) {
|
||||||
|
final isPrimary = addr == primaryAddress;
|
||||||
|
|
||||||
|
return WalletAddressListItem(
|
||||||
|
isPrimary: isPrimary,
|
||||||
|
name: addr.label,
|
||||||
|
address: addr.address);
|
||||||
|
});
|
||||||
addressList.addAll(bitcoinAddresses);
|
addressList.addAll(bitcoinAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue