private static YogaSize MeasureText(ReactTextShadowNode textNode, YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { Log.Info(ReactConstants.Tag, "MeasureText node=" + textNode.ReactTag); // This is not a terribly efficient way of projecting the height of // the text elements. It requires that we have access to the // dispatcher in order to do measurement, which, for obvious // reasons, can cause perceived performance issues as it will block // the UI thread from handling other work. // // TODO: determine another way to measure text elements. var task = DispatcherHelpers.CallOnDispatcher(() => { if (textView == null) { textView = new ReactTextView(ReactProgram.RctWindow); textView.LineWrapType = WrapType.Mixed; } var normalizedWidth = YogaConstants.IsUndefined(width) ? ReactProgram.RctWindow.ScreenSize.Width : width; var normalizedHeight = YogaConstants.IsUndefined(height) ? ReactProgram.RctWindow.ScreenSize.Height : height; textView.Resize((int)normalizedWidth, (int)normalizedHeight); textView.Text = textNode._preparedSpannableText; var textPartObject = textView.EdjeObject["elm.text"]; if (textPartObject == null) { throw new Exception("Invalid ReactTextView.EdjeObject[\"elm.text\"]"); } Size size = textPartObject.TextBlockFormattedSize; Log.Info(ReactConstants.Tag, "MeasureText result : width: " + size.Width + " height:" + size.Height); //textView.Unrealize(); return(MeasureOutput.Make( (float)size.Width, (float)size.Height)); }); return(task.Result); }
public void SetText(string text) { text = ReactTextView.filterText(text); _text = text ?? ""; MarkUpdated(); }
/// <summary> /// Should not be called, as this is a virtual view manager. /// </summary> /// <param name="root">Irrelevant.</param> /// <param name="extraData">Irrelevant.</param> public override void UpdateExtraData(ReactTextView root, object extraData) { }