Added translations, fixed chips theming

This commit is contained in:
Anton Stubenbord
2023-01-20 12:46:46 +01:00
parent f9dfddf704
commit fa3059218d
24 changed files with 399 additions and 270 deletions

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:paperless_mobile/core/workarounds/colored_chip.dart';
import 'package:paperless_mobile/generated/l10n.dart';
class StoragePathAutofillFormBuilderField extends StatefulWidget {
@@ -61,71 +62,78 @@ class _StoragePathAutofillFormBuilderFieldState
"Select to autofill path variable",
style: Theme.of(context).textTheme.bodySmall,
),
Wrap(
alignment: WrapAlignment.start,
spacing: 4.0,
runSpacing: 4.0,
children: [
InputChip(
label: Text(
S.of(context).documentArchiveSerialNumberPropertyLongLabel),
onPressed: () => _addParameterToInput("{asn}", field),
),
InputChip(
label: Text(S.of(context).documentCorrespondentPropertyLabel),
onPressed: () => _addParameterToInput("{correspondent}", field),
),
InputChip(
label: Text(S.of(context).documentDocumentTypePropertyLabel),
onPressed: () => _addParameterToInput("{document_type}", field),
),
InputChip(
label: Text(S.of(context).documentTagsPropertyLabel),
onPressed: () => _addParameterToInput("{tag_list}", field),
),
InputChip(
label: Text(S.of(context).documentTitlePropertyLabel),
onPressed: () => _addParameterToInput("{title}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel),
onPressed: () => _addParameterToInput("{created}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterYearLabel})"),
onPressed: () => _addParameterToInput("{created_year}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterMonthLabel})"),
onPressed: () => _addParameterToInput("{created_month}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterDayLabel})"),
onPressed: () => _addParameterToInput("{created_day}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel),
onPressed: () => _addParameterToInput("{added}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterYearLabel})"),
onPressed: () => _addParameterToInput("{added_year}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterMonthLabel})"),
onPressed: () => _addParameterToInput("{added_month}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterDayLabel})"),
onPressed: () => _addParameterToInput("{added_day}", field),
),
],
ColoredChipWrapper(
child: Wrap(
alignment: WrapAlignment.start,
spacing: 4.0,
runSpacing: 4.0,
children: [
InputChip(
label: Text(S
.of(context)
.documentArchiveSerialNumberPropertyLongLabel),
onPressed: () => _addParameterToInput("{asn}", field),
),
InputChip(
label: Text(S.of(context).documentCorrespondentPropertyLabel),
onPressed: () =>
_addParameterToInput("{correspondent}", field),
),
InputChip(
label: Text(S.of(context).documentDocumentTypePropertyLabel),
onPressed: () =>
_addParameterToInput("{document_type}", field),
),
InputChip(
label: Text(S.of(context).documentTagsPropertyLabel),
onPressed: () => _addParameterToInput("{tag_list}", field),
),
InputChip(
label: Text(S.of(context).documentTitlePropertyLabel),
onPressed: () => _addParameterToInput("{title}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel),
onPressed: () => _addParameterToInput("{created}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterYearLabel})"),
onPressed: () =>
_addParameterToInput("{created_year}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterMonthLabel})"),
onPressed: () =>
_addParameterToInput("{created_month}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterDayLabel})"),
onPressed: () => _addParameterToInput("{created_day}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel),
onPressed: () => _addParameterToInput("{added}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterYearLabel})"),
onPressed: () => _addParameterToInput("{added_year}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterMonthLabel})"),
onPressed: () => _addParameterToInput("{added_month}", field),
),
InputChip(
label: Text(S.of(context).documentCreatedPropertyLabel +
" (${S.of(context).storagePathParameterDayLabel})"),
onPressed: () => _addParameterToInput("{added_day}", field),
),
],
),
)
],
),

View File

@@ -1,11 +1,10 @@
import 'package:flutter/material.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/workarounds/colored_chip.dart';
class TagWidget extends StatelessWidget {
final Tag tag;
final VoidCallback? afterTagTapped;
final VoidCallback onSelected;
final bool isSelected;
final bool isClickable;
final bool showShortName;
final bool dense;
@@ -13,10 +12,8 @@ class TagWidget extends StatelessWidget {
const TagWidget({
super.key,
required this.tag,
required this.afterTagTapped,
this.isClickable = true,
required this.onSelected,
required this.isSelected,
this.showShortName = false,
this.dense = false,
});
@@ -27,24 +24,25 @@ class TagWidget extends StatelessWidget {
padding: const EdgeInsets.only(right: 4.0),
child: AbsorbPointer(
absorbing: !isClickable,
child: FilterChip(
labelPadding:
dense ? const EdgeInsets.symmetric(horizontal: 2) : null,
padding: dense ? const EdgeInsets.all(4) : null,
selected: isSelected,
selectedColor: tag.color,
onSelected: (_) => onSelected(),
visualDensity: const VisualDensity(vertical: -2),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
label: Text(
showShortName && tag.name.length > 6
? '${tag.name.substring(0, 6)}...'
: tag.name,
style: TextStyle(color: tag.textColor),
child: ColoredChipWrapper(
child: FilterChip(
labelPadding:
dense ? const EdgeInsets.symmetric(horizontal: 2) : null,
padding: dense ? const EdgeInsets.all(4) : null,
selectedColor: tag.color,
onSelected: (_) => onSelected(),
visualDensity: const VisualDensity(vertical: -2),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
label: Text(
showShortName && tag.name.length > 6
? '${tag.name.substring(0, 6)}...'
: tag.name,
style: TextStyle(color: tag.textColor),
),
checkmarkColor: tag.textColor,
backgroundColor: tag.color,
side: BorderSide.none,
),
checkmarkColor: tag.textColor,
backgroundColor: tag.color,
side: BorderSide.none,
),
),
);

View File

@@ -7,6 +7,7 @@ import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/repository/label_repository.dart';
import 'package:paperless_mobile/core/repository/state/impl/tag_repository_state.dart';
import 'package:paperless_mobile/core/workarounds/colored_chip.dart';
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
import 'package:paperless_mobile/features/edit_label/view/impl/add_tag_page.dart';
import 'package:paperless_mobile/generated/l10n.dart';
@@ -263,13 +264,15 @@ class _TagFormFieldState extends State<TagFormField> {
}
Widget _buildNotAssignedTag(FormFieldState<TagsQuery> field) {
return InputChip(
label: Text(
S.of(context).labelNotAssignedText,
return ColoredChipWrapper(
child: InputChip(
label: Text(
S.of(context).labelNotAssignedText,
),
backgroundColor:
Theme.of(context).colorScheme.onSurface.withOpacity(0.12),
onDeleted: () => field.didChange(const IdsTagsQuery()),
),
backgroundColor:
Theme.of(context).colorScheme.onSurface.withOpacity(0.12),
onDeleted: () => field.didChange(const IdsTagsQuery()),
);
}
@@ -283,33 +286,37 @@ class _TagFormFieldState extends State<TagFormField> {
if (tag == null) {
return Container();
}
return InputChip(
label: Text(
tag.name,
style: TextStyle(
color: tag.textColor,
decorationColor: tag.textColor,
decoration: !isIncludedTag ? TextDecoration.lineThrough : null,
decorationThickness: 2.0,
return ColoredChipWrapper(
child: InputChip(
label: Text(
tag.name,
style: TextStyle(
color: tag.textColor,
decorationColor: tag.textColor,
decoration: !isIncludedTag ? TextDecoration.lineThrough : null,
decorationThickness: 2.0,
),
),
onPressed: widget.excludeAllowed
? () => field.didChange(currentQuery.withIdQueryToggled(tag.id!))
: null,
backgroundColor: tag.color,
deleteIconColor: tag.textColor,
onDeleted: () => field.didChange(
(field.value as IdsTagsQuery).withIdsRemoved([tag.id!]),
),
),
onPressed: widget.excludeAllowed
? () => field.didChange(currentQuery.withIdQueryToggled(tag.id!))
: null,
backgroundColor: tag.color,
deleteIconColor: tag.textColor,
onDeleted: () => field.didChange(
(field.value as IdsTagsQuery).withIdsRemoved([tag.id!]),
),
);
}
Widget _buildAnyAssignedTag(FormFieldState<TagsQuery> field) {
return InputChip(
label: Text(S.of(context).labelAnyAssignedText),
backgroundColor:
Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.12),
onDeleted: () => field.didChange(const IdsTagsQuery()),
return ColoredChipWrapper(
child: InputChip(
label: Text(S.of(context).labelAnyAssignedText),
backgroundColor:
Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.12),
onDeleted: () => field.didChange(const IdsTagsQuery()),
),
);
}
}

View File

@@ -9,20 +9,16 @@ import 'package:paperless_mobile/features/labels/tags/view/widgets/tag_widget.da
class TagsWidget extends StatelessWidget {
final Iterable<int> tagIds;
final bool isMultiLine;
final VoidCallback? afterTagTapped;
final void Function(int tagId)? onTagSelected;
final bool isClickable;
final bool Function(int id) isSelectedPredicate;
final bool showShortNames;
final bool dense;
const TagsWidget({
Key? key,
required this.tagIds,
this.afterTagTapped,
this.isMultiLine = true,
this.isClickable = true,
required this.isSelectedPredicate,
this.onTagSelected,
this.showShortNames = false,
this.dense = true,
@@ -38,9 +34,7 @@ class TagsWidget extends StatelessWidget {
.map(
(id) => TagWidget(
tag: state.getLabel(id)!,
afterTagTapped: afterTagTapped,
isClickable: isClickable,
isSelected: isSelectedPredicate(id),
onSelected: () => onTagSelected?.call(id),
showShortName: showShortNames,
dense: dense,

View File

@@ -174,7 +174,6 @@ class _LabelsPageState extends State<LabelsPage>
)
: null,
),
contentBuilder: (t) => Text(t.match ?? ''),
emptyStateActionButtonLabel:
S.of(context).labelsPageTagsEmptyStateAddNewLabel,
emptyStateDescription:

View File

@@ -68,21 +68,22 @@ class LabelTabView<T extends Label> extends StatelessWidget {
connectivityState.isConnected,
child: ListView(
children: labels
.map(
(l) => LabelItem<T>(
name: l.name,
content: contentBuilder?.call(l) ??
Text(
"${translateMatchingAlgorithm(context, l.matchingAlgorithm)}\n"
"${l.match}",
maxLines: 2,
),
onOpenEditPage: onEdit,
filterBuilder: filterBuilder,
leading: leadingBuilder?.call(l),
label: l,
),
)
.map((l) => LabelItem<T>(
name: l.name,
content: contentBuilder?.call(l) ??
Text(
translateMatchingAlgorithmName(
context, l.matchingAlgorithm) +
((l.match?.isNotEmpty ?? false)
? ": ${l.match}"
: ""),
maxLines: 2,
),
onOpenEditPage: onEdit,
filterBuilder: filterBuilder,
leading: leadingBuilder?.call(l),
label: l,
))
.toList(),
),
);