GiftDetailView.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System.Threading.Tasks;
  2. using ET;
  3. using FairyGUI;
  4. using UI.DailyWelfare;
  5. namespace GFGGame
  6. {
  7. public class GiftDetailView : BaseWindow
  8. {
  9. private UI_GiftDetailUI _ui;
  10. public override void Dispose()
  11. {
  12. if (_ui != null)
  13. {
  14. _ui.Dispose();
  15. }
  16. _ui = null;
  17. base.Dispose();
  18. }
  19. protected override void OnHide()
  20. {
  21. base.OnHide();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. packageName = UI_GiftDetailUI.PACKAGE_NAME;
  27. _ui = UI_GiftDetailUI.Create();
  28. this.viewCom = _ui.target;
  29. this.viewCom.Center();
  30. this.modal = true;
  31. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  32. _ui.m_listGiftBag.itemRenderer = ListRewardItemRender;
  33. _ui.m_btnCheck.onClick.Add(OnBtnCheckClick);
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. int[][] gifts = (int[][])viewData;
  39. _ui.m_listGiftBag.data = gifts;
  40. _ui.m_listGiftBag.numItems = gifts.Length;
  41. _ui.m_listGiftBag.scrollPane.ScrollTop();
  42. }
  43. private void ListRewardItemRender(int index, GObject obj)
  44. {
  45. int[][] rewards = (int[][])obj.parent.data;
  46. if (obj.data == null)
  47. {
  48. obj.data = new ItemView(obj as GComponent);
  49. }
  50. ItemData itemData = ItemUtil.createItemData(rewards[index]);
  51. (obj.data as ItemView).SetData(itemData);
  52. (obj.data as ItemView).ChangeTxtCountStyle();
  53. }
  54. private void OnBtnCheckClick(EventContext context)
  55. {
  56. ViewManager.Hide<GiftDetailView>();
  57. }
  58. }
  59. }