|
|
@ -86,236 +86,234 @@ class _SettingsPageState extends State<SettingsPage> { |
|
|
|
builder: ( |
|
|
|
builder: ( |
|
|
|
final context, |
|
|
|
final context, |
|
|
|
final accountsSnapshot, |
|
|
|
final accountsSnapshot, |
|
|
|
) { |
|
|
|
) => |
|
|
|
final platform = Provider.of<NeonPlatform>(context, listen: false); |
|
|
|
ValueListenableBuilder<bool>( |
|
|
|
return ValueListenableBuilder<bool>( |
|
|
|
valueListenable: globalOptions.pushNotificationsEnabled, |
|
|
|
valueListenable: globalOptions.pushNotificationsEnabled, |
|
|
|
builder: ( |
|
|
|
builder: ( |
|
|
|
final context, |
|
|
|
final context, |
|
|
|
final _, |
|
|
|
final _, |
|
|
|
final __, |
|
|
|
final __, |
|
|
|
) => |
|
|
|
) => |
|
|
|
SettingsList( |
|
|
|
SettingsList( |
|
|
|
initialCategory: widget.initialCategory?.name, |
|
|
|
initialCategory: widget.initialCategory?.name, |
|
|
|
categories: [ |
|
|
|
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 (NeonPlatform.instance.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 (!globalOptions.pushNotificationsEnabled.enabled) ...[ |
|
|
|
if (appImplementation.options.options.isNotEmpty) ...[ |
|
|
|
TextSettingsTile( |
|
|
|
CustomSettingsTile( |
|
|
|
text: AppLocalizations.of(context).globalOptionsPushNotificationsEnabledDisabledNotice, |
|
|
|
leading: appImplementation.buildIcon(), |
|
|
|
style: TextStyle( |
|
|
|
title: Text(appImplementation.name(context)), |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
onTap: () { |
|
|
|
fontStyle: FontStyle.italic, |
|
|
|
NextcloudAppSettingsRoute(appid: appImplementation.id).go(context); |
|
|
|
color: Theme.of(context).colorScheme.error, |
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
|
|
|
|
CheckBoxSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.pushNotificationsEnabled, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
DropdownButtonSettingsTile( |
|
|
|
|
|
|
|
option: globalOptions.pushNotificationsDistributor, |
|
|
|
|
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
if (NeonPlatform.instance.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 (NeonPlatform.instance.canUseWindowManager && NeonPlatform.instance.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 (!globalOptions.pushNotificationsEnabled.enabled) ...[ |
|
|
|
if (accountsSnapshot.requireData.length > 1) ...[ |
|
|
|
TextSettingsTile( |
|
|
|
CheckBoxSettingsTile( |
|
|
|
text: AppLocalizations.of(context).globalOptionsPushNotificationsEnabledDisabledNotice, |
|
|
|
option: globalOptions.rememberLastUsedAccount, |
|
|
|
style: TextStyle( |
|
|
|
), |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
DropdownButtonSettingsTile( |
|
|
|
fontStyle: FontStyle.italic, |
|
|
|
option: globalOptions.initialAccount, |
|
|
|
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, utf8.encode(data) as Uint8List); |
|
|
|
); |
|
|
|
} catch (e, s) { |
|
|
|
await saveFileWithPickDialog(fileName, utf8.encode(data) as Uint8List); |
|
|
|
debugPrint(e.toString()); |
|
|
|
} catch (e, s) { |
|
|
|
debugPrint(s.toString()); |
|
|
|
debugPrint(e.toString()); |
|
|
|
if (mounted) { |
|
|
|
debugPrint(s.toString()); |
|
|
|
NeonException.showSnackbar(context, e); |
|
|
|
if (mounted) { |
|
|
|
} |
|
|
|
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()); |
|
|
|
if (mounted) { |
|
|
|
if (mounted) { |
|
|
|
NeonException.showSnackbar(context, e); |
|
|
|
NeonException.showSnackbar(context, e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
), |
|
|
|
}, |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
), |
|
|
|
}, |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return Scaffold( |
|
|
|
return Scaffold( |
|
|
|