コード例 #1
0
        /// <summary>
        /// 退出视图
        /// </summary>
        /// <param name="viewId">视图id</param>
        /// <param name="options">选项</param>
        /// <param name="callback">退出完成回调</param>
        public void Quit(int viewId, QuitOptions options = QuitOptions.None, Action callback = null)
        {
            ViewState state;

            if (_viewDic.TryGetValue(viewId, out state))
            {
                if (state.active)
                {
                    state.active     = false;
                    _viewDic[viewId] = state;

                    OnViewQuitStartEvent?.Invoke(viewId);

                    _uiModule?.Quit(viewId, () =>
                    {
                        callback?.Invoke();
                        _uiModule?.UnFocus(viewId);
                        OnViewQuitCompletedEvent?.Invoke(viewId);
                    }, options.HasFlag(QuitOptions.Destroy));
                }
                else
                {
                    callback?.Invoke();
                }
            }
            else
            {
                callback?.Invoke();
            }

            ProcessQuitOptions(IntGroup.Get(viewId), options);
        }
コード例 #2
0
 /// <summary>
 /// 预加载
 /// </summary>
 public void Preload(IntGroup viewGroup, bool instantiate = true)
 {
     for (int i = 0; i < viewGroup.Count; i++)
     {
         Preload(viewGroup[i], instantiate);
     }
 }
コード例 #3
0
        /// <summary>
        /// 进入视图
        /// </summary>
        /// <param name="viewId">视图id</param>
        /// <param name="options">选项</param>
        /// <param name="callback">进入完成回调</param>
        public void Enter(int viewId, EnterOptions options = EnterOptions.None, Action callback = null)
        {
            ProcessEnterOptions(IntGroup.Get(viewId), options);

            ViewState state;

            _viewDic.TryGetValue(viewId, out state);

            if (!state.active)
            {
                state.active     = true;
                _viewDic[viewId] = state;

                OnViewEnterStartEvent?.Invoke(viewId);

                _uiModule?.Enter(viewId, () =>
                {
                    callback?.Invoke();
                    _uiModule?.Focus(viewId);
                    OnViewEnterCompletedEvent?.Invoke(viewId);
                });
            }
            else
            {
                _uiModule?.Focus(viewId);
                callback?.Invoke();
            }
        }
コード例 #4
0
 /// <summary>
 /// 取消焦点
 /// </summary>
 /// <param name="viewGroup">视图组</param>
 public void UnFocus(IntGroup viewGroup)
 {
     for (int i = 0; i < viewGroup.Count; i++)
     {
         UnFocus(viewGroup[i]);
     }
 }
コード例 #5
0
 /// <summary>
 /// 处理退出选项
 /// </summary>
 private void ProcessQuitOptions(IntGroup viewGroup, QuitOptions options)
 {
     if (options.HasFlag(QuitOptions.LeaveStack))
     {
         ProcessLeaveStack(viewGroup);
     }
 }
コード例 #6
0
        /// <summary>
        /// 处理出栈
        /// </summary>
        private void ProcessLeaveStack(IntGroup viewGroup)
        {
            _viewStack.Delete(viewGroup);

            for (int i = 0; i < _viewStack.Count; i++)
            {
                IntGroup view = _viewStack[i];

                IntGroup resultView = view - viewGroup;

                _viewStack[i] = resultView;
            }
        }
コード例 #7
0
        /// <summary>
        /// 弹出视图
        /// 回到上一级视图
        /// </summary>
        /// <param name="callback">完成回调</param>
        /// <returns>是否弹出成功</returns>
        public bool Pop(Action callback = null)
        {
            bool res = false;

            IntGroup curId = IntGroup.Empty;
            IntGroup dstId = IntGroup.Empty;

            if (_viewStack.Count > 1)
            {
                if (_viewStack.Peek(out curId))
                {
                    //当前视图组 是否有视图激活
                    bool curActive = false;

                    for (int i = 0; i < curId.Count; i++)
                    {
                        ViewState state = _viewDic.GetValueAnyway(curId[i]);

                        if (state.active)
                        {
                            curActive = true;
                            break;
                        }
                    }

                    if (curActive) //栈顶界面有显示的,则出栈并隐藏 显示上一级界面
                    {
                        if (_viewStack.Pop(out curId) && _viewStack.Peek(out dstId))
                        {
                            res = true;

                            IntGroup toQuit = curId - dstId;

                            Quit(toQuit, QuitOptions.None, () =>
                            {
                                Enter(dstId, EnterOptions.None, callback);
                            });
                        }
                    }
                    else //栈顶界面无显示,则显示栈顶界面
                    {
                        res = true;

                        Enter(curId, EnterOptions.None, callback);
                    }
                }
            }

            return(res);
        }
コード例 #8
0
        /// <summary>
        /// 合并栈顶并入栈
        /// </summary>
        private void ProcessPushCombineStackTop(IntGroup viewGroup)
        {
            IntGroup top = IntGroup.Empty;

            if (_viewStack.Peek(out top))
            {
                IntGroup newTop = IntGroup.Combine(top, viewGroup);
                _viewStack.Push(newTop);
            }
            else
            {
                _viewStack.Push(viewGroup);
            }
        }
コード例 #9
0
 /// <summary>
 /// 处理驻留选项
 /// </summary>
 private void ProcessStayOptions(IntGroup viewGroup, StayOptions options)
 {
     if (options.HasFlag(StayOptions.PushStack) && !options.HasFlag(StayOptions.CombineStackTop))
     {
         ProcessPushStack(viewGroup);
     }
     else if (options.HasFlag(StayOptions.PushStack) && options.HasFlag(StayOptions.CombineStackTop))
     {
         ProcessPushCombineStackTop(viewGroup);
     }
     else if (!options.HasFlag(StayOptions.PushStack) && options.HasFlag(StayOptions.CombineStackTop))
     {
         ProcessCombineStackTop(viewGroup);
     }
 }
コード例 #10
0
        /// <summary>
        /// 退出视图
        /// </summary>
        /// <param name="viewGroup">视图组</param>
        /// <param name="options">选项</param>
        /// <param name="callback">完成回调</param>
        public void Quit(IntGroup viewGroup, QuitOptions options = QuitOptions.None, Action callback = null)
        {
            int all  = viewGroup.Count;
            int done = 0;

            for (int i = 0; i < all; i++)
            {
                Quit(viewGroup[i], QuitOptionsFilter(QuitOptions.LeaveStack, options), () =>
                {
                    done++;
                    if (done >= all)
                    {
                        callback?.Invoke();
                    }
                });
            }

            ProcessQuitOptions(viewGroup, options);
        }
コード例 #11
0
        /// <summary>
        /// 进入视图
        /// </summary>
        /// <param name="viewGroup">视图组</param>
        /// <param name="options">选项</param>
        /// <param name="callback">进入完成回调</param>
        public void Enter(IntGroup viewGroup, EnterOptions options = EnterOptions.None, Action callback = null)
        {
            ProcessEnterOptions(viewGroup, options);

            int all  = viewGroup.Count;
            int done = 0;

            for (int i = 0; i < all; i++)
            {
                Enter(viewGroup[i], EnterOptionsFilter(EnterOptions.CombineStackTop | EnterOptions.PushStack, options), () =>
                {
                    done++;
                    if (done >= all)
                    {
                        callback?.Invoke();
                    }
                });
            }
        }
コード例 #12
0
        /// <summary>
        /// 退出所有视图
        /// 会有部分视图驻留
        /// </summary>
        /// <param name="stayViewGroup">驻留视图组</param>
        /// <param name="options">退出的视图选项</param>
        /// <param name="stayOptions">驻留的视图选项</param>
        public void QuitAll(IntGroup stayViewGroup, QuitOptions options = QuitOptions.None, StayOptions stayOptions = StayOptions.None)
        {
            _tempQuitList.Clear();

            foreach (int id in _viewDic.Keys)
            {
                if (!stayViewGroup.Contains(id))
                {
                    _tempQuitList.Add(id);
                }
            }

            for (int i = 0; i < _tempQuitList.Count; i++)
            {
                Quit(_tempQuitList[i], QuitOptionsFilter(QuitOptions.LeaveStack, options), null);
            }

            if (options.HasFlag(QuitOptions.LeaveStack))
            {
                ResetStack();
            }

            ProcessStayOptions(stayViewGroup, stayOptions);
        }
コード例 #13
0
 /// <summary>
 /// 进入视图
 /// </summary>
 /// <param name="viewGroup">视图组</param>
 /// <param name="options">选项</param>
 /// <param name="callback">进入完成回调</param>
 public void Enter(IntGroup viewGroup, EnterOptions options = EnterOptions.None, Action callback = null)
 {
     _module.Enter(viewGroup, options, callback);
 }
コード例 #14
0
 /// <summary>
 /// 预加载
 /// </summary>
 /// <param name="viewGroup">视图组</param>
 /// <param name="instantiate">创建界面实体标识</param>
 public void Preload(IntGroup viewGroup, bool instantiate = true)
 {
     _module.Preload(viewGroup, instantiate);
 }
コード例 #15
0
 /// <summary>
 /// 退出所有视图
 /// 会有部分视图驻留
 /// </summary>
 /// <param name="stayViewGroup">驻留视图组</param>
 /// <param name="options">退出的视图选项</param>
 /// <param name="stayOptions">驻留的视图选项</param>
 public void QuitAll(IntGroup stayViewGroup, QuitOptions options = QuitOptions.None, StayOptions stayOptions = StayOptions.None)
 {
     _module.QuitAll(stayViewGroup, options, stayOptions);
 }
コード例 #16
0
 /// <summary>
 /// 取消焦点
 /// </summary>
 /// <param name="viewGroup">视图组</param>
 public void UnFocus(IntGroup viewGroup)
 {
     _module.UnFocus(viewGroup);
 }
コード例 #17
0
 /// <summary>
 /// 退出视图
 /// </summary>
 /// <param name="viewGroup">视图组</param>
 /// <param name="options">选项</param>
 /// <param name="callback">完成回调</param>
 public void Quit(IntGroup viewGroup, QuitOptions options = QuitOptions.None, Action callback = null)
 {
     _module.Quit(viewGroup, options, callback);
 }
コード例 #18
0
 /// <summary>
 /// 退出所有视图
 /// 会有部分视图驻留
 /// </summary>
 /// <param name="stayViewId">驻留视图</param>
 /// <param name="options">退出的视图选项</param>
 /// <param name="stayOptions">驻留的视图选项</param>
 public void QuitAll(int stayViewId, QuitOptions options = QuitOptions.None, StayOptions stayOptions = StayOptions.None)
 {
     QuitAll(IntGroup.Get(stayViewId), options, stayOptions);
 }
コード例 #19
0
 /// <summary>
 /// 处理入栈
 /// </summary>
 private void ProcessPushStack(IntGroup viewGroup)
 {
     _viewStack.Push(viewGroup);
 }