Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

refactor

ashilkn09b9a1e231b6
diff --git a/lib/ui/viewer/search_tab/file_type_section.dart b/lib/ui/viewer/search_tab/file_type_section.dart
index 2a01ed543c..d67ac9e6be 100644
--- a/lib/ui/viewer/search_tab/file_type_section.dart
+++ b/lib/ui/viewer/search_tab/file_type_section.dart
@@ -147,15 +147,9 @@ class FileTypeRecommendation extends StatelessWidget {
@override
Widget build(BuildContext context) {
- //remove 's' at end of extensions and use only 1st word if there exists
- //multiple words.
- final fileType = fileTypeSearchResult.name
- .call()
- .replaceAll(RegExp(r'.$'), "")
- .split(" ")
- .first
- .toUpperCase();
- final assetPath = knownTypesToAssetPath[fileType];
+ final fileTypeKey =
+ fileTypeKeyFromSearchResult(fileTypeSearchResult.name.call());
+ final assetPath = knownTypesToAssetPath[fileTypeKey];
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: ConstrainedBox(
@@ -187,7 +181,7 @@ class FileTypeRecommendation extends StatelessWidget {
child: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
- fileType,
+ fileTypeKey,
style: const TextStyle(
fontSize: 14,
fontFamily: "Inter",
@@ -206,4 +200,16 @@ class FileTypeRecommendation extends StatelessWidget {
),
);
}
+
+ String fileTypeKeyFromSearchResult(String name) {
+ String fileTypeKey = "";
+ //remove 's' at the end of string
+ if (RegExp(r's$').hasMatch(name)) {
+ fileTypeKey = name.substring(0, name.length - 1);
+ }
+ //use only 1st word if there exists multiple words
+ fileTypeKey = fileTypeKey.split(" ").first.toUpperCase();
+
+ return fileTypeKey;
+ }
}