Example #1
0
        bool _shouldShowAttachment(
            OverlayVisibilityMode attachment,
            bool hasText
            )
        {
            switch (attachment)
            {
            case OverlayVisibilityMode.never:
                return(false);

            case OverlayVisibilityMode.always:
                return(true);

            case OverlayVisibilityMode.editing:
                return(hasText);

            case OverlayVisibilityMode.notEditing:
                return(!hasText);
            }
            D.assert(false);
            return(false);
        }
Example #2
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,
            TextAlignVertical textAlignVertical = null,
            bool readOnly = false,
            ToolbarOptions toolbarOptions = null,
            bool?showCursor  = null,
            bool autofocus   = false,
            bool obscureText = false,
            bool autocorrect = true,
            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,
            ui.BoxHeightStyle selectionHeightStyle    = ui.BoxHeightStyle.tight,
            ui.BoxWidthStyle selectionWidthStyle      = ui.BoxWidthStyle.tight,
            Brightness?keyboardAppearance             = null,
            EdgeInsets scrollPadding                  = null,
            DragStartBehavior dragStartBehavior       = DragStartBehavior.start,
            bool enableInteractiveSelection           = true,
            GestureTapCallback onTap                  = null,
            ScrollController scrollController         = null,
            ScrollPhysics scrollPhysics               = null
            ) : base(key: key)
        {
            this.smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
            this.smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
            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.w400,
                color: CupertinoColors.placeholderText
                );
            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.textAlignVertical          = textAlignVertical;
            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.cursorRadius               = cursorRadius ?? Radius.circular(2.0f);
            this.cursorColor                = cursorColor;
            this.selectionHeightStyle       = selectionHeightStyle;
            this.selectionWidthStyle        = selectionWidthStyle;
            this.keyboardAppearance         = keyboardAppearance;
            this.scrollPadding              = scrollPadding ?? EdgeInsets.all(20.0f);
            this.dragStartBehavior          = dragStartBehavior;
            this.enableInteractiveSelection = enableInteractiveSelection;
            this.scrollPhysics              = scrollPhysics;
            this.onTap                      = onTap;
            this.scrollController           = scrollController;
            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
                                                                     ));
        }
Example #3
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);
        }