GiftDetailView.cs 1.9 KB

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