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

#778304 [Feat] - Scroll to message #287

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/src/models/ds_reply_content_in_reply_to.model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DSReplyContentInReplyTo {

DSReplyContentInReplyTo.fromJson(Map<String, dynamic> json)
: id = json['id'],
type = json['type'],
value = json['value'],
direction = json['direction'];
type = json['type'] ?? '',
value = json['value'] ?? '',
direction = json['direction'] ?? '';
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class DSAudioMessageBubble extends StatelessWidget {
final String? uniqueId;
final bool shouldAuthenticate;
final DSReplyContent? replyContent;
final void Function(String)? onTapReply;

DSAudioMessageBubble({
super.key,
Expand All @@ -26,6 +27,7 @@ class DSAudioMessageBubble extends StatelessWidget {
this.borderRadius = const [DSBorderRadius.all],
this.shouldAuthenticate = false,
final DSMessageBubbleStyle? style,
this.onTapReply,
}) : style = style ?? DSMessageBubbleStyle();

@override
Expand All @@ -34,6 +36,7 @@ class DSAudioMessageBubble extends StatelessWidget {
final isLightBubbleBackground = style.isLightBubbleBackground(align);

return DSMessageBubble(
onTapReply: onTapReply,
borderRadius: borderRadius,
align: align,
replyContent: replyContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class DSEndCallsMessageBubble extends StatefulWidget {
final DSCallsMediaMessage callsMediaMessage;
final Future<String?> Function(String)? onAsyncFetchSession;
final Map<String, dynamic>? translations;
final void Function(String)? onTapReply;

DSEndCallsMessageBubble({
super.key,
Expand All @@ -24,6 +25,7 @@ class DSEndCallsMessageBubble extends StatefulWidget {
this.borderRadius = const [DSBorderRadius.all],
DSMessageBubbleStyle? style,
this.translations,
this.onTapReply,
}) : style = style ?? DSMessageBubbleStyle();

@override
Expand Down Expand Up @@ -71,6 +73,7 @@ class _DSEndCallsMessageBubbleState extends State<DSEndCallsMessageBubble> {
@override
Widget build(BuildContext context) {
return DSMessageBubble(
onTapReply: widget.onTapReply,
shouldUseDefaultSize: true,
padding: const EdgeInsets.symmetric(
vertical: 12.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DSApplicationJsonMessageBubble extends StatelessWidget {
this.status,
this.avatarConfig = const DSMessageBubbleAvatarConfig(),
DSMessageBubbleStyle? style,
this.onTapReply,
}) : style = style ?? DSMessageBubbleStyle(),
interactive = content['interactive'] ?? {},
template = content['template'] ?? {};
Expand All @@ -35,6 +36,7 @@ class DSApplicationJsonMessageBubble extends StatelessWidget {
final Map<String, dynamic> content;
final Map<String, dynamic> interactive;
final Map<String, dynamic> template;
final void Function(String)? onTapReply;

@override
Widget build(BuildContext context) => switch (content['type']) {
Expand Down
7 changes: 6 additions & 1 deletion lib/src/widgets/chat/ds_carrousel.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class DSCarrousel extends StatelessWidget {
/// Card styling to adjust custom colors
final DSMessageBubbleStyle style;

/// Callback function to be executed when the reply button is tapped.
final void Function(String)? onTapReply;

DSCarrousel({
super.key,
required this.align,
Expand All @@ -44,7 +47,8 @@ class DSCarrousel extends StatelessWidget {
this.onOpenLink,
this.avatarConfig = const DSMessageBubbleAvatarConfig(),
DSMessageBubbleStyle? style,
}) : style = style ?? DSMessageBubbleStyle();
this.onTapReply,
}) : style = style ?? DSMessageBubbleStyle();

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -94,6 +98,7 @@ class DSCarrousel extends StatelessWidget {
onOpenLink: onOpenLink,
style: style,
mediaType: header["value"]["type"],
onTapReply: onTapReply,
),
),
);
Expand Down
3 changes: 3 additions & 0 deletions lib/src/widgets/chat/ds_image_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class DSImageMessageBubble extends StatefulWidget {
this.mediaType,
this.isUploading = false,
this.replyContent,
this.onTapReply,
}) : style = style ?? DSMessageBubbleStyle();

final DSAlign align;
Expand All @@ -55,6 +56,7 @@ class DSImageMessageBubble extends StatefulWidget {
final String? mediaType;
final bool isUploading;
final DSReplyContent? replyContent;
final void Function(String)? onTapReply;

@override
State<StatefulWidget> createState() => _DSImageMessageBubbleState();
Expand Down Expand Up @@ -84,6 +86,7 @@ class _DSImageMessageBubbleState extends State<DSImageMessageBubble>
: DSColors.neutralLightSnow;

return DSMessageBubble(
onTapReply: widget.onTapReply,
replyContent: widget.replyContent,
defaultMaxSize: DSUtils.bubbleMinSize,
shouldUseDefaultSize: true,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/widgets/chat/ds_location_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class DSLocationMessageBubble extends StatefulWidget {
final String latitude;
final String longitude;
final List<DSBorderRadius> borderRadius;
final void Function(String)? onTapReply;

DSLocationMessageBubble({
super.key,
Expand All @@ -38,6 +39,7 @@ class DSLocationMessageBubble extends StatefulWidget {
this.borderRadius = const [DSBorderRadius.all],
DSMessageBubbleStyle? style,
this.title,
this.onTapReply,
}) : style = style ?? DSMessageBubbleStyle();

@override
Expand Down Expand Up @@ -72,6 +74,7 @@ class _DSLocationMessageBubbleState extends State<DSLocationMessageBubble> {
Widget build(BuildContext context) => GestureDetector(
onTap: _hasValidCoordinates ? _openMapList : null,
child: DSMessageBubble(
onTapReply: widget.onTapReply,
shouldUseDefaultSize: true,
defaultMaxSize: DSUtils.bubbleMinSize,
defaultMinSize: DSUtils.bubbleMinSize,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/widgets/chat/ds_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DSMessageBubble extends StatelessWidget {
final double defaultMinSize;
final DSMessageBubbleStyle style;
final bool hasSpacer;
final void Function(String)? onTapReply;

const DSMessageBubble({
super.key,
Expand All @@ -36,6 +37,7 @@ class DSMessageBubble extends StatelessWidget {
this.defaultMinSize = DSUtils.bubbleMinSize,
required this.style,
this.hasSpacer = true,
this.onTapReply,
});

@override
Expand Down Expand Up @@ -84,6 +86,7 @@ class DSMessageBubble extends StatelessWidget {
replyContent: replyContent!,
style: style,
align: align,
onTap: onTapReply,
),
child,
],
Expand Down
19 changes: 12 additions & 7 deletions lib/src/widgets/chat/ds_reply_container.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,30 @@ class DSReplyContainer extends StatelessWidget {
required this.replyContent,
required this.align,
DSMessageBubbleStyle? style,
this.onTap,
}) : style = style ?? DSMessageBubbleStyle();

final DSAlign align;
final DSReplyContent replyContent;
final DSMessageBubbleStyle style;
final void Function(String)? onTap;

Color get _foregroundColor => style.isLightBubbleBackground(align)
? const Color.fromARGB(255, 39, 4, 4)
: DSColors.surface1;

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
_buildTitle(),
_buildReplyContainer(),
],
return GestureDetector(
onTap: () => onTap?.call(replyContent.inReplyTo.id),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
_buildTitle(),
_buildReplyContainer(),
],
),
),
);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/src/widgets/chat/ds_text_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DSTextMessageBubble extends StatefulWidget {
final bool showSelect;
final void Function(String, Map<String, dynamic>)? onSelected;
final DSMessageBubbleStyle style;
final void Function(String)? onTapReply;

DSTextMessageBubble({
super.key,
Expand All @@ -33,7 +34,8 @@ class DSTextMessageBubble extends StatefulWidget {
this.showSelect = false,
this.onSelected,
DSMessageBubbleStyle? style,
}) : style = style ?? DSMessageBubbleStyle();
this.onTapReply,
}) : style = style ?? DSMessageBubbleStyle();

@override
State<DSTextMessageBubble> createState() => _DSTextMessageBubbleState();
Expand All @@ -58,6 +60,7 @@ class _DSTextMessageBubbleState extends State<DSTextMessageBubble> {
@override
Widget build(BuildContext context) {
return DSMessageBubble(
onTapReply: widget.onTapReply,
align: widget.align,
borderRadius: widget.borderRadius,
padding: EdgeInsets.zero,
Expand Down
7 changes: 6 additions & 1 deletion lib/src/widgets/chat/ds_weblink_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class DSWeblinkMessageBubble extends StatelessWidget {
/// replyContent
final DSReplyContent? replyContent;

/// Callback function to be executed when the reply button is tapped.
final void Function(String)? onTapReply;

DSWeblinkMessageBubble({
super.key,
required this.title,
Expand All @@ -42,7 +45,8 @@ class DSWeblinkMessageBubble extends StatelessWidget {
this.replyContent,
this.borderRadius = const [DSBorderRadius.all],
DSMessageBubbleStyle? style,
}) : style = style ?? DSMessageBubbleStyle();
this.onTapReply,
}) : style = style ?? DSMessageBubbleStyle();

@override
Widget build(BuildContext context) {
Expand All @@ -53,6 +57,7 @@ class DSWeblinkMessageBubble extends StatelessWidget {
: DSColors.neutralLightSnow;

return DSMessageBubble(
onTapReply: onTapReply,
align: align,
replyContent: replyContent,
borderRadius: borderRadius,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class DSVideoMessageBubble extends StatefulWidget {
/// Title of the video which will be displayed inside the message bubble.
final String? title;

/// Callback function to be executed when the reply button is tapped.
final void Function(String)? onTapReply;

/// Card for the purpose of triggering a video to play.
///
/// This widget is intended to display a video card from a url passed in the [url] parameter.
Expand All @@ -81,6 +84,7 @@ class DSVideoMessageBubble extends StatefulWidget {
this.isUploading = false,
this.replyContent,
this.title,
this.onTapReply,
}) : style = style ?? DSMessageBubbleStyle();

@override
Expand Down Expand Up @@ -137,6 +141,7 @@ class _DSVideoMessageBubbleState extends State<DSVideoMessageBubble>
: DSColors.neutralDarkCity;

return DSMessageBubble(
onTapReply: widget.onTapReply,
defaultMaxSize: DSUtils.bubbleMinSize,
shouldUseDefaultSize: true,
replyContent: widget.replyContent,
Expand Down
Loading