|
|
@ -19,6 +19,7 @@ import 'package:neon/src/settings/widgets/settings_list.dart'; |
|
|
|
import 'package:neon/src/settings/widgets/settings_tile.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/text_settings_tile.dart'; |
|
|
|
import 'package:neon/src/theme/branding.dart'; |
|
|
|
import 'package:neon/src/theme/branding.dart'; |
|
|
|
|
|
|
|
import 'package:neon/src/theme/dialog.dart'; |
|
|
|
import 'package:neon/src/utils/confirmation_dialog.dart'; |
|
|
|
import 'package:neon/src/utils/confirmation_dialog.dart'; |
|
|
|
import 'package:neon/src/utils/global_options.dart'; |
|
|
|
import 'package:neon/src/utils/global_options.dart'; |
|
|
|
import 'package:neon/src/utils/save_file.dart'; |
|
|
|
import 'package:neon/src/utils/save_file.dart'; |
|
|
@ -57,263 +58,271 @@ class _SettingsPageState extends State<SettingsPage> { |
|
|
|
final accountsBloc = Provider.of<AccountsBloc>(context, listen: false); |
|
|
|
final accountsBloc = Provider.of<AccountsBloc>(context, listen: false); |
|
|
|
final appImplementations = Provider.of<Iterable<AppImplementation>>(context); |
|
|
|
final appImplementations = Provider.of<Iterable<AppImplementation>>(context); |
|
|
|
|
|
|
|
|
|
|
|
return Scaffold( |
|
|
|
final appBar = AppBar( |
|
|
|
resizeToAvoidBottomInset: false, |
|
|
|
title: Text(AppLocalizations.of(context).settings), |
|
|
|
appBar: AppBar( |
|
|
|
actions: [ |
|
|
|
title: Text(AppLocalizations.of(context).settings), |
|
|
|
IconButton( |
|
|
|
actions: [ |
|
|
|
onPressed: () async { |
|
|
|
IconButton( |
|
|
|
if (await showConfirmationDialog(context, AppLocalizations.of(context).settingsResetAllConfirmation)) { |
|
|
|
onPressed: () async { |
|
|
|
await globalOptions.reset(); |
|
|
|
if (await showConfirmationDialog(context, AppLocalizations.of(context).settingsResetAllConfirmation)) { |
|
|
|
|
|
|
|
await globalOptions.reset(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (final appImplementation in appImplementations) { |
|
|
|
for (final appImplementation in appImplementations) { |
|
|
|
await appImplementation.options.reset(); |
|
|
|
await appImplementation.options.reset(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (final account in accountsBloc.accounts.value) { |
|
|
|
for (final account in accountsBloc.accounts.value) { |
|
|
|
await accountsBloc.getOptionsFor(account).reset(); |
|
|
|
await accountsBloc.getOptionsFor(account).reset(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
tooltip: AppLocalizations.of(context).settingsResetAll, |
|
|
|
}, |
|
|
|
icon: Icon(MdiIcons.cogRefresh), |
|
|
|
tooltip: AppLocalizations.of(context).settingsResetAll, |
|
|
|
), |
|
|
|
icon: Icon(MdiIcons.cogRefresh), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
body: StreamBuilder<List<Account>>( |
|
|
|
); |
|
|
|
stream: accountsBloc.accounts, |
|
|
|
final body = StreamBuilder<List<Account>>( |
|
|
|
initialData: accountsBloc.accounts.valueOrNull, |
|
|
|
stream: accountsBloc.accounts, |
|
|
|
builder: ( |
|
|
|
initialData: accountsBloc.accounts.valueOrNull, |
|
|
|
final context, |
|
|
|
builder: ( |
|
|
|
final accountsSnapshot, |
|
|
|
final context, |
|
|
|
) { |
|
|
|
final accountsSnapshot, |
|
|
|
final platform = Provider.of<NeonPlatform>(context, listen: false); |
|
|
|
) { |
|
|
|
return StreamBuilder<bool>( |
|
|
|
final platform = Provider.of<NeonPlatform>(context, listen: false); |
|
|
|
stream: globalOptions.pushNotificationsEnabled.enabled, |
|
|
|
return StreamBuilder<bool>( |
|
|
|
initialData: globalOptions.pushNotificationsEnabled.enabled.valueOrNull, |
|
|
|
stream: globalOptions.pushNotificationsEnabled.enabled, |
|
|
|
builder: ( |
|
|
|
initialData: globalOptions.pushNotificationsEnabled.enabled.valueOrNull, |
|
|
|
final context, |
|
|
|
builder: ( |
|
|
|
final pushNotificationsEnabledEnabledSnapshot, |
|
|
|
final context, |
|
|
|
) => |
|
|
|
final pushNotificationsEnabledEnabledSnapshot, |
|
|
|
SettingsList( |
|
|
|
) => |
|
|
|
initialCategory: widget.initialCategory?.name, |
|
|
|
SettingsList( |
|
|
|
categories: [ |
|
|
|
initialCategory: widget.initialCategory?.name, |
|
|
|
|
|
|
|
categories: [ |
|
|
|
|
|
|
|
SettingsCategory( |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).settingsApps), |
|
|
|
|
|
|
|
key: ValueKey(SettingsCageories.apps.name), |
|
|
|
|
|
|
|
tiles: <SettingsTile>[ |
|
|
|
|
|
|
|
for (final appImplementation in appImplementations) ...[ |
|
|
|
|
|
|
|
if (appImplementation.options.options.isNotEmpty) ...[ |
|
|
|
|
|
|
|
CustomSettingsTile( |
|
|
|
|
|
|
|
leading: appImplementation.buildIcon(), |
|
|
|
|
|
|
|
title: Text(appImplementation.name(context)), |
|
|
|
|
|
|
|
onTap: () { |
|
|
|
|
|
|
|
NextcloudAppSettingsRoute(appid: appImplementation.id).go(context); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
SettingsCategory( |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryTheme), |
|
|
|
|
|
|
|
key: ValueKey(SettingsCageories.theme.name), |
|
|
|
|
|
|
|
tiles: [ |
|
|
|
|
|
|
|
DropdownButtonSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.themeMode, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.themeOLEDAsDark, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.themeKeepOriginalAccentColor, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
SettingsCategory( |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryNavigation), |
|
|
|
|
|
|
|
key: ValueKey(SettingsCageories.navigation.name), |
|
|
|
|
|
|
|
tiles: [ |
|
|
|
|
|
|
|
DropdownButtonSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.navigationMode, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
if (platform.canUsePushNotifications) ...[ |
|
|
|
SettingsCategory( |
|
|
|
SettingsCategory( |
|
|
|
title: Text(AppLocalizations.of(context).settingsApps), |
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryPushNotifications), |
|
|
|
key: ValueKey(SettingsCageories.apps.name), |
|
|
|
key: ValueKey(SettingsCageories.pushNotifications.name), |
|
|
|
tiles: <SettingsTile>[ |
|
|
|
tiles: [ |
|
|
|
for (final appImplementation in appImplementations) ...[ |
|
|
|
if (pushNotificationsEnabledEnabledSnapshot.hasData && |
|
|
|
if (appImplementation.options.options.isNotEmpty) ...[ |
|
|
|
!pushNotificationsEnabledEnabledSnapshot.requireData) ...[ |
|
|
|
CustomSettingsTile( |
|
|
|
TextSettingsTile( |
|
|
|
leading: appImplementation.buildIcon(), |
|
|
|
text: AppLocalizations.of(context).globalOptionsPushNotificationsEnabledDisabledNotice, |
|
|
|
title: Text(appImplementation.name(context)), |
|
|
|
style: TextStyle( |
|
|
|
onTap: () { |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
NextcloudAppSettingsRoute(appid: appImplementation.id).go(context); |
|
|
|
fontStyle: FontStyle.italic, |
|
|
|
}, |
|
|
|
color: Theme.of(context).colorScheme.error, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.pushNotificationsEnabled, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
DropdownButtonSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.pushNotificationsDistributor, |
|
|
|
|
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
if (platform.canUseWindowManager) ...[ |
|
|
|
SettingsCategory( |
|
|
|
SettingsCategory( |
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryTheme), |
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryStartup), |
|
|
|
key: ValueKey(SettingsCageories.theme.name), |
|
|
|
key: ValueKey(SettingsCageories.startup.name), |
|
|
|
tiles: [ |
|
|
|
tiles: [ |
|
|
|
DropdownButtonSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.themeMode, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
CheckBoxSettingsTile( |
|
|
|
option: globalOptions.themeOLEDAsDark, |
|
|
|
option: globalOptions.startupMinimized, |
|
|
|
), |
|
|
|
), |
|
|
|
CheckBoxSettingsTile( |
|
|
|
CheckBoxSettingsTile( |
|
|
|
option: globalOptions.themeKeepOriginalAccentColor, |
|
|
|
option: globalOptions.startupMinimizeInsteadOfExit, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
if (platform.canUseWindowManager && platform.canUseSystemTray) ...[ |
|
|
|
SettingsCategory( |
|
|
|
SettingsCategory( |
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryNavigation), |
|
|
|
title: Text(AppLocalizations.of(context).optionsCategorySystemTray), |
|
|
|
key: ValueKey(SettingsCageories.navigation.name), |
|
|
|
key: ValueKey(SettingsCageories.systemTray.name), |
|
|
|
tiles: [ |
|
|
|
tiles: [ |
|
|
|
DropdownButtonSettingsTile( |
|
|
|
CheckBoxSettingsTile( |
|
|
|
option: globalOptions.navigationMode, |
|
|
|
option: globalOptions.systemTrayEnabled, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.systemTrayHideToTrayWhenMinimized, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
if (platform.canUsePushNotifications) ...[ |
|
|
|
], |
|
|
|
SettingsCategory( |
|
|
|
SettingsCategory( |
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryPushNotifications), |
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryAccounts), |
|
|
|
key: ValueKey(SettingsCageories.pushNotifications.name), |
|
|
|
key: ValueKey(SettingsCageories.accounts.name), |
|
|
|
tiles: [ |
|
|
|
tiles: [ |
|
|
|
if (pushNotificationsEnabledEnabledSnapshot.hasData && |
|
|
|
if (accountsSnapshot.requireData.length > 1) ...[ |
|
|
|
!pushNotificationsEnabledEnabledSnapshot.requireData) ...[ |
|
|
|
CheckBoxSettingsTile( |
|
|
|
TextSettingsTile( |
|
|
|
option: globalOptions.rememberLastUsedAccount, |
|
|
|
text: AppLocalizations.of(context).globalOptionsPushNotificationsEnabledDisabledNotice, |
|
|
|
), |
|
|
|
style: TextStyle( |
|
|
|
DropdownButtonSettingsTile( |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
option: globalOptions.initialAccount, |
|
|
|
fontStyle: FontStyle.italic, |
|
|
|
), |
|
|
|
color: Theme.of(context).colorScheme.error, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.pushNotificationsEnabled, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
DropdownButtonSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.pushNotificationsDistributor, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
if (platform.canUseWindowManager) ...[ |
|
|
|
|
|
|
|
SettingsCategory( |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryStartup), |
|
|
|
|
|
|
|
key: ValueKey(SettingsCageories.startup.name), |
|
|
|
|
|
|
|
tiles: [ |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.startupMinimized, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.startupMinimizeInsteadOfExit, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
if (platform.canUseWindowManager && platform.canUseSystemTray) ...[ |
|
|
|
|
|
|
|
SettingsCategory( |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).optionsCategorySystemTray), |
|
|
|
|
|
|
|
key: ValueKey(SettingsCageories.systemTray.name), |
|
|
|
|
|
|
|
tiles: [ |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.systemTrayEnabled, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.systemTrayHideToTrayWhenMinimized, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
SettingsCategory( |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryAccounts), |
|
|
|
|
|
|
|
key: ValueKey(SettingsCageories.accounts.name), |
|
|
|
|
|
|
|
tiles: [ |
|
|
|
|
|
|
|
if (accountsSnapshot.requireData.length > 1) ...[ |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.rememberLastUsedAccount, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
DropdownButtonSettingsTile( |
|
|
|
|
|
|
|
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: Icon(MdiIcons.accountPlus), |
|
|
|
|
|
|
|
label: Text(AppLocalizations.of(context).globalOptionsAccountsAdd), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
for (final account in accountsSnapshot.requireData) ...[ |
|
|
|
SettingsCategory( |
|
|
|
AccountSettingsTile( |
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryOther), |
|
|
|
account: account, |
|
|
|
key: ValueKey(SettingsCageories.other.name), |
|
|
|
onTap: () { |
|
|
|
tiles: <SettingsTile>[ |
|
|
|
AccountSettingsRoute(accountid: account.id).go(context); |
|
|
|
CustomSettingsTile( |
|
|
|
|
|
|
|
leading: Icon( |
|
|
|
|
|
|
|
MdiIcons.scriptText, |
|
|
|
|
|
|
|
color: Theme.of(context).colorScheme.primary, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).licenses), |
|
|
|
|
|
|
|
onTap: () async { |
|
|
|
|
|
|
|
final branding = Branding.of(context); |
|
|
|
|
|
|
|
showLicensePage( |
|
|
|
|
|
|
|
context: context, |
|
|
|
|
|
|
|
applicationName: branding.name, |
|
|
|
|
|
|
|
applicationIcon: branding.logo, |
|
|
|
|
|
|
|
applicationLegalese: branding.legalese, |
|
|
|
|
|
|
|
applicationVersion: Provider.of<PackageInfo>(context, listen: false).version, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
CustomSettingsTile( |
|
|
|
], |
|
|
|
leading: Icon( |
|
|
|
CustomSettingsTile( |
|
|
|
MdiIcons.export, |
|
|
|
title: ElevatedButton.icon( |
|
|
|
color: Theme.of(context).colorScheme.primary, |
|
|
|
onPressed: () async => const LoginRoute().push(context), |
|
|
|
), |
|
|
|
icon: Icon(MdiIcons.accountPlus), |
|
|
|
title: Text(AppLocalizations.of(context).settingsExport), |
|
|
|
label: Text(AppLocalizations.of(context).globalOptionsAccountsAdd), |
|
|
|
onTap: () async { |
|
|
|
), |
|
|
|
final settingsExportHelper = _buildSettingsExportHelper(context); |
|
|
|
) |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
SettingsCategory( |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).optionsCategoryOther), |
|
|
|
|
|
|
|
key: ValueKey(SettingsCageories.other.name), |
|
|
|
|
|
|
|
tiles: <SettingsTile>[ |
|
|
|
|
|
|
|
CustomSettingsTile( |
|
|
|
|
|
|
|
leading: Icon( |
|
|
|
|
|
|
|
MdiIcons.scriptText, |
|
|
|
|
|
|
|
color: Theme.of(context).colorScheme.primary, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).licenses), |
|
|
|
|
|
|
|
onTap: () async { |
|
|
|
|
|
|
|
final branding = Branding.of(context); |
|
|
|
|
|
|
|
showLicensePage( |
|
|
|
|
|
|
|
context: context, |
|
|
|
|
|
|
|
applicationName: branding.name, |
|
|
|
|
|
|
|
applicationIcon: branding.logo, |
|
|
|
|
|
|
|
applicationLegalese: branding.legalese, |
|
|
|
|
|
|
|
applicationVersion: Provider.of<PackageInfo>(context, listen: false).version, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
CustomSettingsTile( |
|
|
|
|
|
|
|
leading: Icon( |
|
|
|
|
|
|
|
MdiIcons.export, |
|
|
|
|
|
|
|
color: Theme.of(context).colorScheme.primary, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).settingsExport), |
|
|
|
|
|
|
|
onTap: () async { |
|
|
|
|
|
|
|
final settingsExportHelper = _buildSettingsExportHelper(context); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
final fileName = |
|
|
|
final fileName = |
|
|
|
'nextcloud-neon-settings-${DateTime.now().millisecondsSinceEpoch ~/ 1000}.json.base64'; |
|
|
|
'nextcloud-neon-settings-${DateTime.now().millisecondsSinceEpoch ~/ 1000}.json.base64'; |
|
|
|
final data = base64.encode( |
|
|
|
final data = base64.encode( |
|
|
|
utf8.encode( |
|
|
|
utf8.encode( |
|
|
|
json.encode( |
|
|
|
json.encode( |
|
|
|
settingsExportHelper.toJsonExport(), |
|
|
|
settingsExportHelper.toJsonExport(), |
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
), |
|
|
|
await saveFileWithPickDialog(fileName, Uint8List.fromList(utf8.encode(data))); |
|
|
|
); |
|
|
|
} catch (e, s) { |
|
|
|
await saveFileWithPickDialog(fileName, Uint8List.fromList(utf8.encode(data))); |
|
|
|
debugPrint(e.toString()); |
|
|
|
} catch (e, s) { |
|
|
|
debugPrint(s.toString()); |
|
|
|
debugPrint(e.toString()); |
|
|
|
NeonException.showSnackbar(context, e); |
|
|
|
debugPrint(s.toString()); |
|
|
|
} |
|
|
|
NeonException.showSnackbar(context, e); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
CustomSettingsTile( |
|
|
|
|
|
|
|
leading: Icon( |
|
|
|
|
|
|
|
MdiIcons.import, |
|
|
|
|
|
|
|
color: Theme.of(context).colorScheme.primary, |
|
|
|
), |
|
|
|
), |
|
|
|
CustomSettingsTile( |
|
|
|
title: Text(AppLocalizations.of(context).settingsImport), |
|
|
|
leading: Icon( |
|
|
|
onTap: () async { |
|
|
|
MdiIcons.import, |
|
|
|
final settingsExportHelper = _buildSettingsExportHelper(context); |
|
|
|
color: Theme.of(context).colorScheme.primary, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
title: Text(AppLocalizations.of(context).settingsImport), |
|
|
|
|
|
|
|
onTap: () async { |
|
|
|
|
|
|
|
final settingsExportHelper = _buildSettingsExportHelper(context); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
final result = await FilePicker.platform.pickFiles( |
|
|
|
final result = await FilePicker.platform.pickFiles( |
|
|
|
withData: true, |
|
|
|
withData: true, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (result == null) { |
|
|
|
if (result == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!result.files.single.path!.endsWith('.json.base64')) { |
|
|
|
if (!result.files.single.path!.endsWith('.json.base64')) { |
|
|
|
if (mounted) { |
|
|
|
if (mounted) { |
|
|
|
NeonException.showSnackbar( |
|
|
|
NeonException.showSnackbar( |
|
|
|
context, |
|
|
|
context, |
|
|
|
AppLocalizations.of(context).settingsImportWrongFileExtension, |
|
|
|
AppLocalizations.of(context).settingsImportWrongFileExtension, |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final data = json.decode(utf8.decode(base64.decode(utf8.decode(result.files.single.bytes!)))); |
|
|
|
final data = json.decode(utf8.decode(base64.decode(utf8.decode(result.files.single.bytes!)))); |
|
|
|
|
|
|
|
|
|
|
|
await settingsExportHelper.applyFromJson(data as Map<String, dynamic>); |
|
|
|
await settingsExportHelper.applyFromJson(data as Map<String, dynamic>); |
|
|
|
} catch (e, s) { |
|
|
|
} catch (e, s) { |
|
|
|
debugPrint(e.toString()); |
|
|
|
debugPrint(e.toString()); |
|
|
|
debugPrint(s.toString()); |
|
|
|
debugPrint(s.toString()); |
|
|
|
NeonException.showSnackbar(context, e); |
|
|
|
NeonException.showSnackbar(context, e); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Scaffold( |
|
|
|
|
|
|
|
resizeToAvoidBottomInset: false, |
|
|
|
|
|
|
|
appBar: appBar, |
|
|
|
|
|
|
|
body: Center( |
|
|
|
|
|
|
|
child: ConstrainedBox( |
|
|
|
|
|
|
|
constraints: NeonDialogTheme.of(context).constraints, |
|
|
|
|
|
|
|
child: body, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|