feat+fix: Add option to set default download/share file type, fix typo in filter to query string, disable unused options in document filter

This commit is contained in:
Anton Stubenbord
2023-04-28 20:45:47 +02:00
parent 14c850ece6
commit bea0ab94be
20 changed files with 337 additions and 197 deletions

View File

@@ -0,0 +1,14 @@
import 'package:hive/hive.dart';
import 'package:paperless_mobile/core/config/hive/hive_config.dart';
part 'file_download_type.g.dart';
@HiveType(typeId: HiveTypeIds.fileDownloadType)
enum FileDownloadType {
@HiveField(1)
original,
@HiveField(2)
archived,
@HiveField(3)
alwaysAsk;
}

View File

@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:paperless_mobile/features/settings/view/widgets/color_scheme_option_setting.dart';
import 'package:paperless_mobile/features/settings/view/widgets/default_download_file_type_setting.dart';
import 'package:paperless_mobile/features/settings/view/widgets/default_share_file_type_setting.dart';
import 'package:paperless_mobile/features/settings/view/widgets/language_selection_setting.dart';
import 'package:paperless_mobile/features/settings/view/widgets/theme_mode_setting.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
@@ -12,10 +14,10 @@ class ApplicationSettingsPage extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: Text(S.of(context)!.applicationSettings),
actions: [
actions: const [
Padding(
padding: const EdgeInsets.all(16.0),
child: const Icon(Icons.public),
padding: EdgeInsets.all(16.0),
child: Icon(Icons.public),
)
],
),
@@ -24,6 +26,9 @@ class ApplicationSettingsPage extends StatelessWidget {
LanguageSelectionSetting(),
ThemeModeSetting(),
ColorSchemeOptionSetting(),
Divider(),
DefaultDownloadFileTypeSetting(),
DefaultShareFileTypeSetting(),
],
),
);

View File

@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:paperless_mobile/features/settings/model/file_download_type.dart';
import 'package:paperless_mobile/features/settings/view/widgets/global_settings_builder.dart';
import 'package:paperless_mobile/features/settings/view/widgets/radio_settings_dialog.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
class DefaultDownloadFileTypeSetting extends StatelessWidget {
const DefaultDownloadFileTypeSetting({super.key});
@override
Widget build(BuildContext context) {
return GlobalSettingsBuilder(
builder: (context, settings) {
return ListTile(
title: Text("Default download file type"),
subtitle: Text(
_downloadFileTypeToString(context, settings.defaultDownloadType),
),
onTap: () async {
final selectedValue = await showDialog<FileDownloadType>(
context: context,
builder: (context) {
return RadioSettingsDialog<FileDownloadType>(
titleText: "Default download file type",
options: [
RadioOption(
value: FileDownloadType.alwaysAsk,
label: "Always ask",
),
RadioOption(
value: FileDownloadType.original,
label: S.of(context)!.original,
),
RadioOption(
value: FileDownloadType.archived,
label: S.of(context)!.archivedPdf,
),
],
initialValue: settings.defaultDownloadType,
);
},
);
if (selectedValue != null) {
settings
..defaultDownloadType = selectedValue
..save();
}
},
);
},
);
}
String _downloadFileTypeToString(BuildContext context, FileDownloadType type) {
switch (type) {
case FileDownloadType.original:
return S.of(context)!.original;
case FileDownloadType.archived:
return S.of(context)!.archivedPdf;
case FileDownloadType.alwaysAsk:
return "Always ask";
}
}
}

View File

@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:paperless_mobile/features/settings/model/file_download_type.dart';
import 'package:paperless_mobile/features/settings/view/widgets/global_settings_builder.dart';
import 'package:paperless_mobile/features/settings/view/widgets/radio_settings_dialog.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
class DefaultShareFileTypeSetting extends StatelessWidget {
const DefaultShareFileTypeSetting({super.key});
@override
Widget build(BuildContext context) {
return GlobalSettingsBuilder(
builder: (context, settings) {
return ListTile(
title: Text("Default share file type"),
subtitle: Text(
_downloadFileTypeToString(context, settings.defaultShareType),
),
onTap: () async {
final selectedValue = await showDialog<FileDownloadType>(
context: context,
builder: (context) {
return RadioSettingsDialog<FileDownloadType>(
titleText: "Default share file type",
options: [
RadioOption(
value: FileDownloadType.alwaysAsk,
label: "Always ask",
),
RadioOption(
value: FileDownloadType.original,
label: S.of(context)!.original,
),
RadioOption(
value: FileDownloadType.archived,
label: S.of(context)!.archivedPdf,
),
],
initialValue: settings.defaultShareType,
);
},
);
if (selectedValue != null) {
settings
..defaultDownloadType = selectedValue
..save();
}
},
);
},
);
}
String _downloadFileTypeToString(BuildContext context, FileDownloadType type) {
switch (type) {
case FileDownloadType.original:
return S.of(context)!.original;
case FileDownloadType.archived:
return S.of(context)!.archivedPdf;
case FileDownloadType.alwaysAsk:
return "Always ask";
}
}
}

View File

@@ -51,8 +51,7 @@ class _RadioSettingsDialogState<T> extends State<RadioSettingsDialog<T>> {
mainAxisSize: MainAxisSize.min,
children: [
if (widget.descriptionText != null)
Text(widget.descriptionText!,
style: Theme.of(context).textTheme.bodySmall),
Text(widget.descriptionText!, style: Theme.of(context).textTheme.bodySmall),
...widget.options.map(_buildOptionListTile),
if (widget.footer != null) widget.footer!,
],