CAKE-158 | removed isFirstAddress from wallet_address_list_view_model.dart; rename isFirstAddress property of AddressCell on isPrimary; defined primary address cell in the receive_page.dart

This commit is contained in:
OleksandrSobol 2020-12-03 22:06:16 +02:00
parent e10387a1b6
commit a5d5831d99
3 changed files with 84 additions and 83 deletions

View file

@ -95,7 +95,10 @@ class ReceivePage extends BasePage {
amountTextFieldFocusNode: _cryptoAmountFocus), amountTextFieldFocusNode: _cryptoAmountFocus),
), ),
Observer( Observer(
builder: (_) => ListView.separated( builder: (_) {
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),
@ -135,8 +138,9 @@ class ReceivePage extends BasePage {
} }
if (item is WalletAddressListItem) { if (item is WalletAddressListItem) {
final isFirst = addressListViewModel.isFirstAddress; final isPrimary = isPrimaryAddress;
addressListViewModel.isFirstAddress = false; isPrimaryAddress = false;
cell = Observer(builder: (_) { cell = Observer(builder: (_) {
final isCurrent = item.address == final isCurrent = item.address ==
addressListViewModel.address.address; addressListViewModel.address.address;
@ -155,7 +159,7 @@ class ReceivePage extends BasePage {
return AddressCell.fromItem(item, return AddressCell.fromItem(item,
isCurrent: isCurrent, isCurrent: isCurrent,
isFirstAddress: isFirst, isPrimary: isPrimary,
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
textColor: textColor, textColor: textColor,
onTap: (_) => addressListViewModel.setAddress(item), onTap: (_) => addressListViewModel.setAddress(item),
@ -173,7 +177,8 @@ class ReceivePage extends BasePage {
topRight: Radius.circular(30)), topRight: Radius.circular(30)),
child: cell, child: cell,
); );
})), });
}),
], ],
), ),
)); ));

View file

@ -6,7 +6,7 @@ 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 isFirstAddress, @required bool isPrimary,
@required Color backgroundColor, @required Color backgroundColor,
@required Color textColor, @required Color textColor,
Function(String) onTap, Function(String) onTap,
@ -15,7 +15,7 @@ class AddressCell extends StatelessWidget {
address: item.address, address: item.address,
name: item.name, name: item.name,
isCurrent: isCurrent, isCurrent: isCurrent,
isFirstAddress: isFirstAddress, isPrimary: isPrimary,
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
textColor: textColor, textColor: textColor,
onTap: onTap, onTap: onTap,
@ -25,7 +25,7 @@ class AddressCell extends StatelessWidget {
{@required this.address, {@required this.address,
@required this.name, @required this.name,
@required this.isCurrent, @required this.isCurrent,
@required this.isFirstAddress, @required this.isPrimary,
@required this.backgroundColor, @required this.backgroundColor,
@required this.textColor, @required this.textColor,
this.onTap, this.onTap,
@ -34,7 +34,7 @@ class AddressCell extends StatelessWidget {
final String address; final String address;
final String name; final String name;
final bool isCurrent; final bool isCurrent;
final bool isFirstAddress; final bool isPrimary;
final Color backgroundColor; final Color backgroundColor;
final Color textColor; final Color textColor;
final Function(String) onTap; final Function(String) onTap;
@ -60,7 +60,7 @@ class AddressCell extends StatelessWidget {
), ),
)); ));
return (isCurrent || isFirstAddress) return (isCurrent || isPrimary)
? cell ? cell
: Slidable( : Slidable(
key: Key(address), key: Key(address),

View file

@ -67,9 +67,6 @@ abstract class WalletAddressListViewModelBase with Store {
@observable @observable
String amount; String amount;
@observable
bool isFirstAddress;
@computed @computed
WalletType get type => _wallet.type; WalletType get type => _wallet.type;
@ -100,7 +97,6 @@ abstract class WalletAddressListViewModelBase with Store {
final addressList = ObservableList<ListItem>(); final addressList = ObservableList<ListItem>();
if (wallet is MoneroWallet) { if (wallet is MoneroWallet) {
isFirstAddress = true;
addressList.addAll(wallet.subaddressList.subaddresses.map((subaddress) => addressList.addAll(wallet.subaddressList.subaddresses.map((subaddress) =>
WalletAddressListItem( WalletAddressListItem(
id: subaddress.id, id: subaddress.id,