mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 23:09:35 +01:00
feat: remove diacritics
This commit is contained in:
parent
7e0bcf5629
commit
758adff559
@ -6,6 +6,7 @@ import 'package:matrix/matrix.dart';
|
|||||||
import 'package:vrouter/vrouter.dart';
|
import 'package:vrouter/vrouter.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/pages/chat_list/chat_list_item.dart';
|
import 'package:fluffychat/pages/chat_list/chat_list_item.dart';
|
||||||
|
import 'package:fluffychat/utils/string_extension.dart';
|
||||||
import 'package:fluffychat/widgets/avatar.dart';
|
import 'package:fluffychat/widgets/avatar.dart';
|
||||||
import 'package:fluffychat/widgets/contacts_list.dart';
|
import 'package:fluffychat/widgets/contacts_list.dart';
|
||||||
import 'package:fluffychat/widgets/default_app_bar_search_field.dart';
|
import 'package:fluffychat/widgets/default_app_bar_search_field.dart';
|
||||||
@ -68,9 +69,8 @@ class SearchView extends StatelessWidget {
|
|||||||
rooms.removeWhere(
|
rooms.removeWhere(
|
||||||
(room) =>
|
(room) =>
|
||||||
room.lastEvent == null ||
|
room.lastEvent == null ||
|
||||||
!room.displayname
|
!room.displayname.toLowerCase().removeDiacritics().contains(
|
||||||
.toLowerCase()
|
controller.controller.text.toLowerCase().removeDiacritics()),
|
||||||
.contains(controller.controller.text.toLowerCase()),
|
|
||||||
);
|
);
|
||||||
const tabCount = 3;
|
const tabCount = 3;
|
||||||
return DefaultTabController(
|
return DefaultTabController(
|
||||||
|
15
lib/utils/string_extension.dart
Normal file
15
lib/utils/string_extension.dart
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
extension StringCasingExtension on String {
|
||||||
|
String removeDiacritics() {
|
||||||
|
const withDia =
|
||||||
|
'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
|
||||||
|
const withoutDia =
|
||||||
|
'AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz';
|
||||||
|
|
||||||
|
String str = this;
|
||||||
|
for (int i = 0; i < withDia.length; i++) {
|
||||||
|
str = str.replaceAll(withDia[i], withoutDia[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user