LMFeedPostContent
LMFeedPostContent
is a widget that represents the content section of a post in a feed. It displays the text content of the post and provides options for expanding or collapsing long text, highlighting tags, and customizing the appearance of the text.
The LMFeedPostContent
widget is a part of the likeminds_feed_flutter_ui
package. It is designed to be used within an LMFeedPostWidget
to display the text content of a post in a consistent and customizable manner.
Properties
text
(String
)
The text content of the post. This is an optional parameter. If not provided, the text will be obtained from the InheritedPostProvider
.
onTagTap
(Function(String)
)
A callback function that is called when a tag in the post content is tapped. It receives the tapped tag as a parameter. This is an optional parameter.
expanded
(bool
)
A flag to control whether the text should be initially expanded or collapsed. This is an optional parameter with a default value of false
.
style
(LMFeedPostContentStyle
)
An instance of LMFeedPostContentStyle
to customize the appearance of the post content. This is an optional parameter.
Styling
The LMFeedPostContentStyle
class allows you to customize the appearance of the LMFeedPostContent
.
Customization variables
Property | Type | Description | Required | Default |
---|---|---|---|---|
textStyle | TextStyle | The text style for the post content. | ||
linkStyle | TextStyle | The text style for links and tags in the post content. | ||
expandTextStyle | TextStyle | The text style for the "see more" text when the content is collapsed. | ||
textAlign | TextAlign | The alignment of the text content. | ||
expandText | String | The text to display for expanding the collapsed content. | "see more" | |
animation | bool | Whether to apply animation when expanding or collapsing the content. | true | |
visibleLines | int | The number of lines to show when the content is collapsed. | 4 | |
width | double | The width of the post content container. | ||
height | double | The height of the post content container. | ||
padding | EdgeInsets | The padding of the post content container. | ||
margin | EdgeInsets | The margin of the post content container. |
You can create an instance of LMFeedPostContentStyle
and pass it to the LMFeedPostContent
to customize its appearance.
Usage Example
LMFeedPostContent(
text: "This is a sample post. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, a sit amet aliquam lacinia, nisl nisl aliquam nisl, nec aliquam nisl nisl sit amet nisl.",
onTagTap: (tag) {
// Handle tag tap
print("Tapped tag: $tag");
},
expanded: false,
style: LMFeedPostContentStyle(
textStyle: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.normal,
),
linkStyle: TextStyle(
color: Colors.blue,
fontSize: 16,
fontWeight: FontWeight.bold,
),
expandTextStyle: TextStyle(
color: Colors.grey,
fontSize: 14,
fontWeight: FontWeight.normal,
),
textAlign: TextAlign.left,
expandText: "Read more",
animation: true,
visibleLines: 3,
padding: EdgeInsets.all(16),
),
)
In this example, an LMFeedPostContent
is created with a sample text content. The onTagTap
callback is used to handle taps on tags within the content. The expanded
flag is set to false
to initially collapse the content. The appearance of the content is customized using LMFeedPostContentStyle
, specifying the text styles, alignment, expand text, animation, visible lines, and padding.