LMFeedPostTopic
LMFeedPostTopic
is a widget that represents the topic section of a post in a feed. It displays a list of topics associated with the post using topic chips. The topics can be customized and styled based on the provided LMFeedPostTopicStyle
.
The LMFeedPostTopic
widget is a part of the likeminds_feed_flutter_ui
package. It is designed to be used within an LMFeedPostWidget
to display the topics related to a post.
Properties
post
(LMPostViewData
) - Required
The post data associated with the topics. This is a required parameter.
topics
(List<LMTopicViewData>
) - Required
The list of topics to be displayed for the post. This is a required parameter.
topicChipBuilder
(Widget Function(BuildContext, LMFeedTopicChip)
)
A builder function that allows customization of the topic chips. It takes the BuildContext
and an LMFeedTopicChip
as parameters and returns a custom widget. This is an optional parameter.
style
(LMFeedPostTopicStyle
)
The style configuration for the post topic section. It allows customization of the margin, padding, and styles for active and inactive topic chips. This is an optional parameter.
Styling
The LMFeedPostTopicStyle
class allows you to customize the appearance of the LMFeedPostTopic
widget.
Customization variables
Property | Type | Description | Required | Default |
---|---|---|---|---|
margin | EdgeInsets | The margin around the post topic section. | ||
padding | EdgeInsets | The padding within the post topic section. | ||
activeChipStyle | LMFeedTopicChipStyle | The style configuration for active topic chips. | ||
inactiveChipStyle | LMFeedTopicChipStyle | The style configuration for inactive topic chips. |
You can create an instance of LMFeedPostTopicStyle
and pass it to the LMFeedPostTopic
widget to customize its appearance.
Usage Example
LMFeedPostTopic(
post: LMPostViewData(
id: "post123",
text: "This is a sample post",
topics: [
LMTopicViewData(id: "topic1", name: "Topic 1"),
LMTopicViewData(id: "topic2", name: "Topic 2"),
],
),
topics: [
LMTopicViewData(id: "topic1", name: "Topic 1"),
LMTopicViewData(id: "topic2", name: "Topic 2"),
],
topicChipBuilder: (context, topicChip) {
return GestureDetector(
onTap: () {
// Handle topic chip tap
print("Tapped on topic: ${topicChip.topic.name}");
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(16),
),
child: Text(
topicChip.topic.name,
style: TextStyle(
color: Colors.white,
fontSize: 14,
),
),
),
);
},
style: LMFeedPostTopicStyle(
margin: EdgeInsets.symmetric(vertical: 8),
padding: EdgeInsets.symmetric(horizontal: 16),
activeChipStyle: LMFeedTopicChipStyle(
backgroundColor: Colors.blue,
textStyle: TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
inactiveChipStyle: LMFeedTopicChipStyle(
backgroundColor: Colors.grey[300],
textStyle: TextStyle(
color: Colors.black,
fontSize: 14,
),
),
),
)
In this example, an LMFeedPostTopic
widget is created with the required post
and topics
parameters. The topicChipBuilder
parameter is used to provide a custom builder function that wraps the topic chips with a GestureDetector
to handle tap events. The style
parameter is used to customize the margin, padding, and styles for active and inactive topic chips using the LMFeedPostTopicStyle
class.