FriendAddView.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.Friend;
  4. using System.Collections.Generic;
  5. namespace GFGGame
  6. {
  7. public class FriendAddView : BaseWindow
  8. {
  9. private UI_FriendAddUI _ui;
  10. private List<int> _searchDatas = new List<int>();
  11. public override void Dispose()
  12. {
  13. if (_ui != null)
  14. {
  15. _ui.Dispose();
  16. _ui = null;
  17. }
  18. base.Dispose();
  19. }
  20. protected override void Init()
  21. {
  22. base.Init();
  23. packageName = UI_FriendAddUI.PACKAGE_NAME;
  24. _ui = UI_FriendAddUI.Create();
  25. this.viewCom = _ui.target;
  26. this.viewCom.Center();
  27. this.modal = true;
  28. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  29. _ui.m_listSearch.itemRenderer = RenderListSearchItem;
  30. _ui.m_btnSearch.onClick.Add(OnBtnSearchClick);
  31. _ui.m_btnClear.onClick.Add(OnBtnClearClick);
  32. _ui.m_btnRefresh.onClick.Add(OnBtnRefreshClick);
  33. _ui.m_listApply.itemRenderer = RenderListApplyItem;
  34. _ui.m_btnAgreeAll.onClick.Add(OnBtnAgreeAllClick);
  35. _ui.m_btnRefuseAll.onClick.Add(OnBtnRefuseAllClick);
  36. }
  37. protected override void OnInit()
  38. {
  39. base.OnInit();
  40. // _ui.m_c1.onChanged.Add(OnCtrlChange);
  41. }
  42. protected override void AddEventListener()
  43. {
  44. base.AddEventListener();
  45. }
  46. protected override void OnShown()
  47. {
  48. base.OnShown();
  49. _ui.m_c1.selectedIndex = 0;
  50. _ui.m_txtSearch.text = "";
  51. _ui.m_btnClear.visible = false;
  52. // OnCtrlChange();
  53. OnBtnRefreshClick();
  54. }
  55. protected override void OnHide()
  56. {
  57. base.OnHide();
  58. }
  59. protected override void RemoveEventListener()
  60. {
  61. base.RemoveEventListener();
  62. }
  63. /**************************************************好友搜索***********************************************/
  64. private void RenderListSearchItem(int index, GObject obj)
  65. {
  66. UI_ListSearchItem item = UI_ListSearchItem.Proxy(obj);
  67. if (item.m_btnAdd.data == null)
  68. {
  69. item.m_btnAdd.onClick.Add(OnBtnAddClick);
  70. }
  71. UI_ListSearchItem.ProxyEnd();
  72. }
  73. //添加好友
  74. private void OnBtnAddClick(EventContext context)
  75. {
  76. GObject obj = context.data as GObject;
  77. }
  78. //搜索好友
  79. private void OnBtnSearchClick()
  80. {
  81. if (_ui.m_txtSearch.text.Length < 2)
  82. {
  83. PromptController.Instance.ShowFloatTextPrompt("请输入至少两个字符");
  84. return;
  85. }
  86. bool result = true;
  87. if (result)
  88. {
  89. _ui.m_txtTips.text = "搜索结果";
  90. _ui.m_btnClear.visible = true;
  91. _searchDatas = null;
  92. _ui.m_listSearch.numItems = 0;
  93. }
  94. }
  95. //清空搜索
  96. private void OnBtnClearClick()
  97. {
  98. _ui.m_txtSearch.text = "";
  99. _ui.m_btnClear.visible = false;
  100. OnBtnRefreshClick();
  101. }
  102. //刷新好友列表
  103. private void OnBtnRefreshClick()
  104. {
  105. _ui.m_txtTips.text = "推荐好友";
  106. bool result = true;
  107. if (result)
  108. {
  109. _searchDatas = null;
  110. _ui.m_listSearch.numItems = 0;
  111. }
  112. }
  113. /**************************************************好友申请***********************************************/
  114. private void RenderListApplyItem(int index, GObject obj)
  115. {
  116. int data = _searchDatas[index];
  117. UI_ListApplyItem item = UI_ListApplyItem.Proxy();
  118. if (item.m_btnAgree.data == null)
  119. {
  120. item.m_btnAgree.onClick.Add(OnBtnAgreeClick);
  121. }
  122. if (item.m_btnRefuse.data == null)
  123. {
  124. item.m_btnRefuse.onClick.Add(OnBtnRefuseClick);
  125. }
  126. UI_ListApplyItem.ProxyEnd();
  127. }
  128. //通过好友申请
  129. private void OnBtnAgreeClick(EventContext context)
  130. {
  131. GObject obj = context.data as GObject;
  132. }
  133. //拒绝好友申请
  134. private void OnBtnRefuseClick(EventContext context)
  135. {
  136. GObject obj = context.data as GObject;
  137. }
  138. //一键通过好友申请
  139. private void OnBtnAgreeAllClick()
  140. {
  141. }
  142. //一键拒绝好友申请
  143. private void OnBtnRefuseAllClick()
  144. {
  145. AlertUI.Show("是否拒绝所有好友申请?").SetLeftButton(true).SetRightButton(true, "确定", (object data) =>
  146. {
  147. });
  148. }
  149. }
  150. }