| | 1 | | using DCL.Helpers; |
| | 2 | | using System; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL.MyAccount |
| | 6 | | { |
| | 7 | | public class BlockedListComponentView : BaseComponentView, IBlockedListComponentView |
| | 8 | | { |
| | 9 | | [Header("General")] |
| | 10 | | [SerializeField] internal GameObject mainContainer; |
| | 11 | | [SerializeField] internal GameObject loadingContainer; |
| | 12 | | [SerializeField] internal RectTransform contentTransform; |
| | 13 | | [SerializeField] internal GameObject scrollBar; |
| | 14 | | [SerializeField] internal CollapsableSortedBlockedEntryList blockedList; |
| | 15 | |
|
| | 16 | | public event Action<string> OnUnblockUser; |
| | 17 | |
|
| | 18 | | public void SetupBlockedList() |
| | 19 | | { |
| 0 | 20 | | blockedList.OnUnblockUser = OnUnblockUser; |
| | 21 | | int SortByAlphabeticalOrder(BlockedUserEntry u1, BlockedUserEntry u2) |
| | 22 | | { |
| 0 | 23 | | return string.Compare(u1.Model.userName, u2.Model.userName, StringComparison.InvariantCultureIgnoreCase) |
| | 24 | | } |
| | 25 | |
|
| 0 | 26 | | blockedList.SortingMethod = SortByAlphabeticalOrder; |
| 0 | 27 | | } |
| | 28 | |
|
| | 29 | | public void Set(BlockedUserEntryModel user) |
| | 30 | | { |
| 0 | 31 | | blockedList.Set(user.userId, user); |
| 0 | 32 | | RefreshContentLayout(); |
| 0 | 33 | | } |
| | 34 | |
|
| | 35 | | public void Remove(string userId) |
| | 36 | | { |
| 0 | 37 | | blockedList.Remove(userId); |
| 0 | 38 | | RefreshContentLayout(); |
| 0 | 39 | | } |
| | 40 | |
|
| | 41 | | public void ClearAllEntries() |
| | 42 | | { |
| 0 | 43 | | blockedList.Clear(); |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | public override void Show(bool instant = false) |
| | 47 | | { |
| 0 | 48 | | gameObject.SetActive(true); |
| | 49 | |
|
| 0 | 50 | | if (scrollBar != null) |
| 0 | 51 | | scrollBar.SetActive(true); |
| 0 | 52 | | } |
| | 53 | |
|
| | 54 | | public override void Hide(bool instant = false) |
| | 55 | | { |
| 0 | 56 | | gameObject.SetActive(false); |
| | 57 | |
|
| 0 | 58 | | if (scrollBar != null) |
| 0 | 59 | | scrollBar.SetActive(false); |
| 0 | 60 | | } |
| | 61 | |
|
| | 62 | | public void SetLoadingActive(bool isActive) |
| | 63 | | { |
| 0 | 64 | | loadingContainer.SetActive(isActive); |
| 0 | 65 | | mainContainer.SetActive(!isActive); |
| 0 | 66 | | } |
| | 67 | |
|
| | 68 | | public void RefreshContentLayout() => |
| 0 | 69 | | Utils.ForceRebuildLayoutImmediate(contentTransform); |
| | 70 | |
|
| | 71 | | public override void RefreshControl() |
| | 72 | | { |
| 0 | 73 | | } |
| | 74 | | } |
| | 75 | | } |