remove isEditable parameter

This commit is contained in:
Serhii 2022-12-02 23:36:22 +02:00
parent a5cfc7fa61
commit 5f1e8e9d33
4 changed files with 13 additions and 16 deletions

View file

@ -462,10 +462,9 @@ Future setup(
getIt.registerFactory( getIt.registerFactory(
() => ContactListViewModel(_contactSource, _walletInfoSource)); () => ContactListViewModel(_contactSource, _walletInfoSource));
getIt.registerFactoryParam<ContactListPage, bool, CryptoCurrency?>((bool isEditable, CryptoCurrency? cur) getIt.registerFactoryParam<ContactListPage, CryptoCurrency?, void>((CryptoCurrency? cur, _)
=> ContactListPage( => ContactListPage(
getIt.get<ContactListViewModel>(), getIt.get<ContactListViewModel>(),
isEditable: isEditable,
selectedCurrency: cur)); selectedCurrency: cur));
getIt.registerFactoryParam<ContactPage, ContactRecord?, void>( getIt.registerFactoryParam<ContactPage, ContactRecord?, void>(

View file

@ -300,13 +300,12 @@ Route<dynamic> createRoute(RouteSettings settings) {
case Routes.addressBook: case Routes.addressBook:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (_) => builder: (_) =>
getIt.get<ContactListPage>(param1: true)); getIt.get<ContactListPage>());
case Routes.pickerAddressBook: case Routes.pickerAddressBook:
final selectedCurrency = settings.arguments as CryptoCurrency; final selectedCurrency = settings.arguments as CryptoCurrency;
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (_) => getIt.get<ContactListPage>(param1: false, builder: (_) => getIt.get<ContactListPage>(param1: selectedCurrency));
param2: selectedCurrency));
case Routes.addressBookAddContact: case Routes.addressBookAddContact:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(

View file

@ -17,10 +17,9 @@ import 'package:cake_wallet/src/widgets/collapsible_standart_list.dart';
class ContactListPage extends BasePage { class ContactListPage extends BasePage {
ContactListPage(this.contactListViewModel, ContactListPage(this.contactListViewModel,
{this.isEditable = true, required this.selectedCurrency}); {this.selectedCurrency});
final ContactListViewModel contactListViewModel; final ContactListViewModel contactListViewModel;
final bool isEditable;
final CryptoCurrency? selectedCurrency; final CryptoCurrency? selectedCurrency;
@override @override
@ -28,7 +27,7 @@ class ContactListPage extends BasePage {
@override @override
Widget? trailing(BuildContext context) { Widget? trailing(BuildContext context) {
if (!isEditable) { if (selectedCurrency != null) {
return null; return null;
} }
@ -68,9 +67,9 @@ class ContactListPage extends BasePage {
child: Observer( child: Observer(
builder: (_) { builder: (_) {
final contacts = final contacts =
contactListViewModel.getContacts(isEditable, selectedCurrency); contactListViewModel.getContacts(selectedCurrency);
final walletContacts = final walletContacts =
contactListViewModel.getWallets(isEditable, selectedCurrency); contactListViewModel.getWallets(selectedCurrency);
return CollapsibleSectionList( return CollapsibleSectionList(
context: context, context: context,
sectionCount: 2, sectionCount: 2,
@ -99,7 +98,7 @@ class ContactListPage extends BasePage {
final contact = contacts[index]; final contact = contacts[index];
final content = generateRaw(context, contact); final content = generateRaw(context, contact);
return !isEditable return selectedCurrency != null
? content ? content
: Slidable( : Slidable(
key: Key('${contact.key}'), key: Key('${contact.key}'),
@ -116,7 +115,7 @@ class ContactListPage extends BasePage {
return GestureDetector( return GestureDetector(
onTap: () async { onTap: () async {
if (!isEditable) { if (selectedCurrency != null) {
Navigator.of(context).pop(contact); Navigator.of(context).pop(contact);
return; return;
} }

View file

@ -46,16 +46,16 @@ abstract class ContactListViewModelBase with Store {
Future<void> delete(ContactRecord contact) async => contact.original.delete(); Future<void> delete(ContactRecord contact) async => contact.original.delete();
List<ContactRecord> getContacts(bool isEditable, CryptoCurrency? cur) { List<ContactRecord> getContacts(CryptoCurrency? cur) {
if (!isEditable) { if (cur != null) {
return contacts.where((element) => element.type == cur).toList(); return contacts.where((element) => element.type == cur).toList();
} }
return contacts; return contacts;
} }
List<WalletContact> getWallets(bool isEditable, CryptoCurrency? cur) { List<WalletContact> getWallets(CryptoCurrency? cur) {
if (!isEditable) { if (cur != null) {
return walletContacts.where((element) => element.type == cur).toList(); return walletContacts.where((element) => element.type == cur).toList();
} }