Expenses
This commit is contained in:
parent
09aaf823d8
commit
c7335a8dbb
|
|
@ -36,6 +36,7 @@ import 'package:invoiceninja_flutter/ui/payment_term/view/payment_term_view_vm.d
|
||||||
import 'package:invoiceninja_flutter/ui/reports/reports_screen.dart';
|
import 'package:invoiceninja_flutter/ui/reports/reports_screen.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/reports/reports_screen_vm.dart';
|
import 'package:invoiceninja_flutter/ui/reports/reports_screen_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/account_management_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/account_management_vm.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/settings/expense_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/settings_screen_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/settings_screen_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/tax_settings_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/tax_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/tax_rate/edit/tax_rate_edit_vm.dart';
|
import 'package:invoiceninja_flutter/ui/tax_rate/edit/tax_rate_edit_vm.dart';
|
||||||
|
|
@ -335,6 +336,8 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
TaxRateEditScreen.route: (context) => TaxRateEditScreen(),
|
TaxRateEditScreen.route: (context) => TaxRateEditScreen(),
|
||||||
ProductSettingsScreen.route: (context) =>
|
ProductSettingsScreen.route: (context) =>
|
||||||
ProductSettingsScreen(),
|
ProductSettingsScreen(),
|
||||||
|
ExpenseSettingsScreen.route: (context) =>
|
||||||
|
ExpenseSettingsScreen(),
|
||||||
IntegrationSettingsScreen.route: (context) =>
|
IntegrationSettingsScreen.route: (context) =>
|
||||||
IntegrationSettingsScreen(),
|
IntegrationSettingsScreen(),
|
||||||
ImportExportScreen.route: (context) => ImportExportScreen(),
|
ImportExportScreen.route: (context) => ImportExportScreen(),
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import 'package:invoiceninja_flutter/ui/recurring_invoice/view/recurring_invoice
|
||||||
import 'package:invoiceninja_flutter/ui/reports/reports_screen.dart';
|
import 'package:invoiceninja_flutter/ui/reports/reports_screen.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/reports/reports_screen_vm.dart';
|
import 'package:invoiceninja_flutter/ui/reports/reports_screen_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/account_management_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/account_management_vm.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/settings/expense_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/settings_screen_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/settings_screen_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/settings/tax_settings_vm.dart';
|
import 'package:invoiceninja_flutter/ui/settings/tax_settings_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/token/edit/token_edit_vm.dart';
|
import 'package:invoiceninja_flutter/ui/token/edit/token_edit_vm.dart';
|
||||||
|
|
@ -402,6 +403,9 @@ class SettingsScreens extends StatelessWidget {
|
||||||
case kSettingsProducts:
|
case kSettingsProducts:
|
||||||
screen = ProductSettingsScreen();
|
screen = ProductSettingsScreen();
|
||||||
break;
|
break;
|
||||||
|
case kSettingsExpenses:
|
||||||
|
screen = ExpenseSettingsScreen();
|
||||||
|
break;
|
||||||
case kSettingsIntegrations:
|
case kSettingsIntegrations:
|
||||||
screen = IntegrationSettingsScreen();
|
screen = IntegrationSettingsScreen();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/forms/app_form.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/settings/expense_settings_vm.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
|
||||||
|
class ExpenseSettings extends StatefulWidget {
|
||||||
|
const ExpenseSettings({
|
||||||
|
Key key,
|
||||||
|
@required this.viewModel,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final ExpenseSettingsVM viewModel;
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ExpenseSettingsState createState() => _ExpenseSettingsState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ExpenseSettingsState extends State<ExpenseSettings> {
|
||||||
|
static final GlobalKey<FormState> _formKey =
|
||||||
|
GlobalKey<FormState>(debugLabel: '_expenseSettings');
|
||||||
|
FocusScopeNode _focusNode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_focusNode = FocusScopeNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_focusNode.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final localization = AppLocalization.of(context);
|
||||||
|
final viewModel = widget.viewModel;
|
||||||
|
final company = viewModel.company;
|
||||||
|
|
||||||
|
return EditScaffold(
|
||||||
|
title: localization.expenseSettings,
|
||||||
|
onSavePressed: viewModel.onSavePressed,
|
||||||
|
body: AppForm(
|
||||||
|
formKey: _formKey,
|
||||||
|
focusNode: _focusNode,
|
||||||
|
children: <Widget>[
|
||||||
|
FormCard(
|
||||||
|
children: <Widget>[
|
||||||
|
/*
|
||||||
|
SwitchListTile(
|
||||||
|
activeColor: Theme.of(context).accentColor,
|
||||||
|
title: Text(localization.showCost),
|
||||||
|
value: company.enableExpenseCost ?? false,
|
||||||
|
subtitle: Text(localization.showCostHelp),
|
||||||
|
onChanged: (value) => viewModel.onCompanyChanged(
|
||||||
|
company.rebuild((b) => b..enableExpenseCost = value)),
|
||||||
|
),
|
||||||
|
|
||||||
|
*/
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
|
import 'package:invoiceninja_flutter/data/models/company_model.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/settings/expense_settings.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
import 'package:redux/redux.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
|
||||||
|
class ExpenseSettingsScreen extends StatelessWidget {
|
||||||
|
const ExpenseSettingsScreen({Key key}) : super(key: key);
|
||||||
|
static const String route = '/$kSettings/$kSettingsExpenses';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return StoreConnector<AppState, ExpenseSettingsVM>(
|
||||||
|
converter: ExpenseSettingsVM.fromStore,
|
||||||
|
builder: (context, viewModel) {
|
||||||
|
return ExpenseSettings(
|
||||||
|
viewModel: viewModel,
|
||||||
|
key: ValueKey(viewModel.state.settingsUIState.updatedAt),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExpenseSettingsVM {
|
||||||
|
ExpenseSettingsVM({
|
||||||
|
@required this.state,
|
||||||
|
@required this.company,
|
||||||
|
@required this.onCompanyChanged,
|
||||||
|
@required this.onSavePressed,
|
||||||
|
});
|
||||||
|
|
||||||
|
static ExpenseSettingsVM fromStore(Store<AppState> store) {
|
||||||
|
final state = store.state;
|
||||||
|
|
||||||
|
return ExpenseSettingsVM(
|
||||||
|
state: state,
|
||||||
|
company: state.uiState.settingsUIState.company,
|
||||||
|
onCompanyChanged: (company) =>
|
||||||
|
store.dispatch(UpdateCompany(company: company)),
|
||||||
|
onSavePressed: (context) {
|
||||||
|
final settingsUIState = state.uiState.settingsUIState;
|
||||||
|
final completer = snackBarCompleter<Null>(
|
||||||
|
context, AppLocalization.of(context).savedSettings);
|
||||||
|
store.dispatch(SaveCompanyRequest(
|
||||||
|
completer: completer, company: settingsUIState.company));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
final AppState state;
|
||||||
|
final Function(BuildContext) onSavePressed;
|
||||||
|
final CompanyEntity company;
|
||||||
|
final Function(CompanyEntity) onCompanyChanged;
|
||||||
|
}
|
||||||
|
|
@ -100,7 +100,7 @@ class SettingsList extends StatelessWidget {
|
||||||
section: kSettingsProducts,
|
section: kSettingsProducts,
|
||||||
viewModel: viewModel,
|
viewModel: viewModel,
|
||||||
),
|
),
|
||||||
if (showAll)
|
if (showAll && state.company.isModuleEnabled(EntityType.expense))
|
||||||
SettingsListTile(
|
SettingsListTile(
|
||||||
section: kSettingsExpenses,
|
section: kSettingsExpenses,
|
||||||
viewModel: viewModel,
|
viewModel: viewModel,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue