getStatusIndicatorFromParams static method

StatusIndicatorUtils getStatusIndicatorFromParams({
  1. bool? isSelected,
  2. required CometChatTheme theme,
  3. User? user,
  4. Group? group,
  5. GroupMember? groupMember,
  6. Widget? protectedGroupIcon,
  7. Widget? privateGroupIcon,
  8. Color? onlineStatusIndicatorColor,
  9. Color? privateGroupIconBackground,
  10. Color? protectedGroupIconBackground,
  11. bool? disableUsersPresence,
  12. Widget? selectIcon,
  13. Color? selectIconTint,
})

Implementation

static StatusIndicatorUtils getStatusIndicatorFromParams(
    {bool? isSelected,
    required CometChatTheme theme,
    User? user,
    Group? group,
    GroupMember? groupMember,
    Widget? protectedGroupIcon,
    Widget? privateGroupIcon,
    Color? onlineStatusIndicatorColor,
    Color? privateGroupIconBackground,
    Color? protectedGroupIconBackground,
    bool? disableUsersPresence,
    Widget? selectIcon,
    Color? selectIconTint}) {
  Color? backgroundColor;
  Widget? icon;
  //TODO add icons color to other icons when needed
  if (isSelected == true) {
    // backgroundColor = theme.palette.getSuccess();
    backgroundColor = theme.palette.getPrimary();
    icon = selectIcon ??
        Icon(
          Icons.check,
          color: selectIconTint ?? Colors.white,
          size: 12,
        );
  } else if (user != null && disableUsersPresence != true) {
    backgroundColor =
        user.status != null && user.status == UserStatusConstants.online
            ? (onlineStatusIndicatorColor ?? theme.palette.getSuccess())
            : null;
  } else if (group != null) {
    if (group.type == GroupTypeConstants.password) {
      backgroundColor =
          protectedGroupIconBackground ?? const Color(0xffF7A500);
      icon = protectedGroupIcon ??
          const Icon(
            Icons.lock,
            color: Colors.white,
            size: 7,
          );
    } else if (group.type == GroupTypeConstants.private) {
      backgroundColor =
          privateGroupIconBackground ?? theme.palette.getSuccess();
      icon = privateGroupIcon ??
          const Icon(Icons.back_hand, color: Colors.white, size: 7);
    }
  } else if (groupMember != null) {
    backgroundColor = groupMember.status != null &&
            groupMember.status == UserStatusConstants.online
        ? theme.palette.getSuccess()
        : null;
  }
  StatusIndicatorUtils utility = StatusIndicatorUtils();
  utility.icon = icon;
  utility.statusIndicatorColor = backgroundColor;
  return utility;
}