getDefaultItem method

Widget getDefaultItem(
  1. GroupMember bannedMember,
  2. CometChatBannedMembersController controller,
  3. CometChatTheme theme,
  4. BuildContext context,
)

Implementation

Widget getDefaultItem(
  GroupMember bannedMember,
  CometChatBannedMembersController controller,
  CometChatTheme theme,
  BuildContext context,
) {
  Widget? subtitle;
  if (subtitleView != null) {
    subtitle = subtitleView!(bannedMember);
  }

  Color? backgroundColor;
  Widget? icon;

  StatusIndicatorUtils statusIndicatorUtils =
      StatusIndicatorUtils.getStatusIndicatorFromParams(
    isSelected: controller.selectionMap[bannedMember.uid] != null,
    theme: theme,
    groupMember: bannedMember,
    onlineStatusIndicatorColor:
        bannedMembersStyle.onlineStatusColor ?? theme.palette.getSuccess(),
    disableUsersPresence: disableUsersPresence,
  );

  backgroundColor = statusIndicatorUtils.statusIndicatorColor;
  icon = statusIndicatorUtils.icon;

  return GestureDetector(
    onLongPress: () {
      if (activateSelection == ActivateSelection.onLongClick &&
          controller.selectionMap.isEmpty &&
          !(selectionMode == null || selectionMode == SelectionMode.none)) {
        controller.onTap(bannedMember);

        _isSelectionOn.value = true;
      } else if (onItemLongPress != null) {
        onItemLongPress!(bannedMember);
      }
    },
    onTap: () {
      if (activateSelection == ActivateSelection.onClick ||
          (activateSelection == ActivateSelection.onLongClick &&
                  controller.selectionMap.isNotEmpty) &&
              !(selectionMode == null ||
                  selectionMode == SelectionMode.none)) {
        controller.onTap(bannedMember);
        if (controller.selectionMap.isEmpty) {
          _isSelectionOn.value = false;
        } else if (activateSelection == ActivateSelection.onClick &&
            controller.selectionMap.isNotEmpty &&
            _isSelectionOn.value == false) {
          _isSelectionOn.value = true;
        }
      } else if (onItemTap != null) {
        onItemTap!(bannedMember);
      }
    },
    child: CometChatListItem(
      key: UniqueKey(),
      id: bannedMember.uid,
      avatarName: bannedMember.name,
      avatarURL: bannedMember.avatar,
      title: bannedMember.name,
      subtitleView: subtitle,
      statusIndicatorColor:
          disableUsersPresence == false ? backgroundColor : null,
      statusIndicatorIcon: disableUsersPresence == false ? icon : null,
      statusIndicatorStyle:
          statusIndicatorStyle ?? const StatusIndicatorStyle(),
      avatarStyle: avatarStyle ?? const AvatarStyle(),
      tailView: Text(
        cc.Translations.of(context).banned,
        style: bannedMembersStyle.tailTextStyle ??
            TextStyle(
                fontSize: theme.typography.text1.fontSize,
                fontWeight: theme.typography.text1.fontWeight,
                color: theme.palette.getAccent500()),
      ),
      style: ListItemStyle(
          background: listItemStyle?.background ?? Colors.transparent,
          titleStyle: listItemStyle?.titleStyle ??
              TextStyle(
                  fontSize: theme.typography.name.fontSize,
                  fontWeight: theme.typography.name.fontWeight,
                  fontFamily: theme.typography.name.fontFamily,
                  color: theme.palette.getAccent()),
          height: listItemStyle?.height,
          border: listItemStyle?.border,
          borderRadius: listItemStyle?.borderRadius,
          gradient: listItemStyle?.gradient,
          separatorColor: listItemStyle?.separatorColor,
          width: listItemStyle?.width),
      options: options != null
          ? options!(group, bannedMember, controller, context)
          : controller.defaultFunction(group, bannedMember),
    ),
  );
}