Skip to content

Commit

Permalink
Can longPress on item in chat list and fix can't remove item already …
Browse files Browse the repository at this point in the history
…exists
  • Loading branch information
nqhhdev authored and hoangdat committed Sep 27, 2023
1 parent 8ed95b4 commit 27e6a9f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/pages/chat_list/chat_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ class ChatListController extends State<ChatList>
tempConversationSelectionPresentation =
conversationSelectionNotifier.value.toSet();

if (conversation != null) {
conversationSelectionNotifier.value.toSet().remove(conversation);
if (conversation != null && conversation.isSelected) {
tempConversationSelectionPresentation.remove(conversation);
} else {
tempConversationSelectionPresentation.add(
ConversationSelectionPresentation(
Expand Down
6 changes: 6 additions & 0 deletions lib/pages/chat_list/chat_list_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ class ChatListViewBody extends StatelessWidget {
context,
rooms[index],
),
onLongPress: () {
controller.toggleSelectMode();
controller.toggleSelection(
rooms[index].id,
);
},
checkBoxWidget: ValueListenableBuilder(
valueListenable:
controller.conversationSelectionNotifier,
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/chat_list/chat_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ChatListItem extends StatelessWidget with ChatListItemMixin {
final void Function()? onTap;
final void Function()? onTapAvatar;
final void Function()? onSecondaryTap;
final void Function()? onLongPress;

const ChatListItem(
this.room, {
Expand All @@ -33,6 +34,7 @@ class ChatListItem extends StatelessWidget with ChatListItemMixin {
this.onTap,
this.onTapAvatar,
this.onSecondaryTap,
this.onLongPress,
Key? key,
}) : super(key: key);

Expand Down Expand Up @@ -100,6 +102,7 @@ class ChatListItem extends StatelessWidget with ChatListItemMixin {
child: InkWell(
onTap: () => clickAction(context),
onSecondaryTap: onSecondaryTap,
onLongPress: onLongPress,
child: Container(
padding: ChatListItemStyle.paddingBody,
child: Row(
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/twake_components/twake_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TwakeHeader extends StatelessWidget
child: Row(
children: [
Expanded(
flex: 3,
flex: TwakeHeaderStyle.flexActions,
child: Row(
children: [
InkWell(
Expand Down Expand Up @@ -79,7 +79,7 @@ class TwakeHeader extends StatelessWidget
),
),
Expanded(
flex: 6,
flex: TwakeHeaderStyle.flexTitle,
child: Align(
alignment: Alignment.center,
child: Text(
Expand All @@ -92,7 +92,7 @@ class TwakeHeader extends StatelessWidget
),
if (!TwakeHeaderStyle.isDesktop(context))
Expanded(
flex: 3,
flex: TwakeHeaderStyle.flexActions,
child: Align(
alignment: Alignment.centerRight,
child: InkWell(
Expand Down
2 changes: 2 additions & 0 deletions lib/widgets/twake_components/twake_header_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class TwakeHeaderStyle {
static const double closeIconSize = 24.0;
static const double widthSizedBox = 16.0;
static const double textBorderRadius = 24.0;
static const int flexTitle = 6;
static const int flexActions = 3;

static bool isDesktop(BuildContext context) => responsive.isDesktop(context);

Expand Down

0 comments on commit 27e6a9f

Please sign in to comment.