Fix for back button

This commit is contained in:
Hillel Coren 2023-06-06 17:36:22 +03:00
parent 530091c37b
commit f3dbf0be58
23 changed files with 182 additions and 60 deletions

View File

@ -97,6 +97,12 @@ class SwitchListTableLayout implements PersistUI, PersistPrefs {}
class PopLastHistory implements PersistUI {} class PopLastHistory implements PersistUI {}
class UpdateLastHistory implements PersistUI {
const UpdateLastHistory(this.page);
final int page;
}
class DismissNativeWarning implements PersistUI {} class DismissNativeWarning implements PersistUI {}
class DismissNativeWarningPermanently implements PersistUI, PersistPrefs {} class DismissNativeWarningPermanently implements PersistUI, PersistPrefs {}
@ -329,6 +335,7 @@ void filterByEntity({
void viewEntitiesByType({ void viewEntitiesByType({
@required EntityType entityType, @required EntityType entityType,
BaseEntity filterEntity, BaseEntity filterEntity,
int page = 0,
}) { }) {
final store = StoreProvider.of<AppState>(navigatorKey.currentContext); final store = StoreProvider.of<AppState>(navigatorKey.currentContext);
final uiState = store.state.uiState; final uiState = store.state.uiState;
@ -371,13 +378,13 @@ void viewEntitiesByType({
); );
break; break;
case EntityType.client: case EntityType.client:
action = ViewClientList(); action = ViewClientList(page: page);
break; break;
case EntityType.user: case EntityType.user:
action = ViewUserList(); action = ViewUserList();
break; break;
case EntityType.project: case EntityType.project:
action = ViewProjectList(); action = ViewProjectList(page: page);
break; break;
case EntityType.taxRate: case EntityType.taxRate:
action = ViewTaxRateList(); action = ViewTaxRateList();
@ -386,25 +393,25 @@ void viewEntitiesByType({
action = ViewCompanyGatewayList(); action = ViewCompanyGatewayList();
break; break;
case EntityType.invoice: case EntityType.invoice:
action = ViewInvoiceList(); action = ViewInvoiceList(page: page);
break; break;
case EntityType.quote: case EntityType.quote:
action = ViewQuoteList(); action = ViewQuoteList(page: page);
break; break;
case EntityType.vendor: case EntityType.vendor:
action = ViewVendorList(); action = ViewVendorList(page: page);
break; break;
case EntityType.product: case EntityType.product:
action = ViewProductList(); action = ViewProductList(page: page);
break; break;
case EntityType.task: case EntityType.task:
action = ViewTaskList(); action = ViewTaskList(page: page);
break; break;
case EntityType.expense: case EntityType.expense:
action = ViewExpenseList(); action = ViewExpenseList(page: page);
break; break;
case EntityType.payment: case EntityType.payment:
action = ViewPaymentList(); action = ViewPaymentList(page: page);
break; break;
case EntityType.group: case EntityType.group:
action = ViewGroupList(); action = ViewGroupList();
@ -416,20 +423,17 @@ void viewEntitiesByType({
case EntityType.transactionRule: case EntityType.transactionRule:
action = ViewTransactionRuleList(); action = ViewTransactionRuleList();
break; break;
case EntityType.transaction: case EntityType.transaction:
action = ViewTransactionList(); action = ViewTransactionList(page: page);
break; break;
case EntityType.bankAccount: case EntityType.bankAccount:
action = ViewBankAccountList(); action = ViewBankAccountList();
break; break;
case EntityType.purchaseOrder: case EntityType.purchaseOrder:
action = ViewPurchaseOrderList(); action = ViewPurchaseOrderList(page: page);
break; break;
case EntityType.recurringExpense: case EntityType.recurringExpense:
action = ViewRecurringExpenseList(); action = ViewRecurringExpenseList(page: page);
break; break;
case EntityType.subscription: case EntityType.subscription:
action = ViewSubscriptionList(); action = ViewSubscriptionList();
@ -441,7 +445,7 @@ void viewEntitiesByType({
action = ViewExpenseCategoryList(); action = ViewExpenseCategoryList();
break; break;
case EntityType.recurringInvoice: case EntityType.recurringInvoice:
action = ViewRecurringInvoiceList(); action = ViewRecurringInvoiceList(page: page);
break; break;
case EntityType.webhook: case EntityType.webhook:
action = ViewWebhookList(); action = ViewWebhookList();
@ -456,7 +460,7 @@ void viewEntitiesByType({
action = ViewDesignList(); action = ViewDesignList();
break; break;
case EntityType.credit: case EntityType.credit:
action = ViewCreditList(); action = ViewCreditList(page: page);
break; break;
} }

View File

@ -26,9 +26,11 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
class ViewClientList implements PersistUI { class ViewClientList implements PersistUI {
ViewClientList({ ViewClientList({
this.force = false, this.force = false,
this.page = 0,
}); });
final bool force; final bool force;
final int page;
} }
class ViewClient implements PersistUI, PersistPrefs { class ViewClient implements PersistUI, PersistPrefs {

View File

@ -29,9 +29,13 @@ import 'package:invoiceninja_flutter/data/web_client.dart';
import 'package:printing/printing.dart'; import 'package:printing/printing.dart';
class ViewCreditList implements PersistUI { class ViewCreditList implements PersistUI {
ViewCreditList({this.force = false}); ViewCreditList({
this.force = false,
this.page = 0,
});
final bool force; final bool force;
final int page;
} }
class ViewCredit implements PersistUI, PersistPrefs { class ViewCredit implements PersistUI, PersistPrefs {

View File

@ -23,9 +23,13 @@ import 'package:invoiceninja_flutter/utils/dialogs.dart';
import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/localization.dart';
class ViewExpenseList implements PersistUI { class ViewExpenseList implements PersistUI {
ViewExpenseList({this.force = false}); ViewExpenseList({
this.force = false,
this.page = 0,
});
final bool force; final bool force;
final int page;
} }
class ViewExpense implements PersistUI, PersistPrefs { class ViewExpense implements PersistUI, PersistPrefs {

View File

@ -31,9 +31,13 @@ import 'package:invoiceninja_flutter/data/web_client.dart';
import 'package:printing/printing.dart'; import 'package:printing/printing.dart';
class ViewInvoiceList implements PersistUI { class ViewInvoiceList implements PersistUI {
ViewInvoiceList({this.force = false}); ViewInvoiceList({
this.force = false,
this.page = 0,
});
final bool force; final bool force;
final int page;
} }
class ViewInvoice implements PersistUI, PersistPrefs { class ViewInvoice implements PersistUI, PersistPrefs {

View File

@ -18,9 +18,13 @@ import 'package:invoiceninja_flutter/utils/completers.dart';
import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/localization.dart';
class ViewPaymentList implements PersistUI { class ViewPaymentList implements PersistUI {
ViewPaymentList({this.force = false}); ViewPaymentList({
this.force = false,
this.page = 0,
});
final bool force; final bool force;
final int page;
} }
class ViewPayment implements PersistUI, PersistPrefs { class ViewPayment implements PersistUI, PersistPrefs {

View File

@ -23,9 +23,13 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
import '../document/document_actions.dart'; import '../document/document_actions.dart';
class ViewProductList implements PersistUI { class ViewProductList implements PersistUI {
ViewProductList({this.force = false}); ViewProductList({
this.force = false,
this.page = 0,
});
final bool force; final bool force;
final int page;
} }
class ViewProduct implements PersistUI, PersistPrefs { class ViewProduct implements PersistUI, PersistPrefs {

View File

@ -22,9 +22,13 @@ import 'package:invoiceninja_flutter/utils/dialogs.dart';
import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/localization.dart';
class ViewProjectList implements PersistUI { class ViewProjectList implements PersistUI {
ViewProjectList({this.force = false}); ViewProjectList({
this.force = false,
this.page = 0,
});
final bool force; final bool force;
final int page;
} }
class ViewProject implements PersistUI, PersistPrefs { class ViewProject implements PersistUI, PersistPrefs {

View File

@ -20,9 +20,13 @@ import 'package:printing/printing.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class ViewPurchaseOrderList implements PersistUI { class ViewPurchaseOrderList implements PersistUI {
ViewPurchaseOrderList({this.force = false}); ViewPurchaseOrderList({
this.force = false,
this.page = 0,
});
final bool force; final bool force;
final int page;
} }
class ViewPurchaseOrder implements PersistUI, PersistPrefs { class ViewPurchaseOrder implements PersistUI, PersistPrefs {

View File

@ -29,9 +29,13 @@ import 'package:invoiceninja_flutter/data/web_client.dart';
import 'package:printing/printing.dart'; import 'package:printing/printing.dart';
class ViewQuoteList implements PersistUI { class ViewQuoteList implements PersistUI {
ViewQuoteList({this.force = false}); ViewQuoteList({
this.force = false,
this.page = 0,
});
final bool force; final bool force;
final int page;
} }
class ViewQuote implements PersistUI, PersistPrefs { class ViewQuote implements PersistUI, PersistPrefs {

View File

@ -22,9 +22,11 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
class ViewRecurringExpenseList implements PersistUI { class ViewRecurringExpenseList implements PersistUI {
ViewRecurringExpenseList({ ViewRecurringExpenseList({
this.force = false, this.force = false,
this.page = 0,
}); });
final bool force; final bool force;
final int page;
} }
class ViewRecurringExpense implements PersistUI, PersistPrefs { class ViewRecurringExpense implements PersistUI, PersistPrefs {

View File

@ -27,9 +27,11 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
class ViewRecurringInvoiceList implements PersistUI { class ViewRecurringInvoiceList implements PersistUI {
ViewRecurringInvoiceList({ ViewRecurringInvoiceList({
this.force = false, this.force = false,
this.page = 0,
}); });
final bool force; final bool force;
final int page;
} }
class ViewRecurringInvoice implements PersistUI, PersistPrefs { class ViewRecurringInvoice implements PersistUI, PersistPrefs {

View File

@ -22,9 +22,10 @@ import 'package:invoiceninja_flutter/utils/formatting.dart';
import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/localization.dart';
class ViewTaskList implements PersistUI { class ViewTaskList implements PersistUI {
ViewTaskList({this.force = false}); ViewTaskList({this.force = false, this.page = 0,});
final bool force; final bool force;
final int page;
} }
class ViewTask implements PersistUI, PersistPrefs { class ViewTask implements PersistUI, PersistPrefs {

View File

@ -10,9 +10,13 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart'; import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
class ViewTransactionList implements PersistUI { class ViewTransactionList implements PersistUI {
ViewTransactionList({this.force = false}); ViewTransactionList({
this.force = false,
this.page = 0,
});
final bool force; final bool force;
final int page;
} }
class ViewTransaction implements PersistUI, PersistPrefs { class ViewTransaction implements PersistUI, PersistPrefs {

View File

@ -536,6 +536,18 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
} }
}, },
), ),
TypedReducer<BuiltList<HistoryRecord>, UpdateLastHistory>(
(historyList, action) {
if (historyList.isEmpty) {
return historyList;
}
final history = historyList.first;
return historyList.rebuild(
(b) => b..[0] = history.rebuild((b) => b.page = action.page));
},
),
TypedReducer<BuiltList<HistoryRecord>, ViewDashboard>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, ViewDashboard>((historyList, action) =>
_addToHistory( _addToHistory(
historyList, HistoryRecord(entityType: EntityType.dashboard))), historyList, HistoryRecord(entityType: EntityType.dashboard))),
@ -551,9 +563,9 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
TypedReducer<BuiltList<HistoryRecord>, ViewClient>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, ViewClient>((historyList, action) =>
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.clientId, entityType: EntityType.client))), HistoryRecord(id: action.clientId, entityType: EntityType.client))),
TypedReducer<BuiltList<HistoryRecord>, ViewClientList>((historyList, TypedReducer<BuiltList<HistoryRecord>, ViewClientList>(
action) => (historyList, action) => _addToHistory(historyList,
_addToHistory(historyList, HistoryRecord(entityType: EntityType.client))), HistoryRecord(entityType: EntityType.client, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditClient>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, EditClient>((historyList, action) =>
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.client.id, entityType: EntityType.client))), HistoryRecord(id: action.client.id, entityType: EntityType.client))),
@ -561,8 +573,8 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.productId, entityType: EntityType.product))), HistoryRecord(id: action.productId, entityType: EntityType.product))),
TypedReducer<BuiltList<HistoryRecord>, ViewProductList>( TypedReducer<BuiltList<HistoryRecord>, ViewProductList>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(historyList,
historyList, HistoryRecord(entityType: EntityType.product))), HistoryRecord(entityType: EntityType.product, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditProduct>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, EditProduct>((historyList, action) =>
_addToHistory( _addToHistory(
historyList, historyList,
@ -572,8 +584,8 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.invoiceId, entityType: EntityType.invoice))), HistoryRecord(id: action.invoiceId, entityType: EntityType.invoice))),
TypedReducer<BuiltList<HistoryRecord>, ViewInvoiceList>( TypedReducer<BuiltList<HistoryRecord>, ViewInvoiceList>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(historyList,
historyList, HistoryRecord(entityType: EntityType.invoice))), HistoryRecord(entityType: EntityType.invoice, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditInvoice>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, EditInvoice>((historyList, action) =>
_addToHistory( _addToHistory(
historyList, historyList,
@ -583,8 +595,8 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.paymentId, entityType: EntityType.payment))), HistoryRecord(id: action.paymentId, entityType: EntityType.payment))),
TypedReducer<BuiltList<HistoryRecord>, ViewPaymentList>( TypedReducer<BuiltList<HistoryRecord>, ViewPaymentList>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(historyList,
historyList, HistoryRecord(entityType: EntityType.payment))), HistoryRecord(entityType: EntityType.payment, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditPayment>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, EditPayment>((historyList, action) =>
_addToHistory( _addToHistory(
historyList, historyList,
@ -594,7 +606,8 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.quoteId, entityType: EntityType.quote))), HistoryRecord(id: action.quoteId, entityType: EntityType.quote))),
TypedReducer<BuiltList<HistoryRecord>, ViewQuoteList>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, ViewQuoteList>((historyList, action) =>
_addToHistory(historyList, HistoryRecord(entityType: EntityType.quote))), _addToHistory(historyList,
HistoryRecord(entityType: EntityType.quote, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditQuote>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, EditQuote>((historyList, action) =>
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.quote.id, entityType: EntityType.quote))), HistoryRecord(id: action.quote.id, entityType: EntityType.quote))),
@ -602,7 +615,8 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.taskId, entityType: EntityType.task))), HistoryRecord(id: action.taskId, entityType: EntityType.task))),
TypedReducer<BuiltList<HistoryRecord>, ViewTaskList>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, ViewTaskList>((historyList, action) =>
_addToHistory(historyList, HistoryRecord(entityType: EntityType.task))), _addToHistory(historyList,
HistoryRecord(entityType: EntityType.task, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditTask>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, EditTask>((historyList, action) =>
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.task.id, entityType: EntityType.task))), HistoryRecord(id: action.task.id, entityType: EntityType.task))),
@ -610,8 +624,8 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.projectId, entityType: EntityType.project))), HistoryRecord(id: action.projectId, entityType: EntityType.project))),
TypedReducer<BuiltList<HistoryRecord>, ViewProjectList>( TypedReducer<BuiltList<HistoryRecord>, ViewProjectList>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(historyList,
historyList, HistoryRecord(entityType: EntityType.project))), HistoryRecord(entityType: EntityType.project, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditProject>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, EditProject>((historyList, action) =>
_addToHistory( _addToHistory(
historyList, historyList,
@ -620,9 +634,9 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
TypedReducer<BuiltList<HistoryRecord>, ViewVendor>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, ViewVendor>((historyList, action) =>
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.vendorId, entityType: EntityType.vendor))), HistoryRecord(id: action.vendorId, entityType: EntityType.vendor))),
TypedReducer<BuiltList<HistoryRecord>, ViewVendorList>((historyList, TypedReducer<BuiltList<HistoryRecord>, ViewVendorList>(
action) => (historyList, action) => _addToHistory(historyList,
_addToHistory(historyList, HistoryRecord(entityType: EntityType.vendor))), HistoryRecord(entityType: EntityType.vendor, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditVendor>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, EditVendor>((historyList, action) =>
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.vendor.id, entityType: EntityType.vendor))), HistoryRecord(id: action.vendor.id, entityType: EntityType.vendor))),
@ -630,8 +644,8 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.expenseId, entityType: EntityType.expense))), HistoryRecord(id: action.expenseId, entityType: EntityType.expense))),
TypedReducer<BuiltList<HistoryRecord>, ViewExpenseList>( TypedReducer<BuiltList<HistoryRecord>, ViewExpenseList>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(historyList,
historyList, HistoryRecord(entityType: EntityType.expense))), HistoryRecord(entityType: EntityType.expense, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditExpense>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, EditExpense>((historyList, action) =>
_addToHistory( _addToHistory(
historyList, historyList,
@ -706,7 +720,9 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
id: action.transactionId, entityType: EntityType.transaction))), id: action.transactionId, entityType: EntityType.transaction))),
TypedReducer<BuiltList<HistoryRecord>, ViewTransactionList>( TypedReducer<BuiltList<HistoryRecord>, ViewTransactionList>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(
historyList, HistoryRecord(entityType: EntityType.transaction))), historyList,
HistoryRecord(
entityType: EntityType.transaction, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditTransaction>( TypedReducer<BuiltList<HistoryRecord>, EditTransaction>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(
historyList, historyList,
@ -729,7 +745,9 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
entityType: EntityType.purchaseOrder))), entityType: EntityType.purchaseOrder))),
TypedReducer<BuiltList<HistoryRecord>, ViewPurchaseOrderList>( TypedReducer<BuiltList<HistoryRecord>, ViewPurchaseOrderList>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(
historyList, HistoryRecord(entityType: EntityType.purchaseOrder))), historyList,
HistoryRecord(
entityType: EntityType.purchaseOrder, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditPurchaseOrder>( TypedReducer<BuiltList<HistoryRecord>, EditPurchaseOrder>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(
historyList, historyList,
@ -744,7 +762,9 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
entityType: EntityType.recurringExpense))), entityType: EntityType.recurringExpense))),
TypedReducer<BuiltList<HistoryRecord>, ViewRecurringExpenseList>( TypedReducer<BuiltList<HistoryRecord>, ViewRecurringExpenseList>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(
historyList, HistoryRecord(entityType: EntityType.recurringExpense))), historyList,
HistoryRecord(
entityType: EntityType.recurringExpense, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditRecurringExpense>( TypedReducer<BuiltList<HistoryRecord>, EditRecurringExpense>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(
historyList, historyList,
@ -803,7 +823,9 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
entityType: EntityType.recurringInvoice))), entityType: EntityType.recurringInvoice))),
TypedReducer<BuiltList<HistoryRecord>, ViewRecurringInvoiceList>( TypedReducer<BuiltList<HistoryRecord>, ViewRecurringInvoiceList>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(
historyList, HistoryRecord(entityType: EntityType.recurringInvoice))), historyList,
HistoryRecord(
entityType: EntityType.recurringInvoice, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditRecurringInvoice>( TypedReducer<BuiltList<HistoryRecord>, EditRecurringInvoice>(
(historyList, action) => _addToHistory( (historyList, action) => _addToHistory(
historyList, historyList,
@ -849,9 +871,9 @@ Reducer<BuiltList<HistoryRecord>> historyReducer = combineReducers([
TypedReducer<BuiltList<HistoryRecord>, ViewCredit>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, ViewCredit>((historyList, action) =>
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.creditId, entityType: EntityType.credit))), HistoryRecord(id: action.creditId, entityType: EntityType.credit))),
TypedReducer<BuiltList<HistoryRecord>, ViewCreditList>((historyList, TypedReducer<BuiltList<HistoryRecord>, ViewCreditList>(
action) => (historyList, action) => _addToHistory(historyList,
_addToHistory(historyList, HistoryRecord(entityType: EntityType.credit))), HistoryRecord(entityType: EntityType.credit, page: action.page))),
TypedReducer<BuiltList<HistoryRecord>, EditCredit>((historyList, action) => TypedReducer<BuiltList<HistoryRecord>, EditCredit>((historyList, action) =>
_addToHistory(historyList, _addToHistory(historyList,
HistoryRecord(id: action.credit.id, entityType: EntityType.credit))), HistoryRecord(id: action.credit.id, entityType: EntityType.credit))),

View File

@ -394,11 +394,13 @@ abstract class HistoryRecord
factory HistoryRecord({ factory HistoryRecord({
@required EntityType entityType, @required EntityType entityType,
String id, String id,
int page,
}) { }) {
return _$HistoryRecord._( return _$HistoryRecord._(
id: id, id: id,
entityType: entityType, entityType: entityType,
timestamp: DateTime.now().millisecondsSinceEpoch, timestamp: DateTime.now().millisecondsSinceEpoch,
page: page ?? 0,
); );
} }
@ -413,6 +415,9 @@ abstract class HistoryRecord
EntityType get entityType; EntityType get entityType;
@nullable
int get page;
int get timestamp; int get timestamp;
DateTime get dateTime => DateTime.fromMillisecondsSinceEpoch(timestamp); DateTime get dateTime => DateTime.fromMillisecondsSinceEpoch(timestamp);

View File

@ -620,6 +620,12 @@ class _$HistoryRecordSerializer implements StructuredSerializer<HistoryRecord> {
..add(serializers.serialize(value, ..add(serializers.serialize(value,
specifiedType: const FullType(String))); specifiedType: const FullType(String)));
} }
value = object.page;
if (value != null) {
result
..add('page')
..add(serializers.serialize(value, specifiedType: const FullType(int)));
}
return result; return result;
} }
@ -643,6 +649,10 @@ class _$HistoryRecordSerializer implements StructuredSerializer<HistoryRecord> {
result.entityType = serializers.deserialize(value, result.entityType = serializers.deserialize(value,
specifiedType: const FullType(EntityType)) as EntityType; specifiedType: const FullType(EntityType)) as EntityType;
break; break;
case 'page':
result.page = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'timestamp': case 'timestamp':
result.timestamp = serializers.deserialize(value, result.timestamp = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
@ -1557,12 +1567,15 @@ class _$HistoryRecord extends HistoryRecord {
@override @override
final EntityType entityType; final EntityType entityType;
@override @override
final int page;
@override
final int timestamp; final int timestamp;
factory _$HistoryRecord([void Function(HistoryRecordBuilder) updates]) => factory _$HistoryRecord([void Function(HistoryRecordBuilder) updates]) =>
(new HistoryRecordBuilder()..update(updates))._build(); (new HistoryRecordBuilder()..update(updates))._build();
_$HistoryRecord._({this.id, this.entityType, this.timestamp}) : super._() { _$HistoryRecord._({this.id, this.entityType, this.page, this.timestamp})
: super._() {
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
entityType, r'HistoryRecord', 'entityType'); entityType, r'HistoryRecord', 'entityType');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -1582,6 +1595,7 @@ class _$HistoryRecord extends HistoryRecord {
return other is HistoryRecord && return other is HistoryRecord &&
id == other.id && id == other.id &&
entityType == other.entityType && entityType == other.entityType &&
page == other.page &&
timestamp == other.timestamp; timestamp == other.timestamp;
} }
@ -1592,6 +1606,7 @@ class _$HistoryRecord extends HistoryRecord {
var _$hash = 0; var _$hash = 0;
_$hash = $jc(_$hash, id.hashCode); _$hash = $jc(_$hash, id.hashCode);
_$hash = $jc(_$hash, entityType.hashCode); _$hash = $jc(_$hash, entityType.hashCode);
_$hash = $jc(_$hash, page.hashCode);
_$hash = $jc(_$hash, timestamp.hashCode); _$hash = $jc(_$hash, timestamp.hashCode);
_$hash = $jf(_$hash); _$hash = $jf(_$hash);
return __hashCode ??= _$hash; return __hashCode ??= _$hash;
@ -1602,6 +1617,7 @@ class _$HistoryRecord extends HistoryRecord {
return (newBuiltValueToStringHelper(r'HistoryRecord') return (newBuiltValueToStringHelper(r'HistoryRecord')
..add('id', id) ..add('id', id)
..add('entityType', entityType) ..add('entityType', entityType)
..add('page', page)
..add('timestamp', timestamp)) ..add('timestamp', timestamp))
.toString(); .toString();
} }
@ -1619,6 +1635,10 @@ class HistoryRecordBuilder
EntityType get entityType => _$this._entityType; EntityType get entityType => _$this._entityType;
set entityType(EntityType entityType) => _$this._entityType = entityType; set entityType(EntityType entityType) => _$this._entityType = entityType;
int _page;
int get page => _$this._page;
set page(int page) => _$this._page = page;
int _timestamp; int _timestamp;
int get timestamp => _$this._timestamp; int get timestamp => _$this._timestamp;
set timestamp(int timestamp) => _$this._timestamp = timestamp; set timestamp(int timestamp) => _$this._timestamp = timestamp;
@ -1630,6 +1650,7 @@ class HistoryRecordBuilder
if ($v != null) { if ($v != null) {
_id = $v.id; _id = $v.id;
_entityType = $v.entityType; _entityType = $v.entityType;
_page = $v.page;
_timestamp = $v.timestamp; _timestamp = $v.timestamp;
_$v = null; _$v = null;
} }
@ -1656,6 +1677,7 @@ class HistoryRecordBuilder
id: id, id: id,
entityType: BuiltValueNullFieldError.checkNotNull( entityType: BuiltValueNullFieldError.checkNotNull(
entityType, r'HistoryRecord', 'entityType'), entityType, r'HistoryRecord', 'entityType'),
page: page,
timestamp: BuiltValueNullFieldError.checkNotNull( timestamp: BuiltValueNullFieldError.checkNotNull(
timestamp, r'HistoryRecord', 'timestamp')); timestamp, r'HistoryRecord', 'timestamp'));
replace(_$result); replace(_$result);

View File

@ -21,9 +21,13 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class ViewVendorList implements PersistUI { class ViewVendorList implements PersistUI {
ViewVendorList({this.force = false}); ViewVendorList({
this.force = false,
this.page = 0,
});
final bool force; final bool force;
final int page;
} }
class ViewVendor implements PersistUI, PersistPrefs { class ViewVendor implements PersistUI, PersistPrefs {

View File

@ -2,6 +2,7 @@
import 'dart:async'; import 'dart:async';
// Flutter imports: // Flutter imports:
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
@ -134,6 +135,10 @@ class _HistoryListTileState extends State<HistoryListTile> {
} }
} else if (history.id == null) { } else if (history.id == null) {
title = Text(localization.lookup(history.entityType.plural)); title = Text(localization.lookup(history.entityType.plural));
if (!kReleaseMode) {
subtitle = Text('Page: ${history.page}');
}
} else { } else {
entity = state.getEntityMap(history.entityType)[history.id] as BaseEntity; entity = state.getEntityMap(history.entityType)[history.id] as BaseEntity;

View File

@ -314,7 +314,8 @@ class MainScreen extends StatelessWidget {
break; break;
default: default:
if ((history.id ?? '').isEmpty) { if ((history.id ?? '').isEmpty) {
viewEntitiesByType(entityType: history.entityType); viewEntitiesByType(
entityType: history.entityType, page: history.page);
} else { } else {
viewEntityById( viewEntityById(
entityId: history.id, entityId: history.id,

View File

@ -134,8 +134,10 @@ class _MenuDrawerState extends State<MenuDrawer> {
break; break;
default: default:
if ((history.id ?? '').isEmpty) { if ((history.id ?? '').isEmpty) {
print('## PAGE: ${history.page}');
viewEntitiesByType( viewEntitiesByType(
entityType: history.entityType); entityType: history.entityType,
page: history.page);
} else { } else {
viewEntityById( viewEntityById(
entityId: history.id, entityId: history.id,

View File

@ -88,12 +88,20 @@ class _EntityListState extends State<EntityList> {
// make sure the initial page shows the selected record // make sure the initial page shows the selected record
final entityUIState = state.getUIState(entityType); final entityUIState = state.getUIState(entityType);
final selectedIndex = widget.entityList.indexOf(entityUIState.selectedId);
final rowsPerPage = state.prefState.rowsPerPage; final rowsPerPage = state.prefState.rowsPerPage;
if ((entityUIState.selectedId ?? '').isNotEmpty) {
final selectedIndex = widget.entityList.indexOf(entityUIState.selectedId);
if (selectedIndex >= 0) { if (selectedIndex >= 0) {
_firstRowIndex = (selectedIndex / rowsPerPage).floor() * rowsPerPage; _firstRowIndex = (selectedIndex / rowsPerPage).floor() * rowsPerPage;
} }
} else {
final history = state.historyList.first;
if (history.page != null) {
_firstRowIndex = history.page * rowsPerPage;
}
}
} }
@override @override
@ -279,7 +287,11 @@ class _EntityListState extends State<EntityList> {
: 0, : 0,
sortAscending: listUIState.sortAscending, sortAscending: listUIState.sortAscending,
rowsPerPage: state.prefState.rowsPerPage, rowsPerPage: state.prefState.rowsPerPage,
onPageChanged: (row) => _firstRowIndex = row, onPageChanged: (row) {
_firstRowIndex = row;
store.dispatch(UpdateLastHistory(
(row / state.prefState.rowsPerPage).floor()));
},
initialFirstRowIndex: _firstRowIndex, initialFirstRowIndex: _firstRowIndex,
availableRowsPerPage: [ availableRowsPerPage: [
10, 10,

View File

@ -12,9 +12,11 @@ import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart'
class ViewStubList implements PersistUI { class ViewStubList implements PersistUI {
ViewStubList({ ViewStubList({
this.force = false this.force = false
this.page = 0,
}); });
final bool force; final bool force;
final int page;
} }
class ViewStub class ViewStub