Fix fab/heo issue

This commit is contained in:
Hillel Coren 2019-09-23 20:24:20 +03:00
parent c8a21d6eaa
commit 00334fa91d
21 changed files with 193 additions and 30 deletions

View File

@ -15,7 +15,6 @@ import 'package:invoiceninja_flutter/redux/task/task_reducer.dart';
import 'package:invoiceninja_flutter/redux/project/project_reducer.dart';
import 'package:invoiceninja_flutter/redux/payment/payment_reducer.dart';
import 'package:invoiceninja_flutter/redux/quote/quote_reducer.dart';
import 'package:sentry/sentry.dart';
// STARTER: import - do not remove comment
UserCompanyState companyReducer(UserCompanyState state, dynamic action) {

View File

@ -62,6 +62,7 @@ class ClientScreen extends StatelessWidget {
),
floatingActionButton: userCompany.canCreate(EntityType.client)
? FloatingActionButton(
heroTag: 'client_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () => store.dispatch(
EditClient(client: ClientEntity(), context: context)),

View File

@ -71,6 +71,7 @@ class _ClientViewState extends State<ClientView>
controller: _controller,
),
floatingActionButton: FloatingActionButton(
heroTag: 'client_view_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
showDialog<SimpleDialog>(

View File

@ -53,7 +53,7 @@ class DocumentScreen extends StatelessWidget {
),
floatingActionButton: userCompany.canCreate(EntityType.document)
? FloatingActionButton(
//key: Key(DocumentKeys.documentScreenFABKeyString),
heroTag: 'document_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
store.dispatch(

View File

@ -79,7 +79,7 @@ class ExpenseScreen extends StatelessWidget {
),
floatingActionButton: userCompany.canCreate(EntityType.expense)
? FloatingActionButton(
//key: Key(ExpenseKeys.expenseScreenFABKeyString),
heroTag: 'expense_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
store.dispatch(EditExpense(

View File

@ -63,6 +63,7 @@ class _ExpenseViewState extends State<ExpenseView>
floatingActionButton: company.isEnterprisePlan
? Builder(builder: (BuildContext context) {
return FloatingActionButton(
heroTag: 'expense_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () async {
final image =

View File

@ -5,9 +5,6 @@ import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_items_vm.dart'
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_notes_vm.dart';
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_vm.dart';
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_item_selector.dart';
import 'package:invoiceninja_flutter/ui/quote/edit/quote_edit_details_vm.dart';
import 'package:invoiceninja_flutter/ui/quote/edit/quote_edit_items_vm.dart';
import 'package:invoiceninja_flutter/ui/quote/edit/quote_edit_notes_vm.dart';
import 'package:invoiceninja_flutter/utils/formatting.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/ui/app/buttons/action_icon_button.dart';
@ -69,12 +66,8 @@ class _InvoiceEditState extends State<InvoiceEdit>
appBar: AppBar(
automaticallyImplyLeading: isMobile(context),
title: Text(invoice.isNew
? invoice.isQuote
? localization.newQuote
: localization.newInvoice
: invoice.isQuote
? localization.editQuote
: localization.editInvoice),
? localization.newInvoice
: localization.editInvoice),
actions: <Widget>[
if (!isMobile(context))
FlatButton(
@ -120,17 +113,11 @@ class _InvoiceEditState extends State<InvoiceEdit>
child: TabBarView(
key: ValueKey(viewModel.invoice.id),
controller: _controller,
children: invoice.isQuote
? <Widget>[
QuoteEditDetailsScreen(),
QuoteEditItemsScreen(),
QuoteEditNotesScreen(),
]
: <Widget>[
InvoiceEditDetailsScreen(),
InvoiceEditItemsScreen(),
InvoiceEditNotesScreen(),
],
children: <Widget>[
InvoiceEditDetailsScreen(),
InvoiceEditItemsScreen(),
InvoiceEditNotesScreen(),
],
),
),
bottomNavigationBar: BottomAppBar(
@ -150,6 +137,7 @@ class _InvoiceEditState extends State<InvoiceEdit>
),
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
floatingActionButton: FloatingActionButton(
heroTag: 'invoice_edit_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
showDialog<InvoiceItemSelector>(

View File

@ -98,6 +98,7 @@ class InvoiceScreen extends StatelessWidget {
),
floatingActionButton: userCompany.canCreate(EntityType.invoice)
? FloatingActionButton(
heroTag: 'invoice_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
store.dispatch(EditInvoice(

View File

@ -53,7 +53,7 @@ class PaymentScreen extends StatelessWidget {
),
floatingActionButton: userCompany.canCreate(EntityType.payment)
? FloatingActionButton(
//key: Key(PaymentKeys.paymentScreenFABKeyString),
heroTag: 'payment_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
store.dispatch(EditPayment(

View File

@ -59,6 +59,7 @@ class ProductScreen extends StatelessWidget {
),
floatingActionButton: userCompany.canCreate(EntityType.product)
? FloatingActionButton(
heroTag: 'product_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
store.dispatch(

View File

@ -58,7 +58,7 @@ class ProjectScreen extends StatelessWidget {
),
floatingActionButton: userCompany.canCreate(EntityType.project)
? FloatingActionButton(
//key: Key(ProjectKeys.projectScreenFABKeyString),
heroTag: 'project_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
store.dispatch(EditProject(

View File

@ -153,6 +153,7 @@ class _ProjectViewState extends State<ProjectView> {
},
),
floatingActionButton: FloatingActionButton(
heroTag: 'project_view_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () => viewModel.onAddTaskPressed(context),
child: Icon(

View File

@ -5,8 +5,8 @@ import 'package:flutter_redux/flutter_redux.dart';
import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart';
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit.dart';
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_vm.dart';
import 'package:invoiceninja_flutter/ui/quote/quote_edit.dart';
import 'package:invoiceninja_flutter/ui/quote/quote_screen.dart';
import 'package:invoiceninja_flutter/ui/quote/view/quote_view_vm.dart';
import 'package:invoiceninja_flutter/utils/platforms.dart';
@ -28,7 +28,7 @@ class QuoteEditScreen extends StatelessWidget {
return QuoteEditVM.fromStore(store);
},
builder: (context, viewModel) {
return InvoiceEdit(
return QuoteEdit(
viewModel: viewModel,
formKey: _formKey,
);

View File

@ -0,0 +1,166 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_vm.dart';
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_item_selector.dart';
import 'package:invoiceninja_flutter/ui/quote/edit/quote_edit_details_vm.dart';
import 'package:invoiceninja_flutter/ui/quote/edit/quote_edit_items_vm.dart';
import 'package:invoiceninja_flutter/ui/quote/edit/quote_edit_notes_vm.dart';
import 'package:invoiceninja_flutter/utils/formatting.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/ui/app/buttons/action_icon_button.dart';
import 'package:invoiceninja_flutter/utils/platforms.dart';
class QuoteEdit extends StatefulWidget {
const QuoteEdit({
Key key,
@required this.formKey,
@required this.viewModel,
}) : super(key: key);
final EntityEditVM viewModel;
final GlobalKey<FormState> formKey;
@override
_QuoteEditState createState() => _QuoteEditState();
}
class _QuoteEditState extends State<QuoteEdit>
with SingleTickerProviderStateMixin {
TabController _controller;
static const kDetailsScreen = 0;
static const kItemScreen = 1;
static const kNotesScreen = 2;
@override
void initState() {
super.initState();
final invoice = widget.viewModel.invoice;
final invoiceItem = widget.viewModel.invoiceItem;
final index = invoice.invoiceItems.contains(invoiceItem)
? kItemScreen
: kDetailsScreen;
_controller = TabController(vsync: this, length: 3, initialIndex: index);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final localization = AppLocalization.of(context);
final viewModel = widget.viewModel;
final invoice = viewModel.invoice;
return WillPopScope(
onWillPop: () async {
viewModel.onBackPressed();
return true;
},
child: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: isMobile(context),
title: Text(
invoice.isNew ? localization.newQuote : localization.editQuote),
actions: <Widget>[
if (!isMobile(context))
FlatButton(
child: Text(
localization.cancel,
style: TextStyle(color: Colors.white),
),
onPressed: () => viewModel.onCancelPressed(context),
),
ActionIconButton(
icon: Icons.cloud_upload,
tooltip: localization.save,
isVisible: !invoice.isDeleted,
isSaving: widget.viewModel.isSaving,
isDirty: invoice.isNew || invoice != viewModel.origInvoice,
onPressed: () {
if (!widget.formKey.currentState.validate()) {
return;
}
widget.viewModel.onSavePressed(context);
},
)
],
bottom: TabBar(
controller: _controller,
//isScrollable: true,
tabs: [
Tab(
text: localization.details,
),
Tab(
text: localization.items,
),
Tab(
text: localization.notes,
),
],
),
),
body: Form(
key: widget.formKey,
child: TabBarView(
key: ValueKey(viewModel.invoice.id),
controller: _controller,
children: <Widget>[
QuoteEditDetailsScreen(),
QuoteEditItemsScreen(),
QuoteEditNotesScreen(),
],
),
),
bottomNavigationBar: BottomAppBar(
color: Theme.of(context).primaryColor,
shape: CircularNotchedRectangle(),
child: Padding(
padding: const EdgeInsets.all(14.0),
child: Text(
'${localization.total}: ${formatNumber(invoice.calculateTotal(viewModel.company.settings.enableInclusiveTaxes), context, clientId: viewModel.invoice.clientId)}',
style: TextStyle(
//color: Theme.of(context).selectedRowColor,
color: Colors.white,
fontSize: 20.0,
),
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
floatingActionButton: FloatingActionButton(
heroTag: 'quote_edit_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
showDialog<InvoiceItemSelector>(
context: context,
builder: (BuildContext context) {
return InvoiceItemSelector(
excluded: invoice.invoiceItems
.where((item) => item.isTask || item.isExpense)
.map((item) => item.isTask
? viewModel.state.taskState.map[item.taskId]
: viewModel.state.expenseState.map[item.expenseId])
.toList(),
clientId: invoice.clientId,
onItemsSelected: (items, [clientId]) {
viewModel.onItemsAdded(items, clientId);
_controller.animateTo(kItemScreen);
},
);
});
},
child: const Icon(Icons.add, color: Colors.white),
tooltip: localization.addItem,
),
),
);
}
}

View File

@ -91,6 +91,7 @@ class QuoteScreen extends StatelessWidget {
),
floatingActionButton: userCompany.canCreate(EntityType.quote)
? FloatingActionButton(
heroTag: 'quote_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
store.dispatch(EditQuote(

View File

@ -137,6 +137,7 @@ class _TaskEditState extends State<TaskEdit>
floatingActionButton: task.isInvoiced || task.isDeleted
? SizedBox()
: FloatingActionButton(
heroTag: 'task_edit_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () => viewModel.onFabPressed(),
child: Icon(

View File

@ -78,7 +78,7 @@ class TaskScreen extends StatelessWidget {
),
floatingActionButton: userCompany.canCreate(EntityType.task)
? FloatingActionButton(
//key: Key(TaskKeys.taskScreenFABKeyString),
heroTag: 'task_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
store.dispatch(EditTask(

View File

@ -219,6 +219,7 @@ class _TaskViewState extends State<TaskView> {
return task.isInvoiced || task.isDeleted
? SizedBox()
: FloatingActionButton(
heroTag: 'task_view_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () => viewModel.onFabPressed(context),
child: Icon(

View File

@ -58,7 +58,7 @@ class VendorScreen extends StatelessWidget {
),
floatingActionButton: userCompany.canCreate(EntityType.vendor)
? FloatingActionButton(
//key: Key(VendorKeys.vendorScreenFABKeyString),
heroTag: 'vendor_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
store.dispatch(

View File

@ -57,6 +57,7 @@ class _VendorViewState extends State<VendorView>
controller: _controller,
),
floatingActionButton: FloatingActionButton(
heroTag: 'vendor_view_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () => viewModel.onAddExpensePressed(context),
child: Icon(

View File

@ -60,7 +60,7 @@ class StubScreen extends StatelessWidget {
),
floatingActionButton: user.canCreate(EntityType.stub)
? FloatingActionButton(
//key: Key(StubKeys.stubScreenFABKeyString),
heroTag: 'stub_fab',
backgroundColor: Theme.of(context).primaryColorDark,
onPressed: () {
store.dispatch(