Skip to content

Commit

Permalink
TW-570: Create filter func for ActiveFilter enum
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev authored and hoangdat committed Sep 28, 2023
1 parent e2f6c5b commit 3282540
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/presentation/enum/chat_list/chat_list_enum.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluffychat/utils/matrix_sdk_extensions/client_stories_extension.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';
Expand All @@ -19,7 +20,22 @@ enum ActiveFilter {
allChats,
groups,
messages,
spaces,
spaces;

bool Function(Room) getRoomFilterByActiveFilter() {
switch (this) {
case ActiveFilter.allChats:
return (room) => !room.isSpace && !room.isStoryRoom;
case ActiveFilter.groups:
return (room) =>
!room.isSpace && !room.isDirectChat && !room.isStoryRoom;
case ActiveFilter.messages:
return (room) =>
!room.isSpace && room.isDirectChat && !room.isStoryRoom;
case ActiveFilter.spaces:
return (r) => r.isSpace;
}
}
}

enum ChatListSelectionActions {
Expand Down

0 comments on commit 3282540

Please sign in to comment.