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