Skip to content

Commit

Permalink
TW-1183: Change message item of twake_link_preview
Browse files Browse the repository at this point in the history
  • Loading branch information
hieutbui authored and hoangdat committed Mar 27, 2024
1 parent 1bb2a6e commit 0d3fe0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,16 @@ class TwakeLinkPreview extends StatefulWidget {
final Uri uri;
final int? preferredPointInTime;
final String text;
final Widget childWidget;
final TextStyle? textStyle;
final TextStyle? linkStyle;
final TextAlign? textAlign;
final LinkTapHandler? onLinkTap;
final int? maxLines;
final double? fontSize;
final Widget messageContentWidget;
final bool ownMessage;
final TextSpanBuilder? textSpanBuilder;

const TwakeLinkPreview({
super.key,
required this.uri,
this.preferredPointInTime,
required this.text,
required this.childWidget,
required this.messageContentWidget,
required this.ownMessage,
this.textStyle,
this.linkStyle,
this.textAlign,
this.onLinkTap,
this.maxLines,
this.fontSize,
this.textSpanBuilder,
});

@override
Expand Down Expand Up @@ -69,12 +55,8 @@ class TwakeLinkPreviewController extends State<TwakeLinkPreview>
return TwakeLinkView(
key: twakeLinkViewKey,
text: widget.text,
textStyle: widget.textStyle,
linkStyle: widget.linkStyle,
childWidget: widget.childWidget,
firstValidUrl: firstValidUrl,
onLinkTap: (url) => UrlLauncher(context, url: url.toString()).launchUrl(),
textSpanBuilder: widget.textSpanBuilder,
messageContentWidget: widget.messageContentWidget,
previewItemWidget: ValueListenableBuilder(
valueListenable: getPreviewUrlStateNotifier,
builder: (context, state, child) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
import 'package:fluffychat/widgets/clean_rich_text.dart';
import 'package:fluffychat/widgets/twake_components/twake_preview_link/twake_link_view_style.dart';
import 'package:flutter/material.dart';
import 'package:matrix_link_text/link_text.dart';

class TwakeLinkView extends StatelessWidget {
final String text;
final Widget childWidget;
final Widget messageContentWidget;
final Widget previewItemWidget;
final TextStyle? textStyle;
final TextStyle? linkStyle;
final TextAlign? textAlign;
final LinkTapHandler? onLinkTap;
final int? maxLines;
final String? firstValidUrl;
final TextSpanBuilder? textSpanBuilder;

const TwakeLinkView({
Key? key,
required this.text,
required this.childWidget,
required this.messageContentWidget,
required this.previewItemWidget,
this.textStyle,
this.linkStyle,
this.textAlign = TextAlign.start,
this.onLinkTap,
this.maxLines,
this.firstValidUrl,
this.textSpanBuilder,
}) : super(key: key);

@override
Expand All @@ -47,7 +33,7 @@ class TwakeLinkView extends StatelessWidget {
const SizedBox(height: 2),
Padding(
padding: TwakeLinkViewStyle.paddingWidgetNoPreview,
child: _buildCleanRichText(context),
child: messageContentWidget,
),
],
);
Expand All @@ -56,20 +42,7 @@ class TwakeLinkView extends StatelessWidget {
Widget _buildWidgetNoPreview(BuildContext context) {
return Padding(
padding: TwakeLinkViewStyle.paddingWidgetNoPreview,
child: _buildCleanRichText(context),
);
}

Widget _buildCleanRichText(BuildContext context) {
return TwakeCleanRichText(
text: text,
childWidget: childWidget,
textStyle: textStyle,
linkStyle: linkStyle,
textAlign: textAlign ?? TextAlign.start,
onLinkTap: onLinkTap,
maxLines: maxLines,
textSpanBuilder: textSpanBuilder,
child: messageContentWidget,
);
}
}

0 comments on commit 0d3fe0b

Please sign in to comment.