{% extends 'user/layout.html.twig' %}

{% block title %}{{ parent() }}{% endblock %}

{% set pageNav = 'friend' %}

{% block main %}


<ul class="nav nav-pills mbl">
  <li {% if friendNav == 'following' %}class="active"{% endif %}><a href="{{ path('user_following', {id:user.id}) }}">{{'关注'|trans}}</a></li>
  <li {% if friendNav == 'follower' %}class="active"{% endif %}><a href="{{ path('user_follower', {id:user.id}) }}">{{'粉丝'|trans}}</a></li>
</ul>

<div class="row">
  {% for friend in friends if friends %}
    {% set isFollowed = (friend.id in myfollowings)|default(false) %}
    <div class="col-md-3">
      <div class="teacher-item">
        <div class="teacher-top">
          <a class="teacher-img" href="{{ path('user_show', {id:friend.id}) }}">
            <img class="avatar-lg" src="{{ filepath(friend.largeAvatar, 'avatar.png') }}" alt="">
          </a>
          <h3 class="title">
            <a class="link-dark" href="{{ path('user_show', {id:friend.id}) }}">{{ friend.nickname }}</a>
          </h3>
          <div class="position">
            {% if friend.title %}
              {{ friend.title|sub_text(12) }}
            {% else %}
              {{'暂无头衔'|trans}}
            {% endif %}
          </div>
        </div>

        <div class="teacher-bottom">
          <div class="about">
            {% if allUserProfile[friend.id]|default('') %}
              {{ allUserProfile[friend.id].about|sub_text(30) }}
            {% endif %}
          </div>
          <div class="metas">
            {% if not app.user or (friend.id != app.user.id) %}
              <a class="btn btn-primary btn-sm follow-btn" href="javascript:;" data-url="{{ path('user_follow', {id:friend.id}) }}" {% if isFollowed %} style="display:none;"{% endif %} data-loggedin={% if app.user and app.user.isLogin() %}"1"{% else %}"0"{% endif %}>{{'关注'|trans}}</a>
              <a class="btn btn-default btn-sm unfollow-btn" href="javascript:;" data-url="{{ path('user_unfollow', {id:friend.id}) }}" {% if not isFollowed %} style="display:none;" {% endif %}>{{'已关注'|trans}}</a>
              <a class="btn btn-default btn-sm" data-toggle="modal" data-target="#modal" data-backdrop="static"  data-url="{{path('message_create', {toId:friend.id})}}">{{'私信'|trans}}</a>
            {% endif %}
          </div>
        </div>
      </div>
    </div>
  {% else %}
    {% if friendNav == 'following' %}
      <div class="empty">{{'暂无关注！'|trans}}</div>
    {% elseif friendNav == 'follower' %}
      <div class="empty">{{'暂无粉丝！'|trans}}</div>
    {% endif %}
  {% endfor %}
</div>
{{ web_macro.paginator(paginator) }}

{% endblock %}