浏览代码

Update Text Input Sample.

/main
Yuncong Zhang 6 年前
当前提交
b556cd02
共有 2 个文件被更改,包括 38 次插入29 次删除
  1. 6
      Runtime/widgets/editable_text.cs
  2. 61
      Samples/UIWidgetSample/TextInputSample.cs

6
Runtime/widgets/editable_text.cs


this.textInputAction = textInputAction;
this.textCapitalization = textCapitalization;
this.cursorColor = cursorColor;
this.backgroundCursorColor = backgroundCursorColor ?? Colors.transparent; // TODO: remove ??
this.backgroundCursorColor = backgroundCursorColor ?? Colors.grey; // TODO: remove ??
this.maxLines = maxLines;
this.autofocus = autofocus;
this.selectionColor = selectionColor;

LayerLink _layerLink = new LayerLink();
bool _didAutoFocus = false;
static readonly TimeSpan _fadeDuration = TimeSpan.FromMilliseconds(500);
static readonly TimeSpan _fadeDuration = TimeSpan.FromMilliseconds(250);
static readonly TimeSpan _floatingCursorResetTime = TimeSpan.FromMilliseconds(150);
static readonly TimeSpan _floatingCursorResetTime = TimeSpan.FromMilliseconds(125);
AnimationController _floatingCursorResetController;

61
Samples/UIWidgetSample/TextInputSample.cs


using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
class _TextInputSample : StatefulWidget {
public readonly string title;

}
}
protected override Widget createWidget() {
protected override Widget createWidget() {
class _TextInputSampleState : State<_TextInputSample> {
TextEditingController titleController = new TextEditingController("");

return new _EditableInputTypeWidgetState();
}
}
class _EditableInputTypeWidgetState : State<EditableInputTypeWidget> {
Widget rowWidgets(string title, Widget widget) {
return new Container(

}
));
}
List<Widget> widgets = new List<Widget>();
List<Widget> widgets = new List<Widget>();
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, onSubmitted: this.textSubmitted
, unityTouchKeyboard: unityKeyboard, selectionControls: MaterialUtils.materialTextSelectionControls)))));
new EditableText(controller, node, style, cursorColor, Colors.blue,
selectionColor: selectionColor, onSubmitted: this.textSubmitted
, unityTouchKeyboard: unityKeyboard,
selectionControls: MaterialUtils.materialTextSelectionControls,
cursorWidth: 5.0f, cursorRadius: Radius.circular(2.5f), cursorOpacityAnimates: true, paintCursorAboveText: true)))));
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, maxLines: 4,
new EditableText(controller, node, style, cursorColor, Colors.transparent,
selectionColor: selectionColor, maxLines: 4,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, obscureText: true,
onSubmitted: this.textSubmitted, unityTouchKeyboard: unityKeyboard,
new EditableText(controller, node, style, cursorColor, Colors.transparent,
selectionColor: selectionColor, obscureText: true,
onSubmitted: this.textSubmitted, unityTouchKeyboard: unityKeyboard,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, keyboardType: TextInputType.number,
new EditableText(controller, node, style, cursorColor, Colors.transparent,
selectionColor: selectionColor, keyboardType: TextInputType.number,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, keyboardType: TextInputType.phone,
new EditableText(controller, node, style, cursorColor, Colors.transparent,
selectionColor: selectionColor, keyboardType: TextInputType.phone,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, keyboardType: TextInputType.emailAddress,
new EditableText(controller, node, style, cursorColor, Colors.transparent,
selectionColor: selectionColor, keyboardType: TextInputType.emailAddress,
new EditableText(controller, node, style, cursorColor, Colors.transparent, selectionColor: selectionColor, keyboardType: TextInputType.url,
new EditableText(controller, node, style, cursorColor, Colors.transparent,
selectionColor: selectionColor, keyboardType: TextInputType.url,
widgets.Add(new Text("UIWidgets Touch Keyboard", style: new TextStyle(fontSize:20, height:2.0f), textAlign: TextAlign.center));
widgets.Add(new Text("UIWidgets Touch Keyboard", style: new TextStyle(fontSize: 20, height: 2.0f),
textAlign: TextAlign.center));
widgets.Add(new Text("Unity Touch Keyboard", style: new TextStyle(fontSize:20, height:2.0f), textAlign: TextAlign.center));
widgets.Add(new Text("Unity Touch Keyboard", style: new TextStyle(fontSize: 20, height: 2.0f),
textAlign: TextAlign.center));
crossAxisAlignment: CrossAxisAlignment.stretch,
children: widgets)));
crossAxisAlignment: CrossAxisAlignment.stretch,
children: widgets)));
public class EditStateProvider : StatefulWidget {
public delegate EditableText EditableBuilder(BuildContext context,
TextEditingController controller, FocusNode focusNode);

正在加载...
取消
保存