public override Widget build(BuildContext context) { return(new Container( margin: EdgeInsets.symmetric(horizontal: 8.0f), child: new Row( children: new List <Widget> { /// text input new Flexible( child: new TextField( controller: _textController, decoration: InputDecoration.collapsed(hintText: "Send a message"), onSubmitted: this.OnSend, focusNode: _textFocus ) ), /// the Send button new Container( margin: EdgeInsets.symmetric(horizontal: 4.0f), child: new IconButton( icon: new Icon(Icons.send), onPressed: () => this.OnSend(_textController.text)) ) } ) )); }
public DropdownButtonFormField( Key key = null, T value = null, List <DropdownMenuItem <T> > items = null, ValueChanged <T> onChanged = null, InputDecoration decoration = null, FormFieldSetter <T> onSaved = null, FormFieldValidator <T> validator = null, Widget hint = null ) : base( key: key, onSaved: onSaved, initialValue: value, validator: validator, builder: (FormFieldState <T> field) => { InputDecoration effectiveDecoration = (decoration ?? new InputDecoration()) .applyDefaults(Theme.of(field.context).inputDecorationTheme); return(new InputDecorator( decoration: effectiveDecoration.copyWith(errorText: field.errorText), isEmpty: value == null, child: new DropdownButtonHideUnderline( child: new DropdownButton <T>( isDense: true, value: value, items: items, hint: hint, onChanged: field.didChange ) ) )); } ) { this.onChanged = onChanged; }
InputDecoration _getEffectiveDecoration() { MaterialLocalizations localizations = MaterialLocalizations.of(this.context); ThemeData themeData = Theme.of(this.context); InputDecoration effectiveDecoration = (this.widget.decoration ?? new InputDecoration()) .applyDefaults(themeData.inputDecorationTheme) .copyWith( enabled: this.widget.enabled, hintMaxLines: this.widget.decoration?.hintMaxLines ?? this.widget.maxLines ); if (effectiveDecoration.counter != null || effectiveDecoration.counterText != null) { return(effectiveDecoration); } Widget counter; int currentLength = this._effectiveController.value.text.Length; if (effectiveDecoration.counter == null && effectiveDecoration.counterText == null && this.widget.buildCounter != null) { bool isFocused = this._effectiveFocusNode.hasFocus; counter = this.widget.buildCounter( this.context, currentLength: currentLength, maxLength: this.widget.maxLength, isFocused: isFocused ); return(effectiveDecoration.copyWith(counter: counter)); } if (this.widget.maxLength == null) { return(effectiveDecoration); } string counterText = $"{currentLength}"; if (this.widget.maxLength > 0) { counterText += $"/{this.widget.maxLength}"; if (this._effectiveController.value.text.Length > this.widget.maxLength) { return(effectiveDecoration.copyWith( errorText: effectiveDecoration.errorText ?? "", counterStyle: effectiveDecoration.errorStyle ?? themeData.textTheme.caption.copyWith(color: themeData.errorColor), counterText: counterText )); } } // Handle length exceeds maxLength return(effectiveDecoration.copyWith( counterText: counterText )); }
public TextField(Key key = null, TextEditingController controller = null, FocusNode focusNode = null, InputDecoration decoration = null, bool noDecoration = false, TextInputType keyboardType = null, TextInputAction?textInputAction = null, TextCapitalization textCapitalization = TextCapitalization.none, TextStyle style = null, TextAlign textAlign = TextAlign.left, TextDirection textDirection = TextDirection.ltr, bool autofocus = false, bool obscureText = false, bool autocorrect = false, int?maxLines = 1, int?maxLength = null, bool maxLengthEnforced = true, ValueChanged <string> onChanged = null, VoidCallback onEditingComplete = null, ValueChanged <string> onSubmitted = null, List <TextInputFormatter> inputFormatters = null, bool?enabled = null, float?cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, DragStartBehavior dragStartBehavior = DragStartBehavior.down, bool?enableInteractiveSelection = null, GestureTapCallback onTap = null, InputCounterWidgetBuilder buildCounter = null ) : base(key: key) { D.assert(maxLines == null || maxLines > 0); D.assert(maxLength == null || maxLength == TextField.noMaxLength || maxLength > 0); this.controller = controller; this.focusNode = focusNode; this.decoration = noDecoration ? null : (decoration ?? new InputDecoration()); this.textInputAction = textInputAction; this.textCapitalization = textCapitalization; this.style = style; this.textAlign = textAlign; this.textDirection = textDirection; this.autofocus = autofocus; this.obscureText = obscureText; this.autocorrect = autocorrect; this.maxLines = maxLines; this.maxLength = maxLength; this.maxLengthEnforced = maxLengthEnforced; this.onChanged = onChanged; this.onEditingComplete = onEditingComplete; this.onSubmitted = onSubmitted; this.inputFormatters = inputFormatters; this.enabled = enabled; this.cursorWidth = cursorWidth; this.cursorColor = cursorColor; this.cursorRadius = cursorRadius; this.onSubmitted = onSubmitted; this.keyboardAppearance = keyboardAppearance; this.enableInteractiveSelection = enableInteractiveSelection; this.onTap = onTap; this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline); this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f); this.dragStartBehavior = dragStartBehavior; this.buildCounter = buildCounter; }
InputDecoration _getEffectiveDecoration() { MaterialLocalizations localizations = MaterialLocalizations.of(this.context); InputDecoration effectiveDecoration = (this.widget.decoration ?? new InputDecoration()) .applyDefaults(Theme.of(this.context).inputDecorationTheme) .copyWith( enabled: this.widget.enabled ); if (!this.needsCounter) { return(effectiveDecoration); } int currentLength = this._effectiveController.value.text.Length; string counterText = $"{currentLength}"; if (this.widget.maxLength != TextField.noMaxLength) { counterText += $"/{this.widget.maxLength}"; } // Handle length exceeds maxLength if (this._effectiveController.value.text.Length > this.widget.maxLength) { ThemeData themeData = Theme.of(this.context); return(effectiveDecoration.copyWith( errorText: effectiveDecoration.errorText ?? "", counterStyle: effectiveDecoration.errorStyle ?? themeData.textTheme.caption.copyWith(color: themeData.errorColor), counterText: counterText )); } return(effectiveDecoration.copyWith( counterText: counterText )); }
public TextFormField( Key key = null, TextEditingController controller = null, string initialValue = null, FocusNode focusNode = null, InputDecoration decoration = null, TextInputType keyboardType = null, TextCapitalization textCapitalization = TextCapitalization.none, TextInputAction?textInputAction = null, TextStyle style = null, TextDirection?textDirection = null, TextAlign textAlign = TextAlign.left, bool autofocus = false, bool obscureText = false, bool autocorrect = true, bool autovalidate = false, bool maxLengthEnforced = true, int maxLines = 1, int?maxLength = null, VoidCallback onEditingComplete = null, ValueChanged <string> onFieldSubmitted = null, FormFieldSetter <string> onSaved = null, FormFieldValidator <string> validator = null, List <TextInputFormatter> inputFormatters = null, bool enabled = true, float cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, bool enableInteractiveSelection = true, InputCounterWidgetBuilder buildCounter = null ) : base( key: key, initialValue: controller != null ? controller.text : (initialValue ?? ""), onSaved: onSaved, validator: validator, autovalidate: autovalidate, enabled: enabled, builder: (FormFieldState <string> field) => { _TextFormFieldState state = (_TextFormFieldState)field; InputDecoration effectiveDecoration = (decoration ?? new InputDecoration()) .applyDefaults(Theme.of(field.context).inputDecorationTheme); return(new TextField( controller: state._effectiveController, focusNode: focusNode, decoration: effectiveDecoration.copyWith(errorText: field.errorText), keyboardType: keyboardType, textInputAction: textInputAction, style: style, textAlign: textAlign, textDirection: textDirection ?? TextDirection.ltr, textCapitalization: textCapitalization, autofocus: autofocus, obscureText: obscureText, autocorrect: autocorrect, maxLengthEnforced: maxLengthEnforced, maxLines: maxLines, maxLength: maxLength, onChanged: field.didChange, onEditingComplete: onEditingComplete, onSubmitted: onFieldSubmitted, inputFormatters: inputFormatters, enabled: enabled, cursorWidth: cursorWidth, cursorRadius: cursorRadius, cursorColor: cursorColor, scrollPadding: scrollPadding ?? EdgeInsets.all(20.0f), keyboardAppearance: keyboardAppearance, enableInteractiveSelection: enableInteractiveSelection, buildCounter: buildCounter )); } ) { D.assert(initialValue == null || controller == null); D.assert(maxLines > 0); D.assert(maxLength == null || maxLength > 0); this.controller = controller; }
public override Widget build(BuildContext context) { return(new DefaultTabController( length: 2, child: new Scaffold( extendBody: true, drawer: new Drawer( child: new FlatButton( child: new Text("About"), onPressed: () => Navigator.popAndPushNamed(context, Routes.AboutPageRouteText))), appBar: new AppBar( bottom: new TabBar( tabs: new List <Widget> { new Container(height: 30, child: new Text("Home", style: new TextStyle( shadows: new List <BoxShadow> { new BoxShadow( color: Colors.red, offset: new Offset(0, 0), blurRadius: 5, spreadRadius: 5 ) } ))), new Container(height: 30, child: new Text("Settings", style: new TextStyle( shadows: new List <BoxShadow> { new BoxShadow( color: Colors.red, offset: new Offset(0, 0), blurRadius: 5, spreadRadius: 5 ) } ))) //, //new Container (height: 30, child: new Text ("About")), }, labelStyle: new TextStyle(fontSize: 24f), indicatorSize: TabBarIndicatorSize.tab ), title: new Container( child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max, children: new List <Widget> { new Text("MikuMikuManager"), new Container( padding: EdgeInsets.all(8), width: Screen.width / 2, decoration: new BoxDecoration( Colors.white24, border: Border.all(Colors.white24), borderRadius: BorderRadius.circular(18)), child: new TextField( decoration: InputDecoration.collapsed( "Search..." ), autofocus: false, style: new TextStyle(fontSize: 17), onSubmitted: x => widget.SearchPattern.Value = x )), new PopupMenuButton <SortType>( child: new Icon(Icons.sort), itemBuilder: _ => new List <PopupMenuEntry <SortType> > { new PopupMenuItem <SortType>( value: SortType.ByDefault, child: new Text("By Default") ), new PopupMenuItem <SortType>( value: SortType.ByFavorite, child: new Text("By Favorite") ), new PopupMenuItem <SortType>( value: SortType.ByFolder, child: new Text("By Folder") ) }, initialValue: widget.SortTypeProperty.Value, onSelected: x => { widget.SortTypeProperty.Value = x; } ) } ) ) ), body: new Padding( padding: EdgeInsets.all(8), child: new TabBarView( children: new List <Widget> { new GalleryPage(), new SettingPage() } ) ), floatingActionButton: new Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: new List <Widget> { FloatingActionButton.extended( icon: new Icon(Icons.track_changes), label: new Text("Generate All"), onPressed: () => { var builder = GameObject.Find("MMDRenderer") .GetComponent <PreviewBuilder.PreviewBuilder>(); builder.StartRender(); }), new SizedBox(height: 10, width: 10), FloatingActionButton.extended( icon: new Icon(Icons.refresh), label: new Text("Refresh"), onPressed: () => MMMServices.RefreshObservedMmdObjects()) } ), bottomNavigationBar: new Container( height: 30, decoration: new BoxDecoration( Colors.white, boxShadow: new List <BoxShadow> { new BoxShadow(Colors.black.withOpacity(0.3f), new Offset(0, -5), 5) } ), child: new Stack( children: new List <Widget> { SizedBox.expand( child: new LinearProgressIndicator( backgroundColor: Colors.transparent, value: _progress, valueColor: new AlwaysStoppedAnimation <Color>( Colors.pink))), //Status text new Container( margin: EdgeInsets.only(5), alignment: Alignment.centerLeft, child: new Row( children: new List <Widget> { PaddingText(_renderStatus), VerticalDivider, PaddingText(_savingStatus) } ) ) } ) ) ) )); }
public TextField(Key key = null, TextEditingController controller = null, FocusNode focusNode = null, InputDecoration decoration = null, bool noDecoration = false, TextInputType keyboardType = null, TextInputAction?textInputAction = null, TextCapitalization textCapitalization = TextCapitalization.none, TextStyle style = null, StrutStyle strutStyle = null, TextAlign textAlign = TextAlign.left, TextAlignVertical textAlignVertical = null, TextDirection textDirection = TextDirection.ltr, bool readOnly = false, ToolbarOptions toolbarOptions = null, bool?showCursor = null, bool autofocus = false, bool obscureText = false, bool autocorrect = false, SmartDashesType?smartDashesType = null, SmartQuotesType?smartQuotesType = null, bool enableSuggestions = true, int?maxLines = 1, int?minLines = null, bool expands = false, int?maxLength = null, bool maxLengthEnforced = true, ValueChanged <string> onChanged = null, VoidCallback onEditingComplete = null, ValueChanged <string> onSubmitted = null, List <TextInputFormatter> inputFormatters = null, bool?enabled = null, float?cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, BoxHeightStyle selectionHeightStyle = BoxHeightStyle.tight, BoxWidthStyle selectionWidthStyle = BoxWidthStyle.tight, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, DragStartBehavior dragStartBehavior = DragStartBehavior.start, bool enableInteractiveSelection = true, GestureTapCallback onTap = null, InputCounterWidgetBuilder buildCounter = null, ScrollController scrollController = null, ScrollPhysics scrollPhysics = null ) : base(key: key) { D.assert(maxLines == null || maxLines > 0); D.assert(minLines == null || minLines > 0); D.assert((maxLines == null) || (minLines == null) || (maxLines >= minLines), () => "minLines can't be greater than maxLines"); D.assert(!expands || (maxLines == null && minLines == null), () => "minLines and maxLines must be null when expands is true."); D.assert(maxLength == null || maxLength == noMaxLength || maxLength > 0); D.assert(!obscureText || maxLines == 1, () => "Obscured fields cannot be multiline."); this.smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled); this.smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled); this.controller = controller; this.focusNode = focusNode; this.decoration = noDecoration ? null : (decoration ?? new InputDecoration()); this.textInputAction = textInputAction; this.textCapitalization = textCapitalization; this.style = style; this.strutStyle = strutStyle; this.textAlign = textAlign; this.textAlignVertical = textAlignVertical; this.textDirection = textDirection; this.readOnly = readOnly; this.showCursor = showCursor; this.autofocus = autofocus; this.obscureText = obscureText; this.autocorrect = autocorrect; this.enableSuggestions = enableSuggestions; this.maxLines = maxLines; this.minLines = minLines; this.expands = expands; this.maxLength = maxLength; this.maxLengthEnforced = maxLengthEnforced; this.onChanged = onChanged; this.onEditingComplete = onEditingComplete; this.onSubmitted = onSubmitted; this.inputFormatters = inputFormatters; this.enabled = enabled; this.cursorWidth = cursorWidth; this.cursorColor = cursorColor; this.selectionHeightStyle = selectionHeightStyle; this.selectionWidthStyle = selectionWidthStyle; this.cursorRadius = cursorRadius; this.onSubmitted = onSubmitted; this.keyboardAppearance = keyboardAppearance; this.enableInteractiveSelection = enableInteractiveSelection; this.onTap = onTap; this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline); this.toolbarOptions = toolbarOptions ?? (obscureText ? new ToolbarOptions( selectAll: true, paste: true ) : new ToolbarOptions( copy: true, cut: true, selectAll: true, paste: true )); this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f); this.dragStartBehavior = dragStartBehavior; this.enableInteractiveSelection = enableInteractiveSelection; this.buildCounter = buildCounter; this.scrollPhysics = scrollPhysics; this.scrollController = scrollController; }
public TextFormField( Key key = null, TextEditingController controller = null, string initialValue = null, FocusNode focusNode = null, InputDecoration decoration = null, TextInputType keyboardType = null, TextCapitalization textCapitalization = TextCapitalization.none, TextInputAction?textInputAction = null, TextStyle style = null, StrutStyle strutStyle = null, TextDirection?textDirection = null, TextAlign textAlign = TextAlign.left, TextAlignVertical textAlignVertical = null, bool autofocus = false, bool readOnly = false, ToolbarOptions toolbarOptions = null, bool?showCursor = null, bool obscureText = false, bool autocorrect = true, SmartDashesType?smartDashesType = null, SmartQuotesType?smartQuotesType = null, bool enableSuggestions = true, bool autovalidate = false, bool maxLengthEnforced = true, int?maxLines = 1, int?minLines = null, bool expands = false, int?maxLength = null, ValueChanged <string> onChanged = null, GestureTapCallback onTap = null, VoidCallback onEditingComplete = null, ValueChanged <string> onFieldSubmitted = null, FormFieldSetter <string> onSaved = null, FormFieldValidator <string> validator = null, List <TextInputFormatter> inputFormatters = null, bool enabled = true, float cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, bool enableInteractiveSelection = true, InputCounterWidgetBuilder buildCounter = null, ScrollPhysics scrollPhysics = null ) : base( key: key, initialValue: controller != null ? controller.text : (initialValue ?? ""), onSaved: onSaved, validator: validator, autovalidate: autovalidate, enabled: enabled, builder: (FormFieldState <string> field) => { _TextFormFieldState state = (_TextFormFieldState)field; InputDecoration effectiveDecoration = (decoration ?? new InputDecoration()) .applyDefaults(Theme.of(field.context).inputDecorationTheme); void onChangedHandler(string value) { if (onChanged != null) { onChanged(value); } field.didChange(value); } return(new TextField( controller: state._effectiveController, focusNode: focusNode, decoration: effectiveDecoration.copyWith(errorText: field.errorText), keyboardType: keyboardType, textInputAction: textInputAction, style: style, strutStyle: strutStyle, textAlign: textAlign, textAlignVertical: textAlignVertical, textDirection: textDirection ?? TextDirection.ltr, textCapitalization: textCapitalization, autofocus: autofocus, toolbarOptions: toolbarOptions, readOnly: readOnly, showCursor: showCursor, obscureText: obscureText, autocorrect: autocorrect, smartDashesType: smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled), smartQuotesType: smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled), enableSuggestions: enableSuggestions, maxLengthEnforced: maxLengthEnforced, maxLines: maxLines, minLines: minLines, expands: expands, maxLength: maxLength, onChanged: onChangedHandler, onTap: onTap, onEditingComplete: onEditingComplete, onSubmitted: onFieldSubmitted, inputFormatters: inputFormatters, enabled: enabled, cursorWidth: cursorWidth, cursorRadius: cursorRadius, cursorColor: cursorColor, scrollPadding: scrollPadding ?? EdgeInsets.all(20.0f), scrollPhysics: scrollPhysics, keyboardAppearance: keyboardAppearance, enableInteractiveSelection: enableInteractiveSelection, buildCounter: buildCounter )); } ) { D.assert(initialValue == null || controller == null); D.assert(maxLines > 0); D.assert(maxLines == null || maxLines > 0); D.assert(minLines == null || minLines > 0); D.assert((maxLines == null) || (minLines == null) || (maxLines >= minLines), () => "minLines can't be greater than maxLines"); D.assert(!expands || (maxLines == null && minLines == null), () => "minLines and maxLines must be null when expands is true."); D.assert(!obscureText || maxLines == 1, () => "Obscured fields cannot be multiline."); D.assert(maxLength == null || maxLength > 0); this.controller = controller; }