|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import 'package:file_picker/file_picker.dart'; |
|
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_material_design_icons/flutter_material_design_icons.dart'; |
|
|
|
|
import 'package:meta/meta.dart'; |
|
|
|
@ -10,14 +11,14 @@ import 'package:neon/src/router.dart';
|
|
|
|
|
import 'package:neon/src/settings/utils/settings_export_helper.dart'; |
|
|
|
|
import 'package:neon/src/settings/widgets/account_settings_tile.dart'; |
|
|
|
|
import 'package:neon/src/settings/widgets/custom_settings_tile.dart'; |
|
|
|
|
import 'package:neon/src/settings/widgets/select_settings_tile.dart'; |
|
|
|
|
import 'package:neon/src/settings/widgets/option_settings_tile.dart'; |
|
|
|
|
import 'package:neon/src/settings/widgets/settings_category.dart'; |
|
|
|
|
import 'package:neon/src/settings/widgets/settings_list.dart'; |
|
|
|
|
import 'package:neon/src/settings/widgets/settings_tile.dart'; |
|
|
|
|
import 'package:neon/src/settings/widgets/text_settings_tile.dart'; |
|
|
|
|
import 'package:neon/src/settings/widgets/toggle_settings_tile.dart'; |
|
|
|
|
import 'package:neon/src/theme/branding.dart'; |
|
|
|
|
import 'package:neon/src/theme/dialog.dart'; |
|
|
|
|
import 'package:neon/src/utils/adaptive.dart'; |
|
|
|
|
import 'package:neon/src/utils/confirmation_dialog.dart'; |
|
|
|
|
import 'package:neon/src/utils/global_options.dart'; |
|
|
|
|
import 'package:neon/src/utils/provider.dart'; |
|
|
|
@ -112,24 +113,11 @@ class _SettingsPageState extends State<SettingsPage> {
|
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
final body = StreamBuilder( |
|
|
|
|
stream: accountsBloc.accounts, |
|
|
|
|
initialData: accountsBloc.accounts.valueOrNull, |
|
|
|
|
builder: ( |
|
|
|
|
final context, |
|
|
|
|
final accountsSnapshot, |
|
|
|
|
) => |
|
|
|
|
ValueListenableBuilder( |
|
|
|
|
valueListenable: globalOptions.pushNotificationsEnabled, |
|
|
|
|
builder: ( |
|
|
|
|
final context, |
|
|
|
|
final _, |
|
|
|
|
final __, |
|
|
|
|
) => |
|
|
|
|
SettingsList( |
|
|
|
|
final body = SettingsList( |
|
|
|
|
initialCategory: widget.initialCategory?.name, |
|
|
|
|
categories: [ |
|
|
|
|
SettingsCategory( |
|
|
|
|
hasLeading: true, |
|
|
|
|
title: Text(NeonLocalizations.of(context).settingsApps), |
|
|
|
|
key: ValueKey(SettingsCategories.apps.name), |
|
|
|
|
tiles: <SettingsTile>[ |
|
|
|
@ -170,30 +158,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
if (NeonPlatform.instance.canUsePushNotifications) ...[ |
|
|
|
|
SettingsCategory( |
|
|
|
|
title: Text(NeonLocalizations.of(context).optionsCategoryPushNotifications), |
|
|
|
|
key: ValueKey(SettingsCategories.pushNotifications.name), |
|
|
|
|
tiles: [ |
|
|
|
|
if (!globalOptions.pushNotificationsEnabled.enabled) ...[ |
|
|
|
|
TextSettingsTile( |
|
|
|
|
text: NeonLocalizations.of(context).globalOptionsPushNotificationsEnabledDisabledNotice, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
|
fontStyle: FontStyle.italic, |
|
|
|
|
color: Theme.of(context).colorScheme.error, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
ToggleSettingsTile( |
|
|
|
|
option: globalOptions.pushNotificationsEnabled, |
|
|
|
|
), |
|
|
|
|
SelectSettingsTile( |
|
|
|
|
option: globalOptions.pushNotificationsDistributor, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
if (NeonPlatform.instance.canUsePushNotifications) buildNotificationsCategory(), |
|
|
|
|
if (NeonPlatform.instance.canUseWindowManager) ...[ |
|
|
|
|
SettingsCategory( |
|
|
|
|
title: Text(NeonLocalizations.of(context).optionsCategoryStartup), |
|
|
|
@ -222,39 +187,12 @@ class _SettingsPageState extends State<SettingsPage> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
...buildAccountCategory(), |
|
|
|
|
SettingsCategory( |
|
|
|
|
title: Text(NeonLocalizations.of(context).optionsCategoryAccounts), |
|
|
|
|
key: ValueKey(SettingsCategories.accounts.name), |
|
|
|
|
tiles: [ |
|
|
|
|
if (accountsSnapshot.requireData.length > 1) ...[ |
|
|
|
|
ToggleSettingsTile( |
|
|
|
|
option: globalOptions.rememberLastUsedAccount, |
|
|
|
|
), |
|
|
|
|
SelectSettingsTile( |
|
|
|
|
option: globalOptions.initialAccount, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
for (final account in accountsSnapshot.requireData) ...[ |
|
|
|
|
AccountSettingsTile( |
|
|
|
|
account: account, |
|
|
|
|
onTap: () { |
|
|
|
|
AccountSettingsRoute(accountID: account.id).go(context); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
CustomSettingsTile( |
|
|
|
|
title: ElevatedButton.icon( |
|
|
|
|
onPressed: () async => const LoginRoute().push(context), |
|
|
|
|
icon: const Icon(MdiIcons.accountPlus), |
|
|
|
|
label: Text(NeonLocalizations.of(context).globalOptionsAccountsAdd), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
SettingsCategory( |
|
|
|
|
hasLeading: true, |
|
|
|
|
title: Text(NeonLocalizations.of(context).optionsCategoryOther), |
|
|
|
|
key: ValueKey(SettingsCategories.other.name), |
|
|
|
|
tiles: <SettingsTile>[ |
|
|
|
|
tiles: [ |
|
|
|
|
if (branding.sourceCodeURL != null) |
|
|
|
|
CustomSettingsTile( |
|
|
|
|
leading: Icon( |
|
|
|
@ -363,8 +301,6 @@ class _SettingsPageState extends State<SettingsPage> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return Scaffold( |
|
|
|
@ -381,6 +317,105 @@ class _SettingsPageState extends State<SettingsPage> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget buildNotificationsCategory() { |
|
|
|
|
final globalOptions = NeonProvider.of<GlobalOptions>(context); |
|
|
|
|
|
|
|
|
|
return ValueListenableBuilder( |
|
|
|
|
valueListenable: globalOptions.pushNotificationsEnabled, |
|
|
|
|
builder: (final context, final _, final __) => SettingsCategory( |
|
|
|
|
title: Text(NeonLocalizations.of(context).optionsCategoryPushNotifications), |
|
|
|
|
key: ValueKey(SettingsCategories.pushNotifications.name), |
|
|
|
|
tiles: [ |
|
|
|
|
if (!globalOptions.pushNotificationsEnabled.enabled) |
|
|
|
|
TextSettingsTile( |
|
|
|
|
text: NeonLocalizations.of(context).globalOptionsPushNotificationsEnabledDisabledNotice, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
|
fontStyle: FontStyle.italic, |
|
|
|
|
color: Theme.of(context).colorScheme.error, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
ToggleSettingsTile( |
|
|
|
|
option: globalOptions.pushNotificationsEnabled, |
|
|
|
|
), |
|
|
|
|
SelectSettingsTile( |
|
|
|
|
option: globalOptions.pushNotificationsDistributor, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Iterable<Widget> buildAccountCategory() sync* { |
|
|
|
|
final globalOptions = NeonProvider.of<GlobalOptions>(context); |
|
|
|
|
final accountsBloc = NeonProvider.of<AccountsBloc>(context); |
|
|
|
|
final accounts = accountsBloc.accounts.value; |
|
|
|
|
final hasMultipleAccounts = accounts.length > 1; |
|
|
|
|
|
|
|
|
|
final title = Text(NeonLocalizations.of(context).optionsCategoryAccounts); |
|
|
|
|
final key = ValueKey(SettingsCategories.accounts.name); |
|
|
|
|
final accountTiles = accounts.map( |
|
|
|
|
(final account) => AccountSettingsTile( |
|
|
|
|
account: account, |
|
|
|
|
onTap: () => AccountSettingsRoute(accountID: account.id).go(context), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
final rememberLastUsedAccountTile = ToggleSettingsTile( |
|
|
|
|
option: globalOptions.rememberLastUsedAccount, |
|
|
|
|
); |
|
|
|
|
final initialAccountTile = SelectSettingsTile( |
|
|
|
|
option: globalOptions.initialAccount, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (isCupertino(context)) { |
|
|
|
|
if (hasMultipleAccounts) { |
|
|
|
|
yield SettingsCategory( |
|
|
|
|
title: title, |
|
|
|
|
key: key, |
|
|
|
|
tiles: [ |
|
|
|
|
rememberLastUsedAccountTile, |
|
|
|
|
initialAccountTile, |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
final addAccountTile = CustomSettingsTile( |
|
|
|
|
leading: const Icon( |
|
|
|
|
CupertinoIcons.add, |
|
|
|
|
), |
|
|
|
|
title: Text(NeonLocalizations.of(context).globalOptionsAccountsAdd), |
|
|
|
|
onTap: () async => const LoginRoute().push(context), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
yield CupertinoListSection.insetGrouped( |
|
|
|
|
header: !hasMultipleAccounts ? title : null, |
|
|
|
|
key: !hasMultipleAccounts ? key : null, |
|
|
|
|
children: [ |
|
|
|
|
...accountTiles, |
|
|
|
|
addAccountTile, |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
final addAccountTile = CustomSettingsTile( |
|
|
|
|
title: ElevatedButton.icon( |
|
|
|
|
onPressed: () async => const LoginRoute().push(context), |
|
|
|
|
icon: const Icon(MdiIcons.accountPlus), |
|
|
|
|
label: Text(NeonLocalizations.of(context).globalOptionsAccountsAdd), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
yield SettingsCategory( |
|
|
|
|
title: title, |
|
|
|
|
key: key, |
|
|
|
|
tiles: [ |
|
|
|
|
if (hasMultipleAccounts) rememberLastUsedAccountTile, |
|
|
|
|
if (hasMultipleAccounts) initialAccountTile, |
|
|
|
|
...accountTiles, |
|
|
|
|
addAccountTile, |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SettingsExportHelper _buildSettingsExportHelper(final BuildContext context) { |
|
|
|
|
final globalOptions = NeonProvider.of<GlobalOptions>(context); |
|
|
|
|
final accountsBloc = NeonProvider.of<AccountsBloc>(context); |
|
|
|
|