diff --git a/lib/ui/reports/reports_screen.dart b/lib/ui/reports/reports_screen.dart index fde51698a..3302269e9 100644 --- a/lib/ui/reports/reports_screen.dart +++ b/lib/ui/reports/reports_screen.dart @@ -553,8 +553,13 @@ class ReportResult { return true; } - static bool matchString({String filter, String value}) => - matchesString(value, filter); + static bool matchString({String filter, String value}) { + if (filter == null || filter.isEmpty) { + return true; + } + + return value.toLowerCase().contains(filter.toLowerCase()); + } static bool matchAmount({String filter, double amount}) { final String range = filter.replaceAll(',', '-') + '-'; diff --git a/lib/utils/strings.dart b/lib/utils/strings.dart index a2b5e6f33..81b860770 100644 --- a/lib/utils/strings.dart +++ b/lib/utils/strings.dart @@ -44,11 +44,25 @@ String getLastName(String value) { return parts.last; } +bool matchesStrings(List haystacks, String needle) { + bool isMatch = false; + haystacks.forEach((haystack) { + if (matchesString(haystack, needle)) { + isMatch = true; + } + }); + return isMatch; +} + bool matchesString(String haystack, String needle) { + if (needle == null || needle.isEmpty) { + return true; + } + String regExp = ''; needle.toLowerCase().runes.forEach((int rune) { final character = String.fromCharCode(rune); regExp += character + '.*?'; }); return RegExp(regExp).hasMatch(haystack.toLowerCase()); -} \ No newline at end of file +}