from typing import Optional, override

from flut.flutter.widgets.framework import Widget


class ListTile(Widget):
    def __init__(
        self,
        *,
        key=None,
        leading: Optional[Widget] = None,
        title: Optional[Widget] = None,
        subtitle: Optional[Widget] = None,
        trailing: Optional[Widget] = None,
        dense: Optional[bool] = None,
        iconColor=None,
        textColor=None,
        titleTextStyle=None,
        subtitleTextStyle=None,
        contentPadding=None,
        enabled: bool = True,
        onTap=None,
        onLongPress=None,
        selected: bool = False,
        tileColor=None,
        selectedTileColor=None,
    ):
        super().__init__("ListTile", key=key)
        self.leading = leading
        self.title = title
        self.subtitle = subtitle
        self.trailing = trailing
        self.dense = dense
        self.iconColor = iconColor
        self.textColor = textColor
        self.titleTextStyle = titleTextStyle
        self.subtitleTextStyle = subtitleTextStyle
        self.contentPadding = contentPadding
        self.enabled = enabled
        self.onTap = onTap
        self.onLongPress = onLongPress
        self.selected = selected
        self.tileColor = tileColor
        self.selectedTileColor = selectedTileColor

    @override
    def _flut_pack(self) -> dict:
        result = self._flut_base_props()
        if self.leading is not None:
            result["leading"] = self.leading._flut_pack()
        if self.title is not None:
            result["title"] = self.title._flut_pack()
        if self.subtitle is not None:
            result["subtitle"] = self.subtitle._flut_pack()
        if self.trailing is not None:
            result["trailing"] = self.trailing._flut_pack()
        if self.dense is not None:
            result["dense"] = self.dense
        if self.iconColor is not None:
            result["iconColor"] = self.iconColor._flut_pack()
        if self.textColor is not None:
            result["textColor"] = self.textColor._flut_pack()
        if self.titleTextStyle is not None:
            result["titleTextStyle"] = self.titleTextStyle._flut_pack()
        if self.subtitleTextStyle is not None:
            result["subtitleTextStyle"] = self.subtitleTextStyle._flut_pack()
        if self.contentPadding is not None:
            result["contentPadding"] = self.contentPadding._flut_pack()
        result["enabled"] = self.enabled
        if self.onTap is not None:
            result["onTapId"] = self._register_action(self.onTap)
        if self.onLongPress is not None:
            result["onLongPressId"] = self._register_action(self.onLongPress)
        result["selected"] = self.selected
        if self.tileColor is not None:
            result["tileColor"] = self.tileColor._flut_pack()
        if self.selectedTileColor is not None:
            result["selectedTileColor"] = self.selectedTileColor._flut_pack()
        return result
