buildMainWidget method

Widget buildMainWidget(
  1. BuildContext context,
  2. Color color
)

Implementation

Widget buildMainWidget(BuildContext context, Color color) {
  var isFirst = ItemPosition.of(context)?.isFirst ?? false;
  var isLast = ItemPosition.of(context)?.isLast ?? false;
  var isSelected = ItemListBehavior.of(context)?.isSelected ?? false;

  var borderRadius = BorderRadius.only(
      bottomLeft: isLast ? Radius.circular(30) : Radius.zero,
      bottomRight: isLast ? Radius.circular(30) : Radius.zero,
      topLeft: isFirst ? Radius.circular(30) : Radius.zero,
      topRight: isFirst ? Radius.circular(30) : Radius.zero);
  return Material(
    borderRadius: borderRadius,
    color: color,
    child: InkWell(
      borderRadius: borderRadius,
      onTap:
          (ItemListBehavior.of(context)?.onTapList != null || onTap != null)
              ? () {
                  if (ItemListBehavior.of(context)?.onTapList?.call() ?? true)
                    onTap?.call();
                }
              : null,
      onHover: onHover,
      onLongPress: ItemListBehavior.of(context)?.onLongTapList,
      child: Column(
        children: <Widget>[
          Container(
            width: MediaQuery.of(context).size.width,
            decoration: BoxDecoration(
              borderRadius: borderRadius,
            ),
            child: Row(
              children: <Widget>[
                leading != null || leadingIcon != null
                    ? Padding(
                        padding:
                            EdgeInsets.symmetric(horizontal: 15, vertical: 8),
                        child: Container(
                          width: 45,
                          height: 42,
                          child: Stack(
                            alignment: Alignment.center,
                            children: <Widget>[
                              leading ??
                                  Icon(
                                    leadingIcon,
                                    color: DefaultColors.text,
                                    size: 30,
                                  ),
                              isSelected
                                  ? Container(
                                      width: 40,
                                      height: 40,
                                      decoration: BoxDecoration(
                                          color: DefaultColors.selected
                                              .withOpacity(0.7),
                                          borderRadius:
                                              BorderRadius.circular(20)),
                                      child: Icon(
                                        Icons.check,
                                        color: DefaultColors.backgroundItem,
                                      ),
                                    )
                                  : Container(),
                            ],
                          ),
                        ),
                      )
                    : Container(
                        width: 20,
                      ),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      title != null
                          ? DefaultTextStyle(
                              style: TextStyles.textStyleSize(17)
                                  .copyWith(color: DefaultColors.text),
                              child: title!)
                          : Container(),
                      description != null
                          ? DefaultTextStyle(
                              style: TextStyles.textStyleSize(13)
                                  .copyWith(color: DefaultColors.textLight),
                              child: description!)
                          : Container(),
                    ],
                  ),
                ),
                Padding(
                  padding:
                      const EdgeInsets.symmetric(horizontal: 15, vertical: 0),
                  child: trailing ?? Container(),
                ),
              ],
            ),
          ),
          !isLast
              ? Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 20),
                  child: Divider(
                    color: DefaultColors.backgroundOutline,
                    height: 1.1,
                    thickness: 1.1,
                  ),
                )
              : Container()
        ],
      ),
    ),
  );
}