Flutter web
This commit is contained in:
parent
9bd7476a6b
commit
9e78bc7e41
|
|
@ -120,14 +120,17 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
BuiltList<HistoryRecord> get historyList =>
|
||||
prefState.companyPrefs[uiState.selectedCompanyIndex].historyList;
|
||||
|
||||
bool shouldSelectEntity(EntityType entityType) {
|
||||
bool shouldSelectEntity({EntityType entityType, bool hasRecords}) {
|
||||
final entityList = getEntityList(entityType);
|
||||
final entityUIState = getUIState(entityType);
|
||||
|
||||
if (prefState.isMobile || entityList.isEmpty || uiState.isEditing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!entityList.contains(entityUIState.selectedId)) {
|
||||
if (entityUIState.selectedId == null && !hasRecords) {
|
||||
return false;
|
||||
} else if (!entityList.contains(entityUIState.selectedId)) {
|
||||
return true;
|
||||
} else if (historyList.isEmpty ||
|
||||
!historyList.first.isEqualTo(
|
||||
|
|
|
|||
|
|
@ -141,17 +141,18 @@ class MainScreen extends StatelessWidget {
|
|||
onWillPop: () async {
|
||||
final state = store.state;
|
||||
final historyList = state.historyList;
|
||||
final editingOrSettings =
|
||||
state.uiState.isEditing || state.uiState.isInSettings;
|
||||
final notViewingEntity = state.uiState.isEditing ||
|
||||
state.uiState.isInSettings ||
|
||||
(historyList[0].entityType.toString() != state.uiState.mainRoute);
|
||||
|
||||
if (historyList.isEmpty ||
|
||||
historyList.length == 1 && !editingOrSettings) {
|
||||
historyList.length == 1 && !notViewingEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final history = historyList[editingOrSettings ? 0 : 1];
|
||||
final history = historyList[notViewingEntity ? 0 : 1];
|
||||
|
||||
if (!editingOrSettings) {
|
||||
if (!notViewingEntity) {
|
||||
store.dispatch(PopLastHistory());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ class _ClientListState extends State<ClientList> {
|
|||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.client)) {
|
||||
if (state.shouldSelectEntity(
|
||||
entityType: EntityType.client, hasRecords: clientList.isNotEmpty)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.client,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ class DocumentList extends StatelessWidget {
|
|||
final isInMultiselect = listUIState.isInMultiselect();
|
||||
final documentList = viewModel.documentList;
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.document)) {
|
||||
if (state.shouldSelectEntity(
|
||||
entityType: EntityType.document, hasRecords: documentList.isNotEmpty)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.document,
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@ class _ExpenseListState extends State<ExpenseList> {
|
|||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.expense)) {
|
||||
if (state.shouldSelectEntity(
|
||||
entityType: EntityType.expense, hasRecords: expenseList.isNotEmpty)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.expense,
|
||||
|
|
@ -195,10 +196,9 @@ class _ExpenseListState extends State<ExpenseList> {
|
|||
source: dataTableSource,
|
||||
header: DatatableHeader(
|
||||
entityType: EntityType.expense,
|
||||
onClearPressed: widget
|
||||
.viewModel.onClearEntityFilterPressed,
|
||||
onClearPressed:
|
||||
widget.viewModel.onClearEntityFilterPressed,
|
||||
),
|
||||
|
||||
),
|
||||
)),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ class _EntityListState extends State<InvoiceList> {
|
|||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.invoice)) {
|
||||
if (state.shouldSelectEntity(
|
||||
entityType: EntityType.invoice, hasRecords: invoiceList.isNotEmpty)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.invoice,
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ class _PaymentListState extends State<PaymentList> {
|
|||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.payment)) {
|
||||
if (state.shouldSelectEntity(
|
||||
entityType: EntityType.payment, hasRecords: paymentList.isNotEmpty)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.payment,
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ class _ProductListState extends State<ProductList> {
|
|||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.product)) {
|
||||
if (state.shouldSelectEntity(
|
||||
entityType: EntityType.product, hasRecords: productList.isNotEmpty)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.product,
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class _ProjectListState extends State<ProjectList> {
|
|||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.project)) {
|
||||
if (state.shouldSelectEntity(entityType: EntityType.project, hasRecords: projectList.isNotEmpty)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.project,
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class _TaskListState extends State<TaskList> {
|
|||
final isInMultiselect = listUIState.isInMultiselect();
|
||||
final taskList = widget.viewModel.taskList;
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.task)) {
|
||||
if (state.shouldSelectEntity(entityType: EntityType.task, hasRecords: taskList.isNotEmpty)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.task,
|
||||
|
|
|
|||
|
|
@ -77,7 +77,8 @@ class _VendorListState extends State<VendorList> {
|
|||
return HelpText(AppLocalization.of(context).noRecordsFound);
|
||||
}
|
||||
|
||||
if (state.shouldSelectEntity(EntityType.vendor)) {
|
||||
if (state.shouldSelectEntity(
|
||||
entityType: EntityType.vendor, hasRecords: vendorList.isNotEmpty)) {
|
||||
viewEntityById(
|
||||
context: context,
|
||||
entityType: EntityType.vendor,
|
||||
|
|
|
|||
Loading…
Reference in New Issue