@@ -2,20 +2,20 @@ import 'dart:async';
22
33import 'package:flutter/widgets.dart' ;
44
5- import '../models/data_models/chat_view_list_item .dart' ;
5+ import '../models/data_models/chat_list_item .dart' ;
66import '../values/enumeration.dart' ;
77import '../values/typedefs.dart' ;
88import 'auto_animated_sliver_list_controller.dart' ;
99
10- base class ChatViewListController {
11- ChatViewListController ({
12- required List <ChatViewListItem > initialChatList,
10+ base class ChatListController {
11+ ChatListController ({
12+ required List <ChatListItem > initialChatList,
1313 required this .scrollController,
1414 bool disposeOtherResources = true ,
1515 bool sortEnable = true ,
1616 ChatSorter ? chatSorter,
1717 }) : _disposeOtherResources = disposeOtherResources {
18- _animatedListController = AutoAnimateSliverListController <ChatViewListItem >(
18+ _animatedListController = AutoAnimateSliverListController <ChatListItem >(
1919 items: initialChatList,
2020 itemKeyExtractor: (item) => item.id,
2121 );
@@ -25,7 +25,7 @@ base class ChatViewListController {
2525 final chatList = chatMap.values.toList ();
2626 if (sortEnable) {
2727 chatList.sort (
28- chatSorter ?? ChatViewListSortBy .pinFirstByPinTime.sort,
28+ chatSorter ?? ChatListSortBy .pinFirstByPinTime.sort,
2929 );
3030 }
3131 return chatList;
@@ -51,18 +51,19 @@ base class ChatViewListController {
5151 );
5252 }
5353
54- late final AutoAnimateSliverListController <ChatViewListItem >
54+ late final AutoAnimateSliverListController <ChatListItem >
5555 _animatedListController;
5656
57- AutoAnimateSliverListController <ChatViewListItem >
58- get animatedListController => _animatedListController;
57+ /// Internal use only. Do not use explicitly.
58+ AutoAnimateSliverListController <ChatListItem > get animatedListController =>
59+ _animatedListController;
5960
6061 /// Stores and manages chat items by their unique IDs.
6162 /// A map is used for efficient lookup, update, and removal of chats
6263 /// by their unique id.
63- final _chatListMap = < String , ChatViewListItem > {};
64+ final _chatListMap = < String , ChatListItem > {};
6465
65- Map <String , ChatViewListItem >? _searchResultMap;
66+ Map <String , ChatListItem >? _searchResultMap;
6667
6768 /// Provides scroll controller for chat list.
6869 final ScrollController scrollController;
@@ -74,25 +75,24 @@ base class ChatViewListController {
7475 /// **Note**: If a search is active, this will return the full chat list,
7576 /// not the search results. And this list will be unsorted.
7677 /// So the order of in UI and from this will be different.
77- List <ChatViewListItem > get chatList => _chatListMap.values.toList ();
78+ List <ChatListItem > get chatList => _chatListMap.values.toList ();
7879
7980 /// Provides map of all chats in the chat list.
8081 ///
8182 /// **Note**: If a search is active, this will return the full chat map,
8283 /// not the search results. And this map will be unsorted.
83- Map <String , ChatViewListItem > get chatListMap => _chatListMap;
84+ Map <String , ChatListItem > get chatListMap => _chatListMap;
8485
8586 bool get isSearching => _searchResultMap != null ;
8687
8788 /// Stream controller to manage the chat list stream.
88- final StreamController <Map <String , ChatViewListItem >>
89- _chatListStreamController =
90- StreamController <Map <String , ChatViewListItem >>.broadcast ();
89+ final StreamController <Map <String , ChatListItem >> _chatListStreamController =
90+ StreamController <Map <String , ChatListItem >>.broadcast ();
9191
92- late final Stream <List <ChatViewListItem >> chatListStream;
92+ late final Stream <List <ChatListItem >> chatListStream;
9393
9494 /// Adds a chat to the chat list.
95- void addChat (ChatViewListItem chat) {
95+ void addChat (ChatListItem chat) {
9696 _chatListMap[chat.id] = chat;
9797 // Do not add chat to stream if search is active
9898 // as we will unable to identify whether to add as we don't
@@ -106,7 +106,7 @@ base class ChatViewListController {
106106 }
107107
108108 /// Function for loading data while pagination.
109- void loadMoreChats (List <ChatViewListItem > chatList) {
109+ void loadMoreChats (List <ChatListItem > chatList) {
110110 final chatListLength = chatList.length;
111111 _chatListMap.addAll (
112112 {
@@ -160,7 +160,7 @@ base class ChatViewListController {
160160 }
161161
162162 /// Adds the given chat search results to the stream after the current frame.
163- void setSearchChats (List <ChatViewListItem > searchResults) {
163+ void setSearchChats (List <ChatListItem > searchResults) {
164164 final searchResultLength = searchResults.length;
165165 _searchResultMap = {
166166 for (var i = 0 ; i < searchResultLength; i++ )
0 commit comments