History fixes

This commit is contained in:
Hillel Coren 2020-02-21 09:18:44 +02:00
parent 32b32d5a68
commit a4fbf883ff
2 changed files with 21 additions and 18 deletions

View File

@ -111,7 +111,8 @@ class _HistoryListTileState extends State<HistoryListTile> {
final history = widget.history; final history = widget.history;
Widget text; Widget title;
Widget subtitle;
String clientId; String clientId;
BaseEntity entity; BaseEntity entity;
@ -120,7 +121,16 @@ class _HistoryListTileState extends State<HistoryListTile> {
EntityType.reports, EntityType.reports,
EntityType.settings, EntityType.settings,
].contains(history.entityType)) { ].contains(history.entityType)) {
text = Text(localization.lookup(history.entityType.toString())); title = Text(localization.lookup(history.entityType.toString()));
if (history.entityType == EntityType.reports) {
subtitle =
Text(localization.lookup(state.uiState.reportsUIState.report));
} else if (history.entityType == EntityType.settings) {
var section = state.uiState.settingsUIState.section;
section = section.replaceAll('_edit', '').replaceAll('_view', '');
subtitle =
Text(localization.lookup(section));
}
} else { } else {
entity = state.getEntityMap(history.entityType)[history.id] as BaseEntity; entity = state.getEntityMap(history.entityType)[history.id] as BaseEntity;
@ -146,10 +156,12 @@ class _HistoryListTileState extends State<HistoryListTile> {
break; break;
} }
text = Text(entity.listDisplayName.isEmpty title = Text(entity.listDisplayName.isEmpty
? formatNumber(entity.listDisplayAmount, context, ? formatNumber(entity.listDisplayAmount, context,
formatNumberType: entity.listDisplayAmountType) formatNumberType: entity.listDisplayAmountType)
: entity.listDisplayName); : entity.listDisplayName);
subtitle = Text(localization.lookup('${history.entityType}'));
} }
return Container( return Container(
@ -158,10 +170,8 @@ class _HistoryListTileState extends State<HistoryListTile> {
child: ListTile( child: ListTile(
key: ValueKey('__${history.id}_${history.entityType}__'), key: ValueKey('__${history.id}_${history.entityType}__'),
leading: Icon(getEntityIcon(history.entityType)), leading: Icon(getEntityIcon(history.entityType)),
title: text, title: title,
subtitle: history.id == null subtitle: subtitle,
? null
: Text(localization.lookup('${history.entityType}')),
// TODO this needs to be localized // TODO this needs to be localized
trailing: LiveText( trailing: LiveText(
() => timeago.format(history.dateTime, locale: 'en_short'), () => timeago.format(history.dateTime, locale: 'en_short'),

View File

@ -163,21 +163,14 @@ class MainScreen extends StatelessWidget {
onWillPop: () async { onWillPop: () async {
final state = store.state; final state = store.state;
final historyList = state.historyList; final historyList = state.historyList;
final notViewingEntity = state.uiState.isEditing ||
state.uiState.isInSettings ||
(historyList[0].entityType.toString() !=
state.uiState.mainRoute);
if (historyList.isEmpty || if (historyList.length <= 1) {
historyList.length == 1 && !notViewingEntity) { return true;
return false;
} }
final history = historyList[notViewingEntity ? 0 : 1]; final history = historyList[1];
if (!notViewingEntity) {
store.dispatch(PopLastHistory()); store.dispatch(PopLastHistory());
}
switch (history.entityType) { switch (history.entityType) {
case EntityType.dashboard: case EntityType.dashboard: