Company search
This commit is contained in:
parent
ce0568f3b7
commit
4c7e3a954f
|
|
@ -1,6 +1,11 @@
|
|||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/company/company_state.dart';
|
||||
import 'package:memoize/memoize.dart';
|
||||
|
||||
var memoizedFilteredSelector = memo2((String filter,
|
||||
CompanyState state) =>
|
||||
filteredSelector(filter, state));
|
||||
|
||||
List<BaseEntity> filteredSelector(String filter, CompanyState state) {
|
||||
final List<BaseEntity> list = []
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
|||
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:invoiceninja_flutter/utils/icons.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
||||
class ActivityListTile extends StatelessWidget {
|
||||
|
|
@ -16,29 +17,6 @@ class ActivityListTile extends StatelessWidget {
|
|||
|
||||
final ActivityEntity activity;
|
||||
|
||||
IconData getIconData(EntityType entityType) {
|
||||
switch (entityType) {
|
||||
case EntityType.client:
|
||||
return FontAwesomeIcons.users;
|
||||
case EntityType.invoice:
|
||||
return FontAwesomeIcons.filePdfO;
|
||||
case EntityType.payment:
|
||||
return FontAwesomeIcons.creditCard;
|
||||
case EntityType.credit:
|
||||
return FontAwesomeIcons.creditCard;
|
||||
case EntityType.quote:
|
||||
return FontAwesomeIcons.fileAltO;
|
||||
case EntityType.vendor:
|
||||
return FontAwesomeIcons.building;
|
||||
case EntityType.expense:
|
||||
return FontAwesomeIcons.fileImageO;
|
||||
case EntityType.task:
|
||||
return FontAwesomeIcons.clockO;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
|
|
|
|||
|
|
@ -4,12 +4,16 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/product/product_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/app_drawer_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_filter.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/list_filter_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/dashboard/dashboard_activity.dart';
|
||||
import 'package:invoiceninja_flutter/ui/dashboard/dashboard_panels.dart';
|
||||
import 'package:invoiceninja_flutter/ui/dashboard/dashboard_vm.dart';
|
||||
import 'package:invoiceninja_flutter/utils/icons.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
||||
class DashboardView extends StatefulWidget {
|
||||
|
|
@ -81,7 +85,6 @@ class _DashboardViewState extends State<DashboardView>
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class CustomTabBarView extends StatelessWidget {
|
||||
const CustomTabBarView({
|
||||
@required this.viewModel,
|
||||
|
|
@ -99,26 +102,29 @@ class CustomTabBarView extends StatelessWidget {
|
|||
itemBuilder: (BuildContext context, index) {
|
||||
final entity = viewModel.filteredList[index];
|
||||
final subtitle = entity.matchesFilterValue(viewModel.filter);
|
||||
IconData icon;
|
||||
switch (entity.entityType) {
|
||||
case EntityType.client:
|
||||
icon = FontAwesomeIcons.users;
|
||||
break;
|
||||
case EntityType.product:
|
||||
icon = FontAwesomeIcons.cube;
|
||||
break;
|
||||
case EntityType.invoice:
|
||||
icon = FontAwesomeIcons.filePdfO;
|
||||
break;
|
||||
}
|
||||
return ListTile(
|
||||
title: Text(entity.listDisplayName),
|
||||
leading: Icon(icon),
|
||||
leading: Icon(getIconData(entity.entityType)),
|
||||
trailing: Icon(Icons.navigate_next),
|
||||
subtitle: subtitle != null ? Text(subtitle) : Container(),
|
||||
);
|
||||
onTap: () {
|
||||
dynamic action;
|
||||
switch (entity.entityType) {
|
||||
case EntityType.product:
|
||||
action = EditProduct(product: entity, context: context);
|
||||
break;
|
||||
case EntityType.client:
|
||||
action = ViewClient(clientId: entity.id, context: context);
|
||||
break;
|
||||
case EntityType.invoice:
|
||||
action =
|
||||
ViewInvoice(invoiceId: entity.id, context: context);
|
||||
break;
|
||||
}
|
||||
StoreProvider.of<AppState>(context).dispatch(action);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return TabBarView(
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class DashboardVM {
|
|||
isLoading: state.isLoading,
|
||||
onRefreshed: (context) => _handleRefresh(context),
|
||||
filter: filter,
|
||||
filteredList: filteredSelector(filter, state.selectedCompanyState),
|
||||
filteredList: memoizedFilteredSelector(filter, state.selectedCompanyState),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
|
||||
IconData getIconData(EntityType entityType) {
|
||||
switch (entityType) {
|
||||
case EntityType.client:
|
||||
return FontAwesomeIcons.users;
|
||||
case EntityType.invoice:
|
||||
return FontAwesomeIcons.filePdfO;
|
||||
case EntityType.payment:
|
||||
return FontAwesomeIcons.creditCard;
|
||||
case EntityType.credit:
|
||||
return FontAwesomeIcons.creditCard;
|
||||
case EntityType.quote:
|
||||
return FontAwesomeIcons.fileAltO;
|
||||
case EntityType.vendor:
|
||||
return FontAwesomeIcons.building;
|
||||
case EntityType.expense:
|
||||
return FontAwesomeIcons.fileImageO;
|
||||
case EntityType.task:
|
||||
return FontAwesomeIcons.clockO;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue