private void DrawComponent(ILegoComponent component) { var uiRxModel = ScRxModel.GetRxModel(component.ScrollViewId); if (uiRxModel == null) { #if DEBUG string name = null; if (component.UIRect != null) { name = component.UIRect.name; } Debug.LogError("DrawComponent错误,uiRxModel为null: " + name + " " + component.ScrollViewId); #endif return; } LegoBinder.Binding(component, componentMeta, uiRxModel); component.SetRxModel(uiRxModel); if (uiRxModel.SonComponentModels.Count != 0) { foreach (var sonComponent in component.SonComponentDict) { var bigId = sonComponent.Key; var lowerId = "";//YuBigAssetIdMap.GetLowerId(bigId); LegoUIMeta sonComponentMeta = metaHelper.GetMeta(lowerId); IYuLegoUIRxModel sonComponentRxModel = uiRxModel.SonComponentModels[bigId]; LegoBinder.Binding(sonComponent.Value, sonComponentMeta, sonComponentRxModel); sonComponent.Value.SetRxModel(sonComponentRxModel); } } onDrawComponent?.Invoke(component, uiRxModel); }
private void RxModelReplaceComplished() { ScRxModel.IsReplacingRxModel = false; if (ToReplaceRxModelList.Count > 0) { ScRxModel.Replace(ToReplaceRxModelList.Dequeue()); } }
private void InitScrollViewRxModel() { ScRxModel = (IYuLegoScrollViewRxModel)ViewModule.GetRxModel(name); ScRxModel.BindingAdd(OnRxModelAdd); ScRxModel.BindingInsert(OnRxModelInsert); ScRxModel.BindingRemove(OnRxModelRemove); ScRxModel.BindingReplace(OnRxModelReplace); }
/// <summary> /// 替换数据模型 /// </summary> private void OnRxModelReplace(List <IYuLegoUIRxModel> replaceRxModelList) { ScrollRect.StopMovement(); Content.anchoredPosition = Vector2.zero; UpadteContentSize(); int rxModelAmount = ScRxModel.ModelCount; //数据模型数量 int componentAmount = components.Count; //组件数量 if (componentAmount >= rxModelAmount) { while (components.Count != rxModelAmount) { RestoreComponent(); } ReDrawAllComponents(); onReplaceComponents?.Invoke(components); RxModelReplaceComplished(); } else if (componentAmount >= RequireCount) { ReDrawAllComponents(); RxModelReplaceComplished(); } else { ReDrawAllComponents(); requestTaskCount = 0; for (int i = componentAmount; i < rxModelAmount; i++) { OnRxModelAdd(ScRxModel.GetRxModel(i)); } } UpdateMaxIndexOffset(); }