Exemple #1
0
        public RenderParagraph(TextSpan text,
                               TextAlign textAlign         = TextAlign.left,
                               TextDirection textDirection = TextDirection.ltr,
                               bool softWrap             = true,
                               TextOverflow overflow     = TextOverflow.clip,
                               float textScaleFactor     = 1.0f,
                               int?maxLines              = null,
                               StrutStyle strutStyle     = null,
                               Action onSelectionChanged = null,
                               Color selectionColor      = null
                               )
        {
            D.assert(maxLines == null || maxLines > 0);
            this._softWrap    = softWrap;
            this._overflow    = overflow;
            this._textPainter = new TextPainter(
                text,
                textAlign,
                textDirection,
                textScaleFactor,
                maxLines,
                overflow == TextOverflow.ellipsis ? _kEllipsis : "",
                strutStyle: strutStyle
                );

            this._selection         = null;
            this.onSelectionChanged = onSelectionChanged;
            this.selectionColor     = selectionColor;

            this._resetHoverHandler();
        }
Exemple #2
0
 public static Text rich(TextSpan textSpan,
                         Key key               = null,
                         TextStyle style       = null,
                         StrutStyle strutStyle = null,
                         TextAlign?textAlign   = null,
                         bool?softWrap         = null,
                         TextOverflow?overflow = null,
                         float?textScaleFactor = null,
                         int?maxLines          = null)
 {
     return(new Text(
                textSpan, key,
                style,
                strutStyle,
                textAlign,
                softWrap,
                overflow,
                textScaleFactor,
                maxLines));
 }
 public ParagraphStyle(TextAlign? textAlign = null,
     TextDirection? textDirection = null,
     FontWeight fontWeight = null,
     FontStyle? fontStyle = null,
     int? maxLines = null,
     float? fontSize = null,
     string fontFamily = null,
     float? height = null, // todo  
     string ellipsis = null,
     StrutStyle strutStyle = null) {
     this.textAlign = textAlign;
     this.textDirection = textDirection;
     this.fontWeight = fontWeight;
     this.fontStyle = fontStyle;
     this.maxLines = maxLines;
     this.fontSize = fontSize;
     this.fontFamily = fontFamily;
     this.height = height;
     this.ellipsis = ellipsis;
     this.strutStyle = strutStyle;
 }
Exemple #4
0
 Text(TextSpan textSpan,
      Key key               = null,
      TextStyle style       = null,
      StrutStyle strutStyle = null,
      TextAlign?textAlign   = null,
      bool?softWrap         = null,
      TextOverflow?overflow = null,
      float?textScaleFactor = null,
      int?maxLines          = null) : base(key)
 {
     D.assert(textSpan != null, () => "A non-null TextSpan must be provided to a Text.rich widget.");
     this.textSpan        = textSpan;
     this.data            = null;
     this.style           = style;
     this.strutStyle      = strutStyle;
     this.textAlign       = textAlign;
     this.softWrap        = softWrap;
     this.overflow        = overflow;
     this.textScaleFactor = textScaleFactor;
     this.maxLines        = maxLines;
 }
Exemple #5
0
 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,
     bool autofocus                            = false,
     bool obscureText                          = false,
     bool autocorrect                          = true,
     bool autovalidate                         = false,
     bool maxLengthEnforced                    = true,
     int?maxLines                              = 1,
     int?minLines                              = null,
     bool expands                              = false,
     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,
                strutStyle: strutStyle,
                textAlign: textAlign,
                textDirection: textDirection ?? TextDirection.ltr,
                textCapitalization: textCapitalization,
                autofocus: autofocus,
                obscureText: obscureText,
                autocorrect: autocorrect,
                maxLengthEnforced: maxLengthEnforced,
                maxLines: maxLines,
                minLines: minLines,
                expands: expands,
                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(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 > 0);
     this.controller = controller;
 }
Exemple #6
0
        public CupertinoTextField(
            Key key = null,
            TextEditingController controller = null,
            FocusNode focusNode        = null,
            BoxDecoration decoration   = null,
            EdgeInsets padding         = null,
            string placeholder         = null,
            TextStyle placeholderStyle = null,
            Widget prefix = null,
            OverlayVisibilityMode prefixMode = OverlayVisibilityMode.always,
            Widget suffix = null,
            OverlayVisibilityMode suffixMode      = OverlayVisibilityMode.always,
            OverlayVisibilityMode clearButtonMode = OverlayVisibilityMode.never,
            TextInputType keyboardType            = null,
            TextInputAction?textInputAction       = null,
            TextCapitalization textCapitalization = TextCapitalization.none,
            TextStyle style                           = null,
            StrutStyle strutStyle                     = null,
            TextAlign textAlign                       = TextAlign.left,
            bool autofocus                            = false,
            bool obscureText                          = false,
            bool autocorrect                          = 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,
            Brightness?keyboardAppearance             = null,
            EdgeInsets scrollPadding                  = null,
            DragStartBehavior dragStartBehavior       = DragStartBehavior.start,
            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 > 0);

            this.controller       = controller;
            this.focusNode        = focusNode;
            this.decoration       = decoration ?? CupertinoTextFieldUtils._kDefaultRoundedBorderDecoration;
            this.padding          = padding ?? EdgeInsets.all(6.0f);
            this.placeholder      = placeholder;
            this.placeholderStyle = placeholderStyle ?? new TextStyle(
                fontWeight: FontWeight.w300,
                color: CupertinoTextFieldUtils._kInactiveTextColor
                );
            this.prefix             = prefix;
            this.prefixMode         = prefixMode;
            this.suffix             = suffix;
            this.suffixMode         = suffixMode;
            this.clearButtonMode    = clearButtonMode;
            this.textInputAction    = textInputAction;
            this.textCapitalization = textCapitalization;
            this.style              = style;
            this.strutStyle         = strutStyle;
            this.textAlign          = textAlign;
            this.autofocus          = autofocus;
            this.obscureText        = obscureText;
            this.autocorrect        = autocorrect;
            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.cursorRadius       = cursorRadius ?? Radius.circular(2.0f);
            this.cursorColor        = cursorColor;
            this.keyboardAppearance = keyboardAppearance;
            this.scrollPadding      = scrollPadding ?? EdgeInsets.all(20.0f);
            this.dragStartBehavior  = dragStartBehavior;
            this.scrollPhysics      = scrollPhysics;
            this.keyboardType       = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
        }
        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,
                         TextDirection textDirection = TextDirection.ltr,
                         bool autofocus                            = false,
                         bool obscureText                          = false,
                         bool autocorrect                          = false,
                         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,
                         Brightness?keyboardAppearance             = null,
                         EdgeInsets scrollPadding                  = null,
                         DragStartBehavior dragStartBehavior       = DragStartBehavior.start,
                         bool?enableInteractiveSelection           = null,
                         GestureTapCallback onTap                  = null,
                         InputCounterWidgetBuilder buildCounter    = 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 == 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.strutStyle                 = strutStyle;
            this.textAlign                  = textAlign;
            this.textDirection              = textDirection;
            this.autofocus                  = autofocus;
            this.obscureText                = obscureText;
            this.autocorrect                = autocorrect;
            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.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;
            this.scrollPhysics              = scrollPhysics;
        }