Set default tab to 0

This commit is contained in:
Hillel Coren 2021-02-15 10:30:52 +02:00
parent eb0e482b39
commit 8394a8b3c0
47 changed files with 53 additions and 41 deletions

View File

@ -6,7 +6,7 @@ class Constants {
} }
// TODO remove version once #46609 is fixed // TODO remove version once #46609 is fixed
const String kClientVersion = '5.0.41'; const String kClientVersion = '5.0.42';
const String kMinServerVersion = '5.0.4'; const String kMinServerVersion = '5.0.4';
const String kAppName = 'Invoice Ninja'; const String kAppName = 'Invoice Ninja';

View File

@ -1407,7 +1407,7 @@ void selectEntity({
!entity.entityType.isSetting && !entity.entityType.isSetting &&
entityUIState.selectedId == entity.id && entityUIState.selectedId == entity.id &&
state.prefState.isPreviewVisible) { state.prefState.isPreviewVisible) {
if ((entityUIState.tabIndex ?? 0) > 0) { if (entityUIState.tabIndex > 0) {
store.dispatch(PreviewEntity()); store.dispatch(PreviewEntity());
} else { } else {
editEntity(context: context, entity: entity); editEntity(context: context, entity: entity);

View File

@ -27,7 +27,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -59,6 +59,7 @@ abstract class ClientUIState extends Object
editing: ClientEntity(), editing: ClientEntity(),
editingContact: ContactEntity(), editingContact: ContactEntity(),
saveCompleter: null, saveCompleter: null,
tabIndex: 0,
); );
} }

View File

@ -46,6 +46,7 @@ abstract class CompanyGatewayUIState extends Object
listUIState: ListUIState(CompanyGatewayFields.name), listUIState: ListUIState(CompanyGatewayFields.name),
editing: CompanyGatewayEntity(), editing: CompanyGatewayEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
CompanyGatewayUIState._(); CompanyGatewayUIState._();

View File

@ -25,7 +25,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -58,6 +58,7 @@ abstract class CreditUIState extends Object
listUIState: ListUIState(CreditFields.number, sortAscending: false), listUIState: ListUIState(CreditFields.number, sortAscending: false),
editing: InvoiceEntity(), editing: InvoiceEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }

View File

@ -60,6 +60,7 @@ abstract class DesignUIState extends Object
listUIState: ListUIState(DesignFields.name), listUIState: ListUIState(DesignFields.name),
editing: DesignEntity(), editing: DesignEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }

View File

@ -38,6 +38,7 @@ abstract class DocumentUIState extends Object
listUIState: ListUIState(DocumentFields.name), listUIState: ListUIState(DocumentFields.name),
editing: DocumentEntity(), editing: DocumentEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
DocumentUIState._(); DocumentUIState._();

View File

@ -21,7 +21,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -58,6 +58,7 @@ abstract class ExpenseUIState extends Object
listUIState: ListUIState(ExpenseFields.number, sortAscending: false), listUIState: ListUIState(ExpenseFields.number, sortAscending: false),
editing: ExpenseEntity(), editing: ExpenseEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
ExpenseUIState._(); ExpenseUIState._();

View File

@ -59,6 +59,7 @@ abstract class ExpenseCategoryUIState extends Object
listUIState: ListUIState(ExpenseCategoryFields.name), listUIState: ListUIState(ExpenseCategoryFields.name),
editing: ExpenseCategoryEntity(), editing: ExpenseCategoryEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
ExpenseCategoryUIState._(); ExpenseCategoryUIState._();

View File

@ -44,6 +44,7 @@ abstract class GroupUIState extends Object
listUIState: ListUIState(GroupFields.name), listUIState: ListUIState(GroupFields.name),
editing: GroupEntity(), editing: GroupEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
GroupUIState._(); GroupUIState._();

View File

@ -26,7 +26,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -59,6 +59,7 @@ abstract class InvoiceUIState extends Object
listUIState: ListUIState(InvoiceFields.number, sortAscending: false), listUIState: ListUIState(InvoiceFields.number, sortAscending: false),
editing: InvoiceEntity(), editing: InvoiceEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }

View File

@ -21,7 +21,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -60,6 +60,7 @@ abstract class PaymentUIState extends Object
listUIState: ListUIState(PaymentFields.number, sortAscending: false), listUIState: ListUIState(PaymentFields.number, sortAscending: false),
editing: PaymentEntity(), editing: PaymentEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }

View File

@ -50,6 +50,7 @@ abstract class PaymentTermUIState extends Object
listUIState: ListUIState(PaymentTermFields.name), listUIState: ListUIState(PaymentTermFields.name),
editing: PaymentTermEntity(), editing: PaymentTermEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
PaymentTermUIState._(); PaymentTermUIState._();

View File

@ -22,7 +22,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -49,6 +49,7 @@ abstract class ProductUIState extends Object
listUIState: ListUIState(ProductFields.productKey), listUIState: ListUIState(ProductFields.productKey),
editing: ProductEntity(), editing: ProductEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
ProductUIState._(); ProductUIState._();

View File

@ -25,7 +25,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -59,6 +59,7 @@ abstract class ProjectUIState extends Object
listUIState: ListUIState(ProjectFields.number, sortAscending: false), listUIState: ListUIState(ProjectFields.number, sortAscending: false),
editing: ProjectEntity(), editing: ProjectEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
ProjectUIState._(); ProjectUIState._();

View File

@ -26,7 +26,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -60,6 +60,7 @@ abstract class QuoteUIState extends Object
listUIState: ListUIState(QuoteFields.number, sortAscending: false), listUIState: ListUIState(QuoteFields.number, sortAscending: false),
editing: InvoiceEntity(), editing: InvoiceEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }

View File

@ -27,7 +27,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -61,6 +61,7 @@ abstract class RecurringInvoiceUIState extends Object
listUIState: ListUIState(InvoiceFields.number), listUIState: ListUIState(InvoiceFields.number),
editing: InvoiceEntity(), editing: InvoiceEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }

View File

@ -22,7 +22,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -57,6 +57,7 @@ abstract class TaskUIState extends Object
listUIState: ListUIState(TaskFields.number, sortAscending: false), listUIState: ListUIState(TaskFields.number, sortAscending: false),
editing: TaskEntity(), editing: TaskEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
TaskUIState._(); TaskUIState._();

View File

@ -59,6 +59,7 @@ abstract class TaskStatusUIState extends Object
listUIState: ListUIState(TaskStatusFields.name), listUIState: ListUIState(TaskStatusFields.name),
editing: TaskStatusEntity(), editing: TaskStatusEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
TaskStatusUIState._(); TaskStatusUIState._();

View File

@ -37,6 +37,7 @@ abstract class TaxRateUIState extends Object
listUIState: ListUIState(TaxRateFields.name), listUIState: ListUIState(TaxRateFields.name),
editing: TaxRateEntity(), editing: TaxRateEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
TaxRateUIState._(); TaxRateUIState._();

View File

@ -48,6 +48,7 @@ abstract class TokenUIState extends Object
listUIState: ListUIState(TokenFields.name), listUIState: ListUIState(TokenFields.name),
editing: TokenEntity(), editing: TokenEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
TokenUIState._(); TokenUIState._();

View File

@ -12,7 +12,6 @@ abstract class EntityUIState {
@nullable @nullable
String get selectedId; String get selectedId;
@nullable
int get tabIndex; int get tabIndex;
@nullable @nullable

View File

@ -198,7 +198,7 @@ Reducer<SettingsUIState> settingsUIReducer = combineReducers([
..origUser.replace(action.user ?? state.origUser) ..origUser.replace(action.user ?? state.origUser)
..updatedAt = DateTime.now().millisecondsSinceEpoch ..updatedAt = DateTime.now().millisecondsSinceEpoch
..section = action.section ?? state.section ..section = action.section ?? state.section
..tabIndex = action.tabIndex ?? 0 ..tabIndex = action.tabIndex
..isChanged = false ..isChanged = false
..entityType = action.client != null ..entityType = action.client != null
? EntityType.client ? EntityType.client

View File

@ -44,6 +44,7 @@ abstract class UserUIState extends Object
listUIState: ListUIState(UserFields.firstName), listUIState: ListUIState(UserFields.firstName),
editing: UserEntity(), editing: UserEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
UserUIState._(); UserUIState._();

View File

@ -27,7 +27,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -60,6 +60,7 @@ abstract class VendorUIState extends Object
editing: VendorEntity(), editing: VendorEntity(),
editingContact: VendorContactEntity(), editingContact: VendorContactEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }

View File

@ -49,6 +49,7 @@ abstract class WebhookUIState extends Object
listUIState: ListUIState(WebhookFields.targetUrl), listUIState: ListUIState(WebhookFields.targetUrl),
editing: WebhookEntity(), editing: WebhookEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
WebhookUIState._(); WebhookUIState._();

View File

@ -42,9 +42,7 @@ class _ClientViewState extends State<ClientView>
final state = widget.viewModel.state; final state = widget.viewModel.state;
_controller = TabController( _controller = TabController(
vsync: this, vsync: this, length: 6, initialIndex: state.clientUIState.tabIndex);
length: 6,
initialIndex: state.clientUIState.tabIndex ?? 0);
_controller.addListener(_onTabChanged); _controller.addListener(_onTabChanged);
} }
@ -58,7 +56,7 @@ class _ClientViewState extends State<ClientView>
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (oldWidget.tabIndex != widget.tabIndex) { if (oldWidget.tabIndex != widget.tabIndex) {
_controller.index = widget.tabIndex ?? 0; _controller.index = widget.tabIndex;
} }
} }

View File

@ -42,9 +42,7 @@ class _ExpenseViewState extends State<ExpenseView>
final state = widget.viewModel.state; final state = widget.viewModel.state;
_controller = TabController( _controller = TabController(
vsync: this, vsync: this, length: 2, initialIndex: state.expenseUIState.tabIndex);
length: 2,
initialIndex: state.expenseUIState.tabIndex ?? 0);
_controller.addListener(_onTabChanged); _controller.addListener(_onTabChanged);
} }
@ -58,7 +56,7 @@ class _ExpenseViewState extends State<ExpenseView>
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (oldWidget.tabIndex != widget.tabIndex) { if (oldWidget.tabIndex != widget.tabIndex) {
_controller.index = widget.tabIndex ?? 0; _controller.index = widget.tabIndex;
} }
} }

View File

@ -59,7 +59,7 @@ class _InvoiceViewState extends State<InvoiceView>
_controller = TabController( _controller = TabController(
vsync: this, vsync: this,
length: invoice.isRecurring ? 5 : 4, length: invoice.isRecurring ? 5 : 4,
initialIndex: tabIndex ?? 0); initialIndex: tabIndex);
_controller.addListener(_onTabChanged); _controller.addListener(_onTabChanged);
} }
@ -83,7 +83,7 @@ class _InvoiceViewState extends State<InvoiceView>
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (oldWidget.tabIndex != widget.tabIndex) { if (oldWidget.tabIndex != widget.tabIndex) {
_controller.index = widget.tabIndex ?? 0; _controller.index = widget.tabIndex;
} }
} }

View File

@ -38,9 +38,7 @@ class _ProductViewState extends State<ProductView>
final state = widget.viewModel.state; final state = widget.viewModel.state;
_controller = TabController( _controller = TabController(
vsync: this, vsync: this, length: 2, initialIndex: state.productUIState.tabIndex);
length: 2,
initialIndex: state.productUIState.tabIndex ?? 0);
_controller.addListener(_onTabChanged); _controller.addListener(_onTabChanged);
} }
@ -54,7 +52,7 @@ class _ProductViewState extends State<ProductView>
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (oldWidget.tabIndex != widget.tabIndex) { if (oldWidget.tabIndex != widget.tabIndex) {
_controller.index = widget.tabIndex ?? 0; _controller.index = widget.tabIndex;
} }
} }

View File

@ -38,9 +38,7 @@ class _ProjectViewState extends State<ProjectView>
final state = widget.viewModel.state; final state = widget.viewModel.state;
_controller = TabController( _controller = TabController(
vsync: this, vsync: this, length: 2, initialIndex: state.projectUIState.tabIndex);
length: 2,
initialIndex: state.projectUIState.tabIndex ?? 0);
_controller.addListener(_onTabChanged); _controller.addListener(_onTabChanged);
} }
@ -54,7 +52,7 @@ class _ProjectViewState extends State<ProjectView>
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (oldWidget.tabIndex != widget.tabIndex) { if (oldWidget.tabIndex != widget.tabIndex) {
_controller.index = widget.tabIndex ?? 0; _controller.index = widget.tabIndex;
} }
} }

View File

@ -38,7 +38,7 @@ class _TaskViewState extends State<TaskView>
final state = widget.viewModel.state; final state = widget.viewModel.state;
_controller = TabController( _controller = TabController(
vsync: this, length: 2, initialIndex: state.taskUIState.tabIndex ?? 0); vsync: this, length: 2, initialIndex: state.taskUIState.tabIndex);
_controller.addListener(_onTabChanged); _controller.addListener(_onTabChanged);
} }
@ -52,7 +52,7 @@ class _TaskViewState extends State<TaskView>
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (oldWidget.tabIndex != widget.tabIndex) { if (oldWidget.tabIndex != widget.tabIndex) {
_controller.index = widget.tabIndex ?? 0; _controller.index = widget.tabIndex;
} }
} }

View File

@ -37,9 +37,7 @@ class _VendorViewState extends State<VendorView>
final state = widget.viewModel.state; final state = widget.viewModel.state;
_controller = TabController( _controller = TabController(
vsync: this, vsync: this, length: 3, initialIndex: state.vendorUIState.tabIndex);
length: 3,
initialIndex: state.vendorUIState.tabIndex ?? 0);
_controller.addListener(_onTabChanged); _controller.addListener(_onTabChanged);
} }
@ -53,7 +51,7 @@ class _VendorViewState extends State<VendorView>
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (oldWidget.tabIndex != widget.tabIndex) { if (oldWidget.tabIndex != widget.tabIndex) {
_controller.index = widget.tabIndex ?? 0; _controller.index = widget.tabIndex;
} }
} }

View File

@ -1,6 +1,6 @@
name: invoiceninja_flutter name: invoiceninja_flutter
description: Client for Invoice Ninja description: Client for Invoice Ninja
version: 5.0.41+41 version: 5.0.42+42
author: Hillel Coren author: Hillel Coren
homepage: https://invoiceninja.com homepage: https://invoiceninja.com
documentation: http://docs.invoiceninja.com documentation: http://docs.invoiceninja.com

View File

@ -23,7 +23,7 @@ final tabIndexReducer = combineReducers<int>([
return action.tabIndex; return action.tabIndex;
}), }),
TypedReducer<int, PreviewEntity>((completer, action) { TypedReducer<int, PreviewEntity>((completer, action) {
return null; return 0;
}), }),
]); ]);

View File

@ -57,6 +57,7 @@ abstract class StubUIState extends Object with EntityUIState implements Built<St
listUIState: ListUIState(StubFields.name), listUIState: ListUIState(StubFields.name),
editing: StubEntity(), editing: StubEntity(),
selectedId: '', selectedId: '',
tabIndex: 0,
); );
} }
StubUIState._(); StubUIState._();