//模态窗口 public void Open(Type type, object args = null) { bool isNeedCreate = true; bool isNeedAdd = true; ViewInfo viewInfo = null; if (m_viewsMap.TryGetValue(type, out viewInfo)) { FView view = viewInfo.view; if (IsOpened(type)) { //XXX:置顶到顶层:判断是否被遮挡,通过移除在添加的方式 if (GRoot.inst.numChildren > 0) { if (GRoot.inst.GetChildAt(GRoot.inst.numChildren - 1) != view.GetObject()) { Close(__GetViewKey(view), false); } else { isNeedAdd = false; isNeedCreate = false; } } } if (isNeedAdd) { if (!view.IsDisposed()) { view.__OpenByManager(args); isNeedCreate = false; } } } if (isNeedCreate) { //加载View FView.Create(type, (fWidget) => { FView fView = (FView)fWidget; viewInfo = new ViewInfo(); viewInfo.view = fView; m_viewsMap[type] = viewInfo; m_onCreated?.Invoke(viewInfo); fView.__OpenByManager(args); }, args); } }
private void __InitBarList() { _barList = GetChild <FList>(barListName); if (_barList != null) { _barList.SetVirtual(); _barList.SetState((index, data, comp) => { var viewParams = data as ViewParams; var title = comp.GetChild <FRichText>("title"); title.SetText(viewParams.title); }); _barList.AddClickItem((context) => { _children = (_children != null) ? _children : new Dictionary <int, ViewInfo>(); var data = _barList.GetSelectedData() as ViewParams; var index = _barList.GetSelectedIndex(); if (index == __preIndex) { return; } ViewInfo preViewInfo = null; if (_children.TryGetValue(__preIndex, out preViewInfo)) { var preView = preViewInfo.view; if (preView != null) { preView.RemoveFromParent(); } } var curIndex = index; __preIndex = curIndex; bool isNeedCreate = true; ViewInfo curViewInfo = null; if (_children.TryGetValue(curIndex, out curViewInfo)) { var curView = curViewInfo.view; if (curView != null) { if (!curView.IsDisposed()) { AddChild(curView); isNeedCreate = false; } } } if (isNeedCreate) { var newData = _barList.GetSelectedData() as ViewParams; var newIndex = _barList.GetSelectedIndex(); if (curIndex != newIndex) { return; } FView.Create(newData.cls, (fWidget) => { var fView = (FView)fWidget; ViewInfo newViewInfo = new ViewInfo(); newViewInfo.view = fView; newViewInfo.viewParams = newData; _children[curIndex] = newViewInfo; AddChild(fView); }, newData.args); } }); } }