123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- using UnityEngine;
- using FairyGUI;
- using UI.Friend;
- using System.Collections.Generic;
- namespace GFGGame
- {
- public class FriendAddView : BaseWindow
- {
- private UI_FriendAddUI _ui;
- private List<int> _searchDatas = new List<int>();
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void Init()
- {
- base.Init();
- packageName = UI_FriendAddUI.PACKAGE_NAME;
- _ui = UI_FriendAddUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- _ui.m_listSearch.itemRenderer = RenderListSearchItem;
- _ui.m_btnSearch.onClick.Add(OnBtnSearchClick);
- _ui.m_btnClear.onClick.Add(OnBtnClearClick);
- _ui.m_btnRefresh.onClick.Add(OnBtnRefreshClick);
- _ui.m_listApply.itemRenderer = RenderListApplyItem;
- _ui.m_btnAgreeAll.onClick.Add(OnBtnAgreeAllClick);
- _ui.m_btnRefuseAll.onClick.Add(OnBtnRefuseAllClick);
- }
- protected override void OnInit()
- {
- base.OnInit();
- // _ui.m_c1.onChanged.Add(OnCtrlChange);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void OnShown()
- {
- base.OnShown();
- _ui.m_c1.selectedIndex = 0;
- _ui.m_txtSearch.text = "";
- _ui.m_btnClear.visible = false;
- // OnCtrlChange();
- OnBtnRefreshClick();
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- /**************************************************好友搜索***********************************************/
- private void RenderListSearchItem(int index, GObject obj)
- {
- UI_ListSearchItem item = UI_ListSearchItem.Proxy(obj);
- if (item.m_btnAdd.data == null)
- {
- item.m_btnAdd.onClick.Add(OnBtnAddClick);
- }
- UI_ListSearchItem.ProxyEnd();
- }
- //添加好友
- private void OnBtnAddClick(EventContext context)
- {
- GObject obj = context.data as GObject;
- }
- //搜索好友
- private void OnBtnSearchClick()
- {
- if (_ui.m_txtSearch.text.Length < 2)
- {
- PromptController.Instance.ShowFloatTextPrompt("请输入至少两个字符");
- return;
- }
- bool result = true;
- if (result)
- {
- _ui.m_txtTips.text = "搜索结果";
- _ui.m_btnClear.visible = true;
- _searchDatas = null;
- _ui.m_listSearch.numItems = 0;
- }
- }
- //清空搜索
- private void OnBtnClearClick()
- {
- _ui.m_txtSearch.text = "";
- _ui.m_btnClear.visible = false;
- OnBtnRefreshClick();
- }
- //刷新好友列表
- private void OnBtnRefreshClick()
- {
- _ui.m_txtTips.text = "推荐好友";
- bool result = true;
- if (result)
- {
- _searchDatas = null;
- _ui.m_listSearch.numItems = 0;
- }
- }
- /**************************************************好友申请***********************************************/
- private void RenderListApplyItem(int index, GObject obj)
- {
- int data = _searchDatas[index];
- UI_ListApplyItem item = UI_ListApplyItem.Proxy();
- if (item.m_btnAgree.data == null)
- {
- item.m_btnAgree.onClick.Add(OnBtnAgreeClick);
- }
- if (item.m_btnRefuse.data == null)
- {
- item.m_btnRefuse.onClick.Add(OnBtnRefuseClick);
- }
- UI_ListApplyItem.ProxyEnd();
- }
- //通过好友申请
- private void OnBtnAgreeClick(EventContext context)
- {
- GObject obj = context.data as GObject;
- }
- //拒绝好友申请
- private void OnBtnRefuseClick(EventContext context)
- {
- GObject obj = context.data as GObject;
- }
- //一键通过好友申请
- private void OnBtnAgreeAllClick()
- {
- }
- //一键拒绝好友申请
- private void OnBtnRefuseAllClick()
- {
- AlertUI.Show("是否拒绝所有好友申请?").SetLeftButton(true).SetRightButton(true, "确定", (object data) =>
- {
- });
- }
- }
- }
|