Settings
This commit is contained in:
parent
5393c73e20
commit
e5fb6c714f
|
|
@ -162,7 +162,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
BuiltMap<String, SelectableEntity> getEntityMap(EntityType type) {
|
||||
switch (type) {
|
||||
case EntityType.product:
|
||||
return projectState.map;
|
||||
return productState.map;
|
||||
case EntityType.client:
|
||||
return clientState.map;
|
||||
case EntityType.invoice:
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import 'package:invoiceninja_flutter/redux/company/company_state.dart';
|
|||
import 'package:invoiceninja_flutter/redux/dashboard/dashboard_reducer.dart';
|
||||
import 'package:invoiceninja_flutter/redux/group/group_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/product/product_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/ui_state.dart';
|
||||
|
|
@ -85,6 +86,9 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
|
|||
TypedReducer<BuiltList<HistoryRecord>, ViewClient>((historyList, action) =>
|
||||
_addToHistory(historyList,
|
||||
HistoryRecord(id: action.clientId, entityType: EntityType.client))),
|
||||
TypedReducer<BuiltList<HistoryRecord>, ViewProduct>((historyList, action) =>
|
||||
_addToHistory(historyList,
|
||||
HistoryRecord(id: action.productId, entityType: EntityType.product))),
|
||||
TypedReducer<BuiltList<HistoryRecord>, ViewInvoice>((historyList, action) =>
|
||||
_addToHistory(historyList,
|
||||
HistoryRecord(id: action.invoiceId, entityType: EntityType.invoice))),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
|
|
@ -21,8 +19,26 @@ class HistoryDrawer extends StatelessWidget {
|
|||
final localization = AppLocalization.of(context);
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final history = state.uiState.historyList
|
||||
.sublist(0, min(state.uiState.historyList.length, 50));
|
||||
|
||||
final widgets = <Widget>[];
|
||||
for (var history in state.uiState.historyList) {
|
||||
if (widgets.length > 50) {
|
||||
break;
|
||||
}
|
||||
|
||||
final entity = state.getEntityMap(history.entityType)[history.id];
|
||||
|
||||
if (entity == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
widgets.add(ListTile(
|
||||
key: ValueKey('__${history.id}_${history.entityType}__'),
|
||||
leading: Icon(getEntityIcon(history.entityType)),
|
||||
title: Text(entity.listDisplayName),
|
||||
subtitle: Text(localization.lookup('${history.entityType}')),
|
||||
));
|
||||
}
|
||||
|
||||
return Drawer(
|
||||
child: Scaffold(
|
||||
|
|
@ -42,14 +58,7 @@ class HistoryDrawer extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
body: ListView(
|
||||
children: history.map((history) {
|
||||
final entity = state.getEntityMap(history.entityType)[history.id];
|
||||
return ListTile(
|
||||
leading: Icon(getEntityIcon(history.entityType)),
|
||||
title: Text(entity.listDisplayName),
|
||||
subtitle: Text(localization.lookup('${history.entityType}')),
|
||||
);
|
||||
}).toList(),
|
||||
children: widgets,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue