void OnProjectStateDataChanged(UIProjectStateData data)
 {
     if (data.projectSortData != m_CurrentProjectSortData)
     {
         m_CurrentProjectSortData = data.projectSortData;
         UpdateHeader();
     }
 }
        void OnSortButtonClicked()
        {
            ProjectListSortData sortData = UIStateManager.current.projectStateData.projectSortData;

            sortData.method    = (sortData.sortField != m_SortField || sortData.method == ProjectSortMethod.Descending) ? ProjectSortMethod.Ascending : ProjectSortMethod.Descending;
            sortData.sortField = m_SortField;
            Dispatcher.Dispatch(Payload <ActionTypes> .From(ActionTypes.SetProjectSortMethod, sortData));
        }
Esempio n. 3
0
        void SortProjects(ProjectListSortData sortData)
        {
            m_ScrollRect.verticalNormalizedPosition = 1;
            List <ProjectListItem> childrenProjectItems = m_ScrollViewContent.GetComponentsInChildren <ProjectListItem>(true).ToList();

            foreach (var projectItem in childrenProjectItems.ToList())
            {
                if (!projectItem.gameObject.activeInHierarchy)
                {
                    childrenProjectItems.Remove(projectItem);
                }
            }

            if (childrenProjectItems.Count == 0)
            {
                return;
            }

            var method = (sortData.method == ProjectSortMethod.Ascending) ? 1 : -1;

            switch (sortData.sortField)
            {
            case ProjectSortField.SortByDate:
                childrenProjectItems.Sort((project1, project2) => method * project2.room.project.lastPublished.CompareTo(project1.room.project.lastPublished));
                break;

            case ProjectSortField.SortByName:
                childrenProjectItems.Sort((project1, project2) => method * project1.room.project.name.CompareTo(project2.room.project.name));
                break;

            case ProjectSortField.SortByOrganization:
                childrenProjectItems.Sort((project1, project2) =>
                {
                    var org1 = project1.room.project?.UnityProject?.Organization?.Name ?? string.Empty;
                    var org2 = project2.room.project?.UnityProject?.Organization?.Name ?? string.Empty;
                    return(method * org1.CompareTo(org2));
                });
                break;

            case ProjectSortField.SortByServer:
                childrenProjectItems.Sort((project1, project2) => method * project1.room.project.host.ServerName.CompareTo(project2.room.project.host.ServerName));
                break;

            case ProjectSortField.SortByCollaborators:
                childrenProjectItems.Sort((project1, project2) => method * -project1.room.users.Count.CompareTo(project2.room.users.Count));
                break;

            default:
                childrenProjectItems.Sort((project1, project2) => method * project2.room.project.lastPublished.CompareTo(project1.room.project.lastPublished));
                break;
            }
            for (int i = 0; i < childrenProjectItems.Count; i++)
            {
                childrenProjectItems[i].gameObject.transform.SetSiblingIndex(i);
            }
        }
        void OnProjectStateDataChanged(UIProjectStateData data)
        {
            if (data.activeProject != m_CurrentActiveProject)
            {
                m_CurrentActiveProject  = data.activeProject;
                m_ActiveProjectListItem = m_ProjectListItems.FirstOrDefault(item => item.room.project == m_CurrentActiveProject);
            }

            if (m_ActiveProjectListItem != null && data.activeProjectThumbnail != m_ActiveProjectListItem.projectThumbnail)
            {
                m_ActiveProjectListItem.projectThumbnail = data.activeProjectThumbnail;
            }

            if (data.projectSortData != m_CurrentProjectSortData)
            {
                m_CurrentProjectSortData = data.projectSortData;
                SortProjects();
            }
        }
 void OnProjectSortDataChanged(ProjectListSortData newData)
 {
     UpdateHeader();
 }
Esempio n. 6
0
 void OnProjectSortDataChanged(ProjectListSortData newData)
 {
     SortProjects(newData);
 }
 void Start()
 {
     m_CurrentProjectSortData = UIStateManager.current.projectStateData.projectSortData;
     m_Button.onClick.AddListener(OnSortButtonClicked);
     UpdateHeader();
 }