71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
|
using System.Collections.Generic;
|
||
|
using Assets.Sources.Core.DataBinding;
|
||
|
using TMPro;
|
||
|
using uMVVM.Sources.Infrastructure;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
namespace Game.MVVM.Model
|
||
|
{
|
||
|
public class MallScrollItemView : UnityGuiView<MallScrollItemViewModel>
|
||
|
{
|
||
|
private string icon;
|
||
|
private object data;
|
||
|
|
||
|
public Image imgIcon;
|
||
|
public TMP_Text txtName;
|
||
|
public TMP_Text txtCount;
|
||
|
public Button btnBuy;
|
||
|
|
||
|
protected override void OnInitialize()
|
||
|
{
|
||
|
base.OnInitialize();
|
||
|
this.Binder.Add<long>("ItemId", this.IdOnValueChanged);
|
||
|
this.Binder.Add<string>("ItemName", this.ItemNameOnValueChanged);
|
||
|
this.Binder.Add<string>("ItemIcon", this.ItemIconOnValueChanged);
|
||
|
this.Binder.Add<string>("ItemDesc", this.ItemDescOnValueChanged);
|
||
|
this.Binder.Add<int>("ItemCount", this.ItemCountOnValueChanged);
|
||
|
this.Binder.Add<object>("ItemData", this.ItemDataOnValueChanged);
|
||
|
|
||
|
this.btnBuy.onClick.AddListener(this.ClickButtonBuy);
|
||
|
}
|
||
|
|
||
|
private void ClickButtonBuy()
|
||
|
{
|
||
|
this.BindingContext.OnClickBuy?.Invoke(this.txtName.text, this.data);
|
||
|
}
|
||
|
|
||
|
private void ItemDataOnValueChanged(object oldvalue, object newvalue)
|
||
|
{
|
||
|
this.BindingContext.ItemData.Value = newvalue;
|
||
|
}
|
||
|
|
||
|
private void ItemIconOnValueChanged(string oldvalue, string newvalue)
|
||
|
{
|
||
|
this.BindingContext.ItemIcon.Value = newvalue;
|
||
|
this.icon = newvalue;
|
||
|
this.imgIcon = null;
|
||
|
}
|
||
|
|
||
|
private void ItemCountOnValueChanged(int oldvalue, int newvalue)
|
||
|
{
|
||
|
this.BindingContext.ItemCount.Value = newvalue;
|
||
|
this.txtCount.text = newvalue.ToString();
|
||
|
}
|
||
|
|
||
|
private void ItemDescOnValueChanged(string oldvalue, string newvalue)
|
||
|
{
|
||
|
this.BindingContext.ItemDesc.Value = newvalue;
|
||
|
}
|
||
|
|
||
|
private void ItemNameOnValueChanged(string oldvalue, string newvalue)
|
||
|
{
|
||
|
this.BindingContext.ItemName.Value = newvalue;
|
||
|
this.txtName.text = newvalue;
|
||
|
}
|
||
|
|
||
|
private void IdOnValueChanged(long oldvalue, long newvalue)
|
||
|
{
|
||
|
this.BindingContext.ItemId.Value = newvalue;
|
||
|
}
|
||
|
}
|
||
|
}
|