< Summary

Class:UsersSearchPromptView
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/Views/UsersSearchPrompt/UsersSearchPromptView.cs
Covered lines:23
Uncovered lines:9
Coverable lines:32
Total lines:83
Line coverage:71.8% (23 of 32)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
OnDestroy()0%110100%
Update()0%2100%
Dispose()0%220100%
SetFriendListEmpty(...)0%110100%
ClearSearch()0%110100%
GetUsersBaseElement()0%2100%
GetUserElementsParent()0%2100%
Show()0%220100%
Hide()0%2100%
SetIdleSearchTime(...)0%2100%
ShowSearchSpinner()0%110100%
ShowClearButton()0%110100%
OnSearch(...)0%220100%
HideIfClickedOutside()0%20400%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/Views/UsersSearchPrompt/UsersSearchPromptView.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4internal class UsersSearchPromptView : MonoBehaviour, IDisposable
 5{
 6    public event Action<string> OnSearchText;
 7    public event Action OnShouldHide;
 8
 9    [SerializeField] internal SearchInputField searchInputField;
 10    [SerializeField] private GameObject emptyListGO;
 11    [SerializeField] internal Transform friendListParent;
 12    [SerializeField] private UserElementView userElementBase;
 13    [SerializeField] private ShowHideAnimator showHideAnimator;
 14
 15    private bool isDestroyed = false;
 16    private RectTransform rectTransform;
 17
 18    private void Awake()
 19    {
 720        rectTransform = GetComponent<RectTransform>();
 721        searchInputField.OnSearchText += OnSearch;
 722        SetFriendListEmpty(true);
 723        gameObject.SetActive(false);
 724    }
 25
 26    private void OnDestroy()
 27    {
 728        searchInputField.OnSearchText -= OnSearch;
 729        isDestroyed = true;
 730    }
 31
 032    private void Update() { HideIfClickedOutside(); }
 33
 34    public void Dispose()
 35    {
 2636        if (!isDestroyed)
 37        {
 2638            Destroy(gameObject);
 39        }
 2640    }
 41
 42    public void SetFriendListEmpty(bool isEmpty)
 43    {
 1944        emptyListGO.SetActive(isEmpty);
 1945        friendListParent.gameObject.SetActive(!isEmpty);
 1946    }
 47
 1248    public void ClearSearch() { searchInputField.ClearSearch(); }
 49
 050    public UserElementView GetUsersBaseElement() { return userElementBase; }
 51
 052    public Transform GetUserElementsParent() { return friendListParent; }
 53
 54    public void Show()
 55    {
 656        this.enabled = true;
 657        if (!gameObject.activeSelf)
 58        {
 659            gameObject.SetActive(true);
 60        }
 661        showHideAnimator.Show();
 662    }
 63
 064    public void Hide() { showHideAnimator.Hide(); }
 65
 066    public void SetIdleSearchTime(float idleSearchTime) { searchInputField.SetIdleSearchTime(idleSearchTime); }
 67
 468    public void ShowSearchSpinner() { searchInputField.ShowSearchSpinner(); }
 69
 270    public void ShowClearButton() { searchInputField.ShowSearchClearButton(); }
 71
 1672    private void OnSearch(string value) { OnSearchText?.Invoke(value); }
 73
 74    private void HideIfClickedOutside()
 75    {
 076        if (Input.GetMouseButtonDown(0) &&
 77            !RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition))
 78        {
 079            OnShouldHide?.Invoke();
 080            this.enabled = false;
 81        }
 082    }
 83}