Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make StreamChannelListTile trailing widget behave similarly with ListTile trailing in Flutter #2084

Open
1 task done
mlab817 opened this issue Jan 16, 2025 · 0 comments
Open
1 task done
Labels
enhancement New feature or request

Comments

@mlab817
Copy link

mlab817 commented Jan 16, 2025

Please select which package this feature is related to

stream_chat_flutter

Which platforms would this feature impact?

Android, iOS

Is your feature request related to a problem?

The trailing property of the StreamChatListTile is not intuitive because it does not follow the behavior of ListTile trailing property.

return BetterStreamBuilder<bool>(
      stream: channel.isMutedStream,
      initialData: channel.isMuted,
      builder: (context, isMuted) => AnimatedOpacity(
        opacity: isMuted ? 0.5 : 1,
        duration: const Duration(milliseconds: 300),
        child: ListTile(
          onTap: onTap,
          onLongPress: onLongPress,
          visualDensity: visualDensity,
          contentPadding: contentPadding,
          leading: leading,
          tileColor: tileColor,
          selected: selected,
          selectedTileColor: selectedTileColor ??
              StreamChatTheme.of(context).colorTheme.borders,
          title: Row(
            children: [
              Expanded(child: title),
              BetterStreamBuilder<List<Member>>(
                stream: channelState.membersStream,
                initialData: channelState.members,
                comparator: const ListEquality().equals,
                builder: (context, members) {
                  if (members.isEmpty) {
                    return const Offstage();
                  }
                  return unreadIndicatorBuilder?.call(context) ??
                      StreamUnreadIndicator.channels(cid: channel.cid);
                },
              ),
            ],
          ),
          subtitle: Row(
            children: [
              Expanded(
                child: Align(
                  alignment: Alignment.centerLeft,
                  child: subtitle,
                ),
              ),
              BetterStreamBuilder<List<Message>>(
                stream: channelState.messagesStream,
                initialData: channelState.messages,
                comparator: const ListEquality().equals,
                builder: (context, messages) {
                  final lastMessage = messages.lastWhereOrNull(
                    (m) => !m.shadowed && !m.isDeleted,
                  );

                  if (lastMessage == null ||
                      (lastMessage.user?.id != currentUser.id)) {
                    return const Offstage();
                  }

                  final hasNonUrlAttachments = lastMessage.attachments
                      .any((it) => it.type != AttachmentType.urlPreview);

                  return Padding(
                    padding: const EdgeInsets.only(right: 4),
                    child:
                        sendingIndicatorBuilder?.call(context, lastMessage) ??
                            SendingIndicatorBuilder(
                              messageTheme: streamChatTheme.ownMessageTheme,
                              message: lastMessage,
                              hasNonUrlAttachments: hasNonUrlAttachments,
                              streamChat: streamChat,
                              streamChatTheme: streamChatTheme,
                              channel: channel,
                            ),
                  );
                },
              ),
              trailing, <--- trailing is nested inside subtitle
            ],
          ),
        ),
      ),
    );

The trailing property here could be renamed to subtitleEnd or something similar.

The trailing not available limits the customizability of the StreamChatListTile. For example, if you want to customize the actual trailing property, you'll need to modify the entire content of the StreamChatListTile. Just to give an example:

Messenger's channel list tile has a trailing that shows unread indicator as a dot and also a mute indicator.

Describe the solution that you'd like

Move the trailing property for StreamChatListTile to trailing and use a different trailing property for the subtitle.

Describe alternatives that you have considered

Customized the title and subtitle to fit my use case or use a Stack to add an overlay button at the end of the listtile.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@mlab817 mlab817 added the enhancement New feature or request label Jan 16, 2025
@mlab817 mlab817 changed the title Make StreamChannelListTile trailing widget behave similarly with ListTile trailing Make StreamChannelListTile trailing widget behave similarly with ListTile trailing in Flutter Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant