Integrations
This commit is contained in:
parent
4fc9da1b78
commit
1f04d9e47d
|
|
@ -358,7 +358,6 @@ const String kSettingsTaxSettings = 'tax_settings';
|
|||
const String kSettingsTaxRates = 'tax_settings_rates';
|
||||
const String kSettingsTaxRatesView = 'tax_settings_rates_view';
|
||||
const String kSettingsTaxRatesEdit = 'tax_settings_rates_edit';
|
||||
const String kSettingsIntegrations = 'integrations';
|
||||
const String kSettingsProducts = 'product_settings';
|
||||
const String kSettingsTasks = 'task_settings';
|
||||
const String kSettingsExpenses = 'expense_settings';
|
||||
|
|
|
|||
|
|
@ -508,8 +508,6 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
|||
ExpenseSettingsScreen(),
|
||||
TaskSettingsScreen.route: (context) =>
|
||||
TaskSettingsScreen(),
|
||||
IntegrationSettingsScreen.route: (context) =>
|
||||
IntegrationSettingsScreen(),
|
||||
ImportExportScreen.route: (context) =>
|
||||
ImportExportScreen(),
|
||||
DeviceSettingsScreen.route: (context) =>
|
||||
|
|
|
|||
|
|
@ -744,9 +744,6 @@ class SettingsScreens extends StatelessWidget {
|
|||
case kSettingsExpenses:
|
||||
screen = ExpenseSettingsScreen();
|
||||
break;
|
||||
case kSettingsIntegrations:
|
||||
screen = IntegrationSettingsScreen();
|
||||
break;
|
||||
case kSettingsImportExport:
|
||||
screen = ImportExportScreen();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ export 'package:invoiceninja_flutter/ui/settings/import_export_vm.dart';
|
|||
export 'package:invoiceninja_flutter/ui/settings/invoice_design_vm.dart';
|
||||
export 'package:invoiceninja_flutter/ui/settings/custom_fields_vm.dart';
|
||||
export 'package:invoiceninja_flutter/ui/settings/localization_vm.dart';
|
||||
export 'package:invoiceninja_flutter/ui/settings/integrations_vm.dart';
|
||||
export 'package:invoiceninja_flutter/ui/settings/product_settings_vm.dart';
|
||||
export 'package:invoiceninja_flutter/ui/settings/templates_and_reminders_vm.dart';
|
||||
export 'package:invoiceninja_flutter/ui/settings/user_details_vm.dart';
|
||||
|
|
|
|||
|
|
@ -1,111 +0,0 @@
|
|||
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/decorated_form_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/learn_more.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/scrollable_listview.dart';
|
||||
import 'package:invoiceninja_flutter/ui/settings/integrations_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
||||
class IntegrationSettings extends StatefulWidget {
|
||||
const IntegrationSettings({
|
||||
Key key,
|
||||
@required this.viewModel,
|
||||
}) : super(key: key);
|
||||
|
||||
final IntegrationSettingsVM viewModel;
|
||||
|
||||
@override
|
||||
_IntegrationSettingsState createState() => _IntegrationSettingsState();
|
||||
}
|
||||
|
||||
class _IntegrationSettingsState extends State<IntegrationSettings> {
|
||||
//static final GlobalKey<FormState> _formKey = GlobalKey<FormState>(debugLabel: '_notifications');
|
||||
|
||||
bool autoValidate = false;
|
||||
|
||||
final _googleAnalyticsController = TextEditingController();
|
||||
final _slackWebhookController = TextEditingController();
|
||||
|
||||
List<TextEditingController> _controllers = [];
|
||||
final _debouncer = Debouncer();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controllers.forEach((dynamic controller) {
|
||||
controller.removeListener(_onChanged);
|
||||
controller.dispose();
|
||||
});
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
_controllers = [
|
||||
_googleAnalyticsController,
|
||||
_slackWebhookController,
|
||||
];
|
||||
|
||||
_controllers
|
||||
.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
||||
|
||||
final company = widget.viewModel.state.company;
|
||||
_googleAnalyticsController.text = company.googleAnalyticsKey;
|
||||
_slackWebhookController.text = company.slackWebhookUrl;
|
||||
|
||||
_controllers
|
||||
.forEach((dynamic controller) => controller.addListener(_onChanged));
|
||||
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
void _onChanged() {
|
||||
_debouncer.run(() {
|
||||
final state = widget.viewModel.state;
|
||||
final company = state.company.rebuild((b) => b
|
||||
..slackWebhookUrl = _slackWebhookController.text.trim()
|
||||
..googleAnalyticsKey = _googleAnalyticsController.text.trim());
|
||||
if (state.company != company) {
|
||||
widget.viewModel.onCompanyChanged(company);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
//final viewModel = widget.viewModel;
|
||||
|
||||
return EditScaffold(
|
||||
title: localization.integrations,
|
||||
onSavePressed: widget.viewModel.onSavePressed,
|
||||
body: ScrollableListView(
|
||||
children: <Widget>[
|
||||
FormCard(
|
||||
children: <Widget>[
|
||||
LearnMoreUrl(
|
||||
url: 'https://my.slack.com/services/new/incoming-webhook/',
|
||||
child: DecoratedFormField(
|
||||
label: 'Slack',
|
||||
keyboardType: TextInputType.url,
|
||||
hint: localization.slackWebhookUrl,
|
||||
controller: _slackWebhookController,
|
||||
),
|
||||
),
|
||||
LearnMoreUrl(
|
||||
url: 'https://support.google.com/analytics/answer/1037249',
|
||||
child: DecoratedFormField(
|
||||
label: 'Google Analytics',
|
||||
hint: localization.trackingId,
|
||||
controller: _googleAnalyticsController,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
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/integrations.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 IntegrationSettingsScreen extends StatelessWidget {
|
||||
const IntegrationSettingsScreen({Key key}) : super(key: key);
|
||||
static const String route = '/$kSettings/$kSettingsIntegrations';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StoreConnector<AppState, IntegrationSettingsVM>(
|
||||
converter: IntegrationSettingsVM.fromStore,
|
||||
builder: (context, viewModel) {
|
||||
return IntegrationSettings(
|
||||
viewModel: viewModel,
|
||||
key: ValueKey(viewModel.state.settingsUIState.updatedAt),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class IntegrationSettingsVM {
|
||||
IntegrationSettingsVM({
|
||||
@required this.state,
|
||||
@required this.onCompanyChanged,
|
||||
@required this.onSavePressed,
|
||||
});
|
||||
|
||||
static IntegrationSettingsVM fromStore(Store<AppState> store) {
|
||||
final state = store.state;
|
||||
|
||||
return IntegrationSettingsVM(
|
||||
state: state,
|
||||
onCompanyChanged: (company) =>
|
||||
store.dispatch(UpdateCompany(company: company)),
|
||||
onSavePressed: (context) {
|
||||
Debouncer.runOnComplete(() {
|
||||
final settingsUIState = store.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 Function(CompanyEntity) onCompanyChanged;
|
||||
}
|
||||
|
|
@ -165,8 +165,6 @@ IconData getSettingIcon(String section) {
|
|||
case kSettingsTaxSettings:
|
||||
case kSettingsTaxRates:
|
||||
return MdiIcons.percent;
|
||||
case kSettingsIntegrations:
|
||||
return MdiIcons.link;
|
||||
case kSettingsImportExport:
|
||||
return Icons.import_export;
|
||||
case kSettingsDeviceSettings:
|
||||
|
|
|
|||
Loading…
Reference in New Issue