Tablet layout
This commit is contained in:
parent
ea32b2736c
commit
81da98a219
|
|
@ -51,12 +51,7 @@ Middleware<AppState> _editClient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final client =
|
Navigator.of(action.context).pushNamed(ClientEditScreen.route);
|
||||||
await Navigator.of(action.context).pushNamed(ClientEditScreen.route);
|
|
||||||
|
|
||||||
if (action.completer != null && client != null) {
|
|
||||||
action.completer.complete(client);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -171,6 +166,10 @@ Middleware<AppState> _saveClient(ClientRepository repository) {
|
||||||
.then((ClientEntity client) {
|
.then((ClientEntity client) {
|
||||||
if (action.client.isNew) {
|
if (action.client.isNew) {
|
||||||
store.dispatch(AddClientSuccess(client));
|
store.dispatch(AddClientSuccess(client));
|
||||||
|
final clientUIState = store.state.clientUIState;
|
||||||
|
if (clientUIState.saveCompleter != null) {
|
||||||
|
clientUIState.saveCompleter.complete(client);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
store.dispatch(SaveClientSuccess(client));
|
store.dispatch(SaveClientSuccess(client));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
|
import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/ui/entity_ui_state.dart';
|
import 'package:invoiceninja_flutter/redux/ui/entity_ui_state.dart';
|
||||||
|
|
@ -12,7 +14,17 @@ EntityUIState clientUIReducer(ClientUIState state, dynamic action) {
|
||||||
..editing.replace(editingReducer(state.editing, action))
|
..editing.replace(editingReducer(state.editing, action))
|
||||||
..editingContact
|
..editingContact
|
||||||
.replace(editingContactReducer(state.editingContact, action))
|
.replace(editingContactReducer(state.editingContact, action))
|
||||||
..selectedId = selectedIdReducer(state.selectedId, action));
|
..selectedId = selectedIdReducer(state.selectedId, action)
|
||||||
|
..saveCompleter = saveCompleterReducer(state.saveCompleter, action));
|
||||||
|
}
|
||||||
|
|
||||||
|
final saveCompleterReducer = combineReducers<Completer<SelectableEntity>>([
|
||||||
|
TypedReducer<Completer<SelectableEntity>, EditClient>(editClient),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Completer<SelectableEntity> editClient(
|
||||||
|
Completer<SelectableEntity> completer, dynamic action) {
|
||||||
|
return action.completer;
|
||||||
}
|
}
|
||||||
|
|
||||||
final editingContactReducer = combineReducers<ContactEntity>([
|
final editingContactReducer = combineReducers<ContactEntity>([
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:built_value/built_value.dart';
|
import 'package:built_value/built_value.dart';
|
||||||
|
|
@ -55,6 +57,7 @@ abstract class ClientUIState extends Object
|
||||||
editing: ClientEntity(),
|
editing: ClientEntity(),
|
||||||
editingContact: ContactEntity(),
|
editingContact: ContactEntity(),
|
||||||
selectedId: 0,
|
selectedId: 0,
|
||||||
|
saveCompleter: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ClientUIState._();
|
ClientUIState._();
|
||||||
|
|
@ -65,6 +68,10 @@ abstract class ClientUIState extends Object
|
||||||
@nullable
|
@nullable
|
||||||
ContactEntity get editingContact;
|
ContactEntity get editingContact;
|
||||||
|
|
||||||
|
@nullable
|
||||||
|
@BuiltValueField(serialize: false)
|
||||||
|
Completer<SelectableEntity> get saveCompleter;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get isCreatingNew => editing.isNew;
|
bool get isCreatingNew => editing.isNew;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,6 +264,8 @@ class _$ClientUIState extends ClientUIState {
|
||||||
@override
|
@override
|
||||||
final ContactEntity editingContact;
|
final ContactEntity editingContact;
|
||||||
@override
|
@override
|
||||||
|
final Completer<SelectableEntity> saveCompleter;
|
||||||
|
@override
|
||||||
final int selectedId;
|
final int selectedId;
|
||||||
@override
|
@override
|
||||||
final ListUIState listUIState;
|
final ListUIState listUIState;
|
||||||
|
|
@ -272,7 +274,11 @@ class _$ClientUIState extends ClientUIState {
|
||||||
(new ClientUIStateBuilder()..update(updates)).build();
|
(new ClientUIStateBuilder()..update(updates)).build();
|
||||||
|
|
||||||
_$ClientUIState._(
|
_$ClientUIState._(
|
||||||
{this.editing, this.editingContact, this.selectedId, this.listUIState})
|
{this.editing,
|
||||||
|
this.editingContact,
|
||||||
|
this.saveCompleter,
|
||||||
|
this.selectedId,
|
||||||
|
this.listUIState})
|
||||||
: super._() {
|
: super._() {
|
||||||
if (selectedId == null) {
|
if (selectedId == null) {
|
||||||
throw new BuiltValueNullFieldError('ClientUIState', 'selectedId');
|
throw new BuiltValueNullFieldError('ClientUIState', 'selectedId');
|
||||||
|
|
@ -295,6 +301,7 @@ class _$ClientUIState extends ClientUIState {
|
||||||
return other is ClientUIState &&
|
return other is ClientUIState &&
|
||||||
editing == other.editing &&
|
editing == other.editing &&
|
||||||
editingContact == other.editingContact &&
|
editingContact == other.editingContact &&
|
||||||
|
saveCompleter == other.saveCompleter &&
|
||||||
selectedId == other.selectedId &&
|
selectedId == other.selectedId &&
|
||||||
listUIState == other.listUIState;
|
listUIState == other.listUIState;
|
||||||
}
|
}
|
||||||
|
|
@ -302,7 +309,9 @@ class _$ClientUIState extends ClientUIState {
|
||||||
@override
|
@override
|
||||||
int get hashCode {
|
int get hashCode {
|
||||||
return $jf($jc(
|
return $jf($jc(
|
||||||
$jc($jc($jc(0, editing.hashCode), editingContact.hashCode),
|
$jc(
|
||||||
|
$jc($jc($jc(0, editing.hashCode), editingContact.hashCode),
|
||||||
|
saveCompleter.hashCode),
|
||||||
selectedId.hashCode),
|
selectedId.hashCode),
|
||||||
listUIState.hashCode));
|
listUIState.hashCode));
|
||||||
}
|
}
|
||||||
|
|
@ -312,6 +321,7 @@ class _$ClientUIState extends ClientUIState {
|
||||||
return (newBuiltValueToStringHelper('ClientUIState')
|
return (newBuiltValueToStringHelper('ClientUIState')
|
||||||
..add('editing', editing)
|
..add('editing', editing)
|
||||||
..add('editingContact', editingContact)
|
..add('editingContact', editingContact)
|
||||||
|
..add('saveCompleter', saveCompleter)
|
||||||
..add('selectedId', selectedId)
|
..add('selectedId', selectedId)
|
||||||
..add('listUIState', listUIState))
|
..add('listUIState', listUIState))
|
||||||
.toString();
|
.toString();
|
||||||
|
|
@ -333,6 +343,11 @@ class ClientUIStateBuilder
|
||||||
set editingContact(ContactEntityBuilder editingContact) =>
|
set editingContact(ContactEntityBuilder editingContact) =>
|
||||||
_$this._editingContact = editingContact;
|
_$this._editingContact = editingContact;
|
||||||
|
|
||||||
|
Completer<SelectableEntity> _saveCompleter;
|
||||||
|
Completer<SelectableEntity> get saveCompleter => _$this._saveCompleter;
|
||||||
|
set saveCompleter(Completer<SelectableEntity> saveCompleter) =>
|
||||||
|
_$this._saveCompleter = saveCompleter;
|
||||||
|
|
||||||
int _selectedId;
|
int _selectedId;
|
||||||
int get selectedId => _$this._selectedId;
|
int get selectedId => _$this._selectedId;
|
||||||
set selectedId(int selectedId) => _$this._selectedId = selectedId;
|
set selectedId(int selectedId) => _$this._selectedId = selectedId;
|
||||||
|
|
@ -349,6 +364,7 @@ class ClientUIStateBuilder
|
||||||
if (_$v != null) {
|
if (_$v != null) {
|
||||||
_editing = _$v.editing?.toBuilder();
|
_editing = _$v.editing?.toBuilder();
|
||||||
_editingContact = _$v.editingContact?.toBuilder();
|
_editingContact = _$v.editingContact?.toBuilder();
|
||||||
|
_saveCompleter = _$v.saveCompleter;
|
||||||
_selectedId = _$v.selectedId;
|
_selectedId = _$v.selectedId;
|
||||||
_listUIState = _$v.listUIState?.toBuilder();
|
_listUIState = _$v.listUIState?.toBuilder();
|
||||||
_$v = null;
|
_$v = null;
|
||||||
|
|
@ -377,6 +393,7 @@ class ClientUIStateBuilder
|
||||||
new _$ClientUIState._(
|
new _$ClientUIState._(
|
||||||
editing: _editing?.build(),
|
editing: _editing?.build(),
|
||||||
editingContact: _editingContact?.build(),
|
editingContact: _editingContact?.build(),
|
||||||
|
saveCompleter: saveCompleter,
|
||||||
selectedId: selectedId,
|
selectedId: selectedId,
|
||||||
listUIState: listUIState.build());
|
listUIState: listUIState.build());
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@ class _EntityDropdownState extends State<EntityDropdown> {
|
||||||
onSelected: (entity) {
|
onSelected: (entity) {
|
||||||
_textController.text = entity.listDisplayName;
|
_textController.text = entity.listDisplayName;
|
||||||
widget.onSelected(entity);
|
widget.onSelected(entity);
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
},
|
||||||
onAddPressed: widget.onAddPressed != null
|
onAddPressed: widget.onAddPressed != null
|
||||||
? (context, completer) => widget.onAddPressed(completer)
|
? (context, completer) => widget.onAddPressed(completer)
|
||||||
|
|
@ -144,6 +143,7 @@ class _EntityDropdownDialogState extends State<EntityDropdownDialog> {
|
||||||
? IconButton(
|
? IconButton(
|
||||||
icon: Icon(Icons.add_circle_outline),
|
icon: Icon(Icons.add_circle_outline),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
final Completer<SelectableEntity> completer =
|
final Completer<SelectableEntity> completer =
|
||||||
Completer<SelectableEntity>();
|
Completer<SelectableEntity>();
|
||||||
widget.onAddPressed(context, completer);
|
widget.onAddPressed(context, completer);
|
||||||
|
|
@ -184,7 +184,10 @@ class _EntityDropdownDialogState extends State<EntityDropdownDialog> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
subtitle: subtitle != null ? Text(subtitle, maxLines: 2) : null,
|
subtitle: subtitle != null ? Text(subtitle, maxLines: 2) : null,
|
||||||
onTap: () => widget.onSelected(entity),
|
onTap: () {
|
||||||
|
widget.onSelected(entity);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,6 @@ import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/client/client_screen.dart';
|
import 'package:invoiceninja_flutter/ui/client/client_screen.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/client/edit/client_edit.dart';
|
import 'package:invoiceninja_flutter/ui/client/edit/client_edit.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/client/view/client_view_vm.dart';
|
import 'package:invoiceninja_flutter/ui/client/view/client_view_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/expense/edit/expense_edit_vm.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_vm.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/project/edit/project_edit_vm.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/quote/edit/quote_edit_vm.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/task/edit/task_edit_vm.dart';
|
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
|
|
||||||
|
|
@ -115,20 +110,9 @@ class ClientEditVM {
|
||||||
if (state.uiState.currentRoute.contains(ClientScreen.route)) {
|
if (state.uiState.currentRoute.contains(ClientScreen.route)) {
|
||||||
store.dispatch(UpdateCurrentRoute(ClientViewScreen.route));
|
store.dispatch(UpdateCurrentRoute(ClientViewScreen.route));
|
||||||
}
|
}
|
||||||
if (client.isNew) {
|
if (client.isNew && state.clientUIState.saveCompleter == null) {
|
||||||
// The client was created through the entity picker
|
Navigator.of(context)
|
||||||
if ([
|
.pushReplacementNamed(ClientViewScreen.route);
|
||||||
InvoiceEditScreen.route,
|
|
||||||
QuoteEditScreen.route,
|
|
||||||
ProjectEditScreen.route,
|
|
||||||
TaskEditScreen.route,
|
|
||||||
ExpenseEditScreen.route,
|
|
||||||
].contains(store.state.uiState.currentRoute)) {
|
|
||||||
Navigator.of(context).pop(savedClient);
|
|
||||||
} else {
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushReplacementNamed(ClientViewScreen.route);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(context).pop(savedClient);
|
Navigator.of(context).pop(savedClient);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue