浏览代码

Update editable text, and some samples.

/main
Yuncong Zhang 5 年前
当前提交
33462b90
共有 3 个文件被更改,包括 29 次插入26 次删除
  1. 38
      Runtime/widgets/editable_text.cs
  2. 1
      Samples/ReduxSample/ObjectFinder/ObjectFinderApp.cs
  3. 16
      Samples/UIWidgetSample/TextInputSample.cs

38
Runtime/widgets/editable_text.cs


D.assert(style != null);
D.assert(cursorColor != null);
D.assert(maxLines == null || maxLines > 0);
// D.assert(backgroundCursorColor != null); // TODO: remove comment when this parameter is actually used
D.assert(backgroundCursorColor != null);
this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f);

this._cursorBlinkOpacityController = new AnimationController(vsync: this, duration: _fadeDuration);
this._cursorBlinkOpacityController.addListener(this._onCursorColorTick);
this._floatingCursorResetController = new AnimationController(vsync: this);
// this._floatingCursorResetController.addListener(_onFloatingCursorResetTick); // TODO: remove comment when _onFLoatingCursorResetTick is ready
// this._floatingCursorResetController.addListener(_onFloatingCursorResetTick); // TODO: remove comment when _onFloatingCursorResetTick is ready
}
public override void didChangeDependencies() {

textSpan: this.buildTextSpan(),
value: this._value,
cursorColor: this._cursorColor,
// backgroundCursorColor: this.widget.backgroundCursorColor, // TODO
backgroundCursorColor: this.widget.backgroundCursorColor,
showCursor: EditableText.debugDeterministicCursor
? new ValueNotifier<bool>(true)
: this._cursorVisibilityNotifier,

rendererIgnoresPointer: this.widget.rendererIgnoresPointer,
cursorWidth: this.widget.cursorWidth,
cursorRadius: this.widget.cursorRadius,
// cursorOffset: this.widget.cursorOffset, // TODO
// paintCursorAboveText: this.widget.paintCursorAboveText, // TODO
cursorOffset: this.widget.cursorOffset,
paintCursorAboveText: this.widget.paintCursorAboveText,
textSelectionDelegate: this
// devicePixelRatio: _devicePixelRatio // TODO
textSelectionDelegate: this,
devicePixelRatio: this._devicePixelRatio
)
)
);

public readonly TextSpan textSpan;
public readonly TextEditingValue value;
public readonly Color cursorColor;
public readonly Color backgroundColor;
public readonly Color backgroundCursorColor;
public readonly ValueNotifier<bool> showCursor;
public readonly bool hasFocus;
public readonly int? maxLines;

public _Editable(TextSpan textSpan = null, TextEditingValue value = null,
Color cursorColor = null, Color backgroundColor = null, ValueNotifier<bool> showCursor = null,
Color cursorColor = null, Color backgroundCursorColor = null, ValueNotifier<bool> showCursor = null,
bool hasFocus = false,
int? maxLines = null, Color selectionColor = null, float textScaleFactor = 1.0f,
TextDirection? textDirection = null, bool obscureText = false, TextAlign textAlign = TextAlign.left,

this.textSpan = textSpan;
this.value = value;
this.cursorColor = cursorColor;
this.backgroundColor = backgroundColor;
this.backgroundCursorColor = backgroundCursorColor;
this.showCursor = showCursor;
this.hasFocus = hasFocus;
this.maxLines = maxLines;

offset: this.offset,
showCursor: this.showCursor,
cursorColor: this.cursorColor,
// backgroundColor: this.backgroundColor, // TODO
backgroundCursorColor: this.backgroundCursorColor,
hasFocus: this.hasFocus,
maxLines: this.maxLines,
selectionColor: this.selectionColor,

ignorePointer: this.rendererIgnoresPointer,
cursorWidth: this.cursorWidth ?? 1.0f,
cursorRadius: this.cursorRadius,
// cursorOffset: this.cursorOffset, // TODO
cursorOffset: this.cursorOffset,
textSelectionDelegate: this.textSelectionDelegate
// paintCursorAboveText: this.paintCursorAboveText, // TODO
// devicePixelRatio: this.devicePixelRatio // TODO
textSelectionDelegate: this.textSelectionDelegate,
paintCursorAboveText: this.paintCursorAboveText == true,
devicePixelRatio: this.devicePixelRatio ?? 1.0f
);
}

edit.cursorColor = this.cursorColor;
// edit.backgroundColor = this.backgroundColor; // TODO
edit.backgroundCursorColor = this.backgroundCursorColor;
edit.showCursor = this.showCursor;
edit.hasFocus = this.hasFocus;
edit.maxLines = this.maxLines;

edit.textSelectionDelegate = this.textSelectionDelegate;
edit.cursorWidth = this.cursorWidth ?? 1.0f;
edit.cursorRadius = this.cursorRadius;
// edit.cursorOffset = this.cursorOffset; // TODO
edit.cursorOffset = this.cursorOffset;
// edit.paintCursorAboveText = this.paintCursorAboveText; // TODO
// edit.devicePixelRatio = this.devicePixelRatio; // TODO
edit.paintCursorAboveText = this.paintCursorAboveText == true;
edit.devicePixelRatio = this.devicePixelRatio ?? 1.0f;
}
}
}

1
Samples/ReduxSample/ObjectFinder/ObjectFinderApp.cs


padding: EdgeInsets.only(left: 8, right: 8),
child: new EditableText(
selectionControls: MaterialUtils.materialTextSelectionControls,
backgroundCursorColor: Colors.transparent,
controller: this._controller,
focusNode: this._focusNode,
style: new TextStyle(

16
Samples/UIWidgetSample/TextInputSample.cs


child: new EditableText(maxLines: 1,
controller: this.titleController,
selectionControls: MaterialUtils.materialTextSelectionControls,
backgroundCursorColor: Colors.transparent,
autofocus: true,
focusNode: new FocusNode(),
style: new TextStyle(

padding: EdgeInsets.fromLTRB(8, 0, 8, 0),
child: new EditableText(maxLines: 200,
controller: this.descController,
backgroundCursorColor: Colors.transparent,
selectionControls: MaterialUtils.materialTextSelectionControls,
focusNode: new FocusNode(),
style: new TextStyle(

var selectionColor = new Color(0xFF6F6F6F);
widgets.Add(this.rowWidgets("Default", new EditStateProvider(builder: ((buildContext, controller, node) =>
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, onSubmitted: this.textSubmitted
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, onSubmitted: this.textSubmitted
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, maxLines: 4,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, maxLines: 4,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, obscureText: true,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, obscureText: true,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.number,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, keyboardType: TextInputType.number,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.phone,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, keyboardType: TextInputType.phone,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.emailAddress,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, keyboardType: TextInputType.emailAddress,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.url,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, keyboardType: TextInputType.url,
onSubmitted: this.textSubmitted, unityTouchKeyboard: unityKeyboard,
selectionControls: MaterialUtils.materialTextSelectionControls)))));
return widgets;

正在加载...
取消
保存