Exemplo n.º 1
0
 private void Awake()
 {
     UIItemClearOnClicked = mBtnClear.OnClickAsObservable().Select(_ => mItemModel.Id);
     UIItemBgOnClicked    = mImgBg.OnPointerClickAsObservable().Select(_ => mItemModel.Id);
     UIItemBgOnClicked.Subscribe(_ =>
     {
         mHightLight.enabled = true;
     });                                                                                                          //变false
     RPLink.GetRp(RPLink.EventMaskEnable).Where(e => !e).Subscribe(e => mHightLight.enabled = false).AddTo(this); //订阅全局rp
 }
Exemplo n.º 2
0
        private void AddUIItem(TodoItem itemModel)
        {
            var UiItem = Object.Instantiate(mItemPrf).GetComponent <UIItem>();//实例化UIprefab

            UiItem.transform.SetParent(mItemsRoot, false);
            UiItem.SetItemModel(itemModel);//给uiItem数据
            UiItem.UIItemClearOnClicked.Subscribe(id =>
            {
                mItemModelLst.RemoveItem(id);
                Object.Destroy(UiItem.gameObject);
            });
            UiItem.UIItemBgOnClicked.Subscribe(id =>
            {
                mCurClickedUiId = id;
                RPLink.GetRp(RPLink.EventMaskEnable).Value = true;//修改全局rp,以通知他处
            });
        }
Exemplo n.º 3
0
        private void Start()
        {
            //把输入框是否为空转化成一个bool值 关联 按钮 的禁用显示
            mIptContent.OnValueChangedAsObservable().Select(str => string.IsNullOrEmpty(str)).Subscribe(
                emptyIpt =>
            {
                mBtnSure.interactable = !emptyIpt;
                if (!emptyIpt)
                {
                    mBtnCancel.image.enabled = true;
                }
                else if (!mImgEventMask.enabled)
                {
                    mBtnCancel.image.enabled = false;
                }
            });

            //确认按钮点击
            mBtnSure.OnClickAsObservable().Subscribe(
                _ =>
            {
                if (!mImgEventMask.enabled)     //非修改模式下 添加待办事项(仅用遮罩得enable来代表是否修改模式)
                {
                    mItemsLstCtl.AddUIItem(mIptContent.text);
                }
                else     // 修改模式下 修改当前选中的待办事项 (当前选中逻辑由列表控制器负责)
                {
                    mItemsLstCtl.ModifyUIItem(mIptContent.text);
                }
                //重置一切
                mIptContent.text         = "";
                mBtnCancel.image.enabled = false;
                RPLink.GetRp(RPLink.EventMaskEnable).Value = false;
            });
            //订阅一个全局的reaciveProperty(全局可修改可订阅) 他在此处用来关联遮罩的开启与否
            RPLink.GetRp(RPLink.EventMaskEnable).Subscribe(
                enabled =>
            {
                mImgEventMask.enabled = enabled; //直接关联遮罩的enable
                if (enabled)                     //如果从false变成了true
                {
                    mIptContent.Select();
                    mIptContent.text = mItemsLstCtl.GetCurUIContent();
                }
                else
                {
                    mIptContent.text         = "";
                    mBtnCancel.image.enabled = false;
                }
            });

            //遮罩开启时才有的点击事件
            mImgEventMask.OnPointerClickAsObservable().Subscribe(_ => RPLink.GetRp(RPLink.EventMaskEnable).Value = false);
            //取消输入按钮
            mBtnCancel.OnClickAsObservable().Subscribe(_ =>
            {
                if (mIptContent.text == "")
                {
                    RPLink.GetRp(RPLink.EventMaskEnable).Value = false;
                    mBtnCancel.image.enabled = false;
                }
                else
                {
                    mIptContent.text = "";
                }
            });
        }
Exemplo n.º 4
0
 private ItemsListCtl mItemsLstCtl;//items列表的控制器
 private void Awake()
 {
     mItemsLstCtl = new ItemsListCtl(mItemsRoot);
     RPLink.GetRp(RPLink.EventMaskEnable).Value = false;//一个全局的reactiveProperty 用来表示遮罩的enable
 }