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

@@ -2,8 +2,10 @@ import 'package:flutter/material.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/generated/l10n.dart';
String translateMatchingAlgorithm(
BuildContext context, MatchingAlgorithm algorithm) {
String translateMatchingAlgorithmDescription(
BuildContext context,
MatchingAlgorithm algorithm,
) {
switch (algorithm) {
case MatchingAlgorithm.anyWord:
return S.of(context).matchingAlgorithmAnyDescription;
@@ -19,3 +21,23 @@ String translateMatchingAlgorithm(
return S.of(context).matchingAlgorithmAutoDescription;
}
}
String translateMatchingAlgorithmName(
BuildContext context,
MatchingAlgorithm algorithm,
) {
switch (algorithm) {
case MatchingAlgorithm.anyWord:
return S.of(context).matchingAlgorithmAnyName;
case MatchingAlgorithm.allWords:
return S.of(context).matchingAlgorithmAllName;
case MatchingAlgorithm.exactMatch:
return S.of(context).matchingAlgorithmExactName;
case MatchingAlgorithm.regex:
return S.of(context).matchingAlgorithmRegexName;
case MatchingAlgorithm.fuzzy:
return S.of(context).matchingAlgorithmFuzzyName;
case MatchingAlgorithm.auto:
return S.of(context).matchingAlgorithmAutoName;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/core/workarounds/colored_chip.dart';
import 'package:paperless_mobile/generated/l10n.dart';
class RelativeDateRangePickerHelper extends StatefulWidget {
@@ -28,15 +29,17 @@ class _RelativeDateRangePickerHelperState
separatorBuilder: (context, index) => const SizedBox(width: 8.0),
itemBuilder: (context, index) {
final option = _options[index];
return FilterChip(
label: Text(option.title),
onSelected: (isSelected) {
final value =
isSelected ? option.value : const RelativeDateRangeQuery();
widget.field.didChange(value);
widget.onChanged?.call(value);
},
selected: widget.field.value == option.value,
return ColoredChipWrapper(
child: FilterChip(
label: Text(option.title),
onSelected: (isSelected) {
final value =
isSelected ? option.value : const RelativeDateRangeQuery();
widget.field.didChange(value);
widget.onChanged?.call(value);
},
selected: widget.field.value == option.value,
),
);
},
scrollDirection: Axis.horizontal,

View File

@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
class ColoredChipWrapper extends StatelessWidget {
final Color? backgroundColor;
final Widget child;
const ColoredChipWrapper({
super.key,
this.backgroundColor,
required this.child,
});
@override
Widget build(BuildContext context) {
Color color = backgroundColor ?? Colors.lightGreen[50]!;
return Theme(
data: Theme.of(context).copyWith(
canvasColor: color,
),
child: child,
);
}
}