mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 14:07:59 -06:00
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:
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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!,
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user