/// <summary> /// 处理退出选项 /// </summary> private void ProcessQuitOptions(IntGroup viewGroup, QuitOptions options) { if (options.HasFlag(QuitOptions.LeaveStack)) { ProcessLeaveStack(viewGroup); } }
/// <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); }
/// <summary> /// 退出所有视图 /// </summary> /// <param name="options">选项</param> public void QuitAll(QuitOptions options = QuitOptions.None) { _tempQuitList.Clear(); foreach (int id in _viewDic.Keys) { _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(); } }
/// <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); }