diff --git a/lib/constants.dart b/lib/constants.dart index ecc654bda..f0122f97f 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -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'; diff --git a/lib/main_app.dart b/lib/main_app.dart index 4a106679a..561504fc3 100644 --- a/lib/main_app.dart +++ b/lib/main_app.dart @@ -508,8 +508,6 @@ class InvoiceNinjaAppState extends State { ExpenseSettingsScreen(), TaskSettingsScreen.route: (context) => TaskSettingsScreen(), - IntegrationSettingsScreen.route: (context) => - IntegrationSettingsScreen(), ImportExportScreen.route: (context) => ImportExportScreen(), DeviceSettingsScreen.route: (context) => diff --git a/lib/ui/app/main_screen.dart b/lib/ui/app/main_screen.dart index fe118f0c0..e80964041 100644 --- a/lib/ui/app/main_screen.dart +++ b/lib/ui/app/main_screen.dart @@ -744,9 +744,6 @@ class SettingsScreens extends StatelessWidget { case kSettingsExpenses: screen = ExpenseSettingsScreen(); break; - case kSettingsIntegrations: - screen = IntegrationSettingsScreen(); - break; case kSettingsImportExport: screen = ImportExportScreen(); break; diff --git a/lib/ui/app/screen_imports.dart b/lib/ui/app/screen_imports.dart index 8443f9438..a70905d24 100644 --- a/lib/ui/app/screen_imports.dart +++ b/lib/ui/app/screen_imports.dart @@ -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'; diff --git a/lib/ui/settings/integrations.dart b/lib/ui/settings/integrations.dart deleted file mode 100644 index 350f20693..000000000 --- a/lib/ui/settings/integrations.dart +++ /dev/null @@ -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 { - //static final GlobalKey _formKey = GlobalKey(debugLabel: '_notifications'); - - bool autoValidate = false; - - final _googleAnalyticsController = TextEditingController(); - final _slackWebhookController = TextEditingController(); - - List _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: [ - FormCard( - children: [ - 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, - ), - ), - ], - ) - ], - ), - ); - } -} diff --git a/lib/ui/settings/integrations_vm.dart b/lib/ui/settings/integrations_vm.dart deleted file mode 100644 index fc8de73a5..000000000 --- a/lib/ui/settings/integrations_vm.dart +++ /dev/null @@ -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( - 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 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( - context, AppLocalization.of(context).savedSettings); - store.dispatch(SaveCompanyRequest( - completer: completer, company: settingsUIState.company)); - }); - }); - } - - final AppState state; - final Function(BuildContext) onSavePressed; - final Function(CompanyEntity) onCompanyChanged; -} diff --git a/lib/utils/icons.dart b/lib/utils/icons.dart index f3c8157ad..9b4a1b761 100644 --- a/lib/utils/icons.dart +++ b/lib/utils/icons.dart @@ -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: