using System.Linq;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
public class FairySiegeBaseDonateInfoWin : Window
|
{
|
[SerializeField] ButtonEx btnClose;
|
[SerializeField] TextEx txtQuery;
|
[SerializeField] TextEx txtNoResult;
|
[SerializeField] ScrollerController scroller;
|
FairySiegeActModel model { get { return ModelCenter.Instance.GetModel<FairySiegeActModel>(); } }
|
|
#region Build-in
|
|
protected override void AddListeners()
|
{
|
btnClose.SetListener(CloseClick);
|
}
|
|
protected override void BindController()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
txtQuery.SetActive(model.contributionInfoDict.IsNullOrEmpty());
|
txtNoResult.SetActive(false);
|
scroller.Refresh();
|
scroller.Restart();
|
scroller.OnRefreshCell += OnRefreshCell;
|
model.UpdateFamilyGCZContributionInfoEvent += OnUpdateFamilyGCZContributionInfoEvent;
|
model.SendQuery(1, 0, 0, 0);
|
}
|
|
protected override void OnPreClose()
|
{
|
scroller.OnRefreshCell -= OnRefreshCell;
|
model.UpdateFamilyGCZContributionInfoEvent -= OnUpdateFamilyGCZContributionInfoEvent;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
#endregion
|
|
private void OnUpdateFamilyGCZContributionInfoEvent()
|
{
|
txtQuery.SetActive(false);
|
CreateScroller();
|
}
|
|
private void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetComponent<FairySiegeBaseDonateInfoCell>();
|
_cell?.Display(cell.index);
|
}
|
|
private void CreateScroller()
|
{
|
scroller.Refresh();
|
bool isNullOrEmpty = model.contributionInfoDict.IsNullOrEmpty();
|
txtNoResult.SetActive(isNullOrEmpty);
|
if (!isNullOrEmpty)
|
{
|
var list = model.contributionInfoDict.Keys.ToList();
|
list.Sort((a, b) =>
|
{
|
uint contributionValueA = model.contributionInfoDict[a];
|
uint contributionValueB = model.contributionInfoDict[b];
|
return contributionValueB.CompareTo(contributionValueA);
|
});
|
foreach (var item in list)
|
{
|
scroller.AddCell(ScrollerDataType.Header, (int)item);
|
}
|
}
|
scroller.Restart();
|
}
|
}
|
}
|