mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 08:08:14 -06:00
Added translations, fixed chips theming
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
23
lib/core/workarounds/colored_chip.dart
Normal file
23
lib/core/workarounds/colored_chip.dart
Normal 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user