Skip to main content

LMFeedTopicTile

LMFeedTopicTile is a widget that represents a tile for a topic in a feed. It displays the topic text and an optional icon to indicate the selection state. The tile can be customized by passing in the required parameters, such as the topic data, selection state, and appearance options.


LMFeedTopicTile

The LMFeedTopicTile widget is part of the likeminds_feed_flutter_ui package. It is designed to be used within a feed or topic selection interface to display individual topics and allow user interaction.

Properties

  • topic (LMTopicViewData) - Required

The topic data associated with the tile. It consists of an id, topic text, and an isEnabled boolean. This is a required parameter.

  • icon (Icon) - Required

The icon to be displayed when the tile is selected. This is a required parameter.

  • onTap (Function(LMTopicViewData)) - Required

The action to perform when the tile is tapped. It takes the LMTopicViewData as a parameter. This is a required parameter.

  • isSelected (bool) - Required

A boolean value indicating whether the tile is selected or not. This is a required parameter.

  • text (LMFeedText) - Required

The text widget to be displayed in the tile. This is a required parameter.

  • tileRowAlignment (MainAxisAlignment)

The alignment of the row within the tile. It defaults to MainAxisAlignment.spaceBetween if not provided. This is an optional parameter.

  • backgroundColor (Color)

The background color of the tile. It defaults to Colors.transparent if not provided. This is an optional parameter.

  • height (double)

The height of the tile. This is an optional parameter.

  • borderColor (Color)

The color of the tile's border. This is an optional parameter.

  • borderWidth (double)

The width of the tile's border. This is an optional parameter.

  • padding (EdgeInsets)

The padding within the tile. This is an optional parameter.

Usage Example

LMFeedTopicTile(
topic: LMTopicViewData(
id: 'topic1',
topic: 'Technology',
isEnabled: true,
),
icon: Icon(Icons.check),
onTap: (topic) {
// Handle topic tile tap
print('Tapped on topic: ${topic.topic}');
},
isSelected: true,
text: LMFeedText(
text: 'Technology',
style: LMFeedTextStyle(
textStyle: TextStyle(
color: Colors.black,
fontSize: 16,
),
),
),
tileRowAlignment: MainAxisAlignment.start,
backgroundColor: Colors.grey[200],
height: 48,
borderColor: Colors.blue,
borderWidth: 1,
padding: EdgeInsets.symmetric(horizontal: 16),
)

In this example, an LMFeedTopicTile widget is created with the required topic, icon, onTap, isSelected, and text properties. The topic property specifies the topic data associated with the tile. The icon property defines the icon to be displayed when the tile is selected. The onTap callback is invoked when the tile is tapped, passing the LMTopicViewData as a parameter. The isSelected property indicates whether the tile is currently selected. The text property specifies the text widget to be displayed in the tile.

Additionally, the optional properties tileRowAlignment, backgroundColor, height, borderColor, borderWidth, and padding are used to customize the appearance and layout of the tile.