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(
() => ContactListViewModel(_contactSource, _walletInfoSource));
getIt.registerFactoryParam<ContactListPage, bool, CryptoCurrency?>((bool isEditable, CryptoCurrency? cur)
getIt.registerFactoryParam<ContactListPage, CryptoCurrency?, void>((CryptoCurrency? cur, _)
=> ContactListPage(
getIt.get<ContactListViewModel>(),
isEditable: isEditable,
selectedCurrency: cur));
getIt.registerFactoryParam<ContactPage, ContactRecord?, void>(

View file

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

View file

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

View file

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