Ejemplo n.º 1
0
 public _SnappingScrollPhysics(
     ScrollPhysics parent  = null,
     float?midScrollOffset = null
     ) : base(parent: parent)
 {
     D.assert(midScrollOffset != null);
 }
Ejemplo n.º 2
0
 public RefreshScrollPhysics(
     ScrollPhysics parent  = null,
     bool enableOverScroll = true
     ) : base(parent)
 {
     this.enableOverScroll = enableOverScroll;
 }
Ejemplo n.º 3
0
        SelectableText(
            string data,
            TextSpan textSpan,
            Key key                             = null,
            FocusNode focusNode                 = null,
            TextStyle style                     = null,
            StrutStyle strutStyle               = null,
            TextAlign?textAlign                 = null,
            TextDirection?textDirection         = null,
            float?textScaleFactor               = null,
            bool showCursor                     = false,
            bool autofocus                      = false,
            ToolbarOptions toolbarOptions       = null,
            int?minLines                        = null,
            int?maxLines                        = null,
            float cursorWidth                   = 2.0f,
            Radius cursorRadius                 = null,
            Color cursorColor                   = null,
            DragStartBehavior dragStartBehavior = DragStartBehavior.start,
            bool enableInteractiveSelection     = true,
            GestureTapCallback onTap            = null,
            ScrollPhysics scrollPhysics         = null,
            TextWidthBasis?textWidthBasis       = 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"
                );
            toolbarOptions = toolbarOptions ??
                             new ToolbarOptions(
                selectAll: true,
                copy: true
                );

            this.data                       = data;
            this.textSpan                   = textSpan;
            this.focusNode                  = focusNode;
            this.style                      = style;
            this.strutStyle                 = strutStyle;
            this.textAlign                  = textAlign;
            this.textDirection              = textDirection;
            this.textScaleFactor            = textScaleFactor;
            this.showCursor                 = showCursor;
            this.autofocus                  = autofocus;
            this.toolbarOptions             = toolbarOptions;
            this.minLines                   = minLines;
            this.maxLines                   = maxLines;
            this.cursorWidth                = cursorWidth;
            this.cursorRadius               = cursorRadius;
            this.cursorColor                = cursorColor;
            this.dragStartBehavior          = dragStartBehavior;
            this.enableInteractiveSelection = enableInteractiveSelection;
            this.onTap                      = onTap;
            this.scrollPhysics              = scrollPhysics;
            this.textWidthBasis             = textWidthBasis;
        }
Ejemplo n.º 4
0
 public override ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context,
                                                     ScrollPosition oldPosition)
 {
     return(new _TabBarScrollPosition(
                physics: physics,
                context: context,
                oldPosition: oldPosition,
                tabBar: this.tabBar
                ));
 }
Ejemplo n.º 5
0
        public static SelectableText rich(
            TextSpan textSpan,
            Key key                             = null,
            FocusNode focusNode                 = null,
            TextStyle style                     = null,
            StrutStyle strutStyle               = null,
            TextAlign?textAlign                 = null,
            TextDirection?textDirection         = null,
            float?textScaleFactor               = null,
            bool showCursor                     = false,
            bool autofocus                      = false,
            ToolbarOptions toolbarOptions       = null,
            int?minLines                        = null,
            int?maxLines                        = null,
            float cursorWidth                   = 2.0f,
            Radius cursorRadius                 = null,
            Color cursorColor                   = null,
            DragStartBehavior dragStartBehavior = DragStartBehavior.start,
            bool enableInteractiveSelection     = true,
            GestureTapCallback onTap            = null,
            ScrollPhysics scrollPhysics         = null,
            TextWidthBasis?textWidthBasis       = null
            )
        {
            D.assert(
                textSpan != null,
                () => "A non-null TextSpan must be provided to a SelectableText.rich widget."
                );

            return(new SelectableText(
                       data: null,
                       textSpan: textSpan,
                       key: key,
                       focusNode: focusNode,
                       style: style,
                       strutStyle: strutStyle,
                       textAlign: textAlign,
                       textDirection: textDirection,
                       textScaleFactor: textScaleFactor,
                       showCursor: showCursor,
                       autofocus: autofocus,
                       toolbarOptions: toolbarOptions,
                       minLines: minLines,
                       maxLines: maxLines,
                       cursorWidth: cursorWidth,
                       cursorRadius: cursorRadius,
                       cursorColor: cursorColor,
                       dragStartBehavior: dragStartBehavior,
                       enableInteractiveSelection: enableInteractiveSelection,
                       onTap: onTap,
                       scrollPhysics: scrollPhysics,
                       textWidthBasis: textWidthBasis
                       ));
        }
Ejemplo n.º 6
0
 public TabBarView(
     Key key = null,
     List <Widget> children   = null,
     TabController controller = null,
     ScrollPhysics physics    = null
     ) : base(key: key)
 {
     D.assert(children != null);
     this.children   = children;
     this.controller = controller;
     this.physics    = physics;
 }
Ejemplo n.º 7
0
 public override ScrollPosition createScrollPosition(
     ScrollPhysics physics,
     ScrollContext context,
     ScrollPosition oldPosition
     )
 {
     return(new _DraggableScrollableSheetScrollPosition(
                physics: physics,
                context: context,
                oldPosition: oldPosition,
                extent: extent
                ));
 }
Ejemplo n.º 8
0
 public _TabBarScrollPosition(
     ScrollPhysics physics      = null,
     ScrollContext context      = null,
     ScrollPosition oldPosition = null,
     _TabBarState tabBar        = null
     ) : base(
         physics: physics,
         context: context,
         initialPixels: null,
         oldPosition: oldPosition)
 {
     this.tabBar = tabBar;
 }
Ejemplo n.º 9
0
        bool _handleScrollNotification(ScrollNotification notification, float midScrollOffset)
        {
            if (notification.depth == 0 && notification is ScrollUpdateNotification)
            {
                ScrollPhysics physics = this._scrollController.position.pixels >= midScrollOffset
                    ? (ScrollPhysics) new PageScrollPhysics()
                    : new NeverScrollableScrollPhysics();
                if (physics != this._headingScrollPhysics)
                {
                    this.setState(() => { this._headingScrollPhysics = physics; });
                }
            }

            return(false);
        }
Ejemplo n.º 10
0
 public _DraggableScrollableSheetScrollPosition(
     ScrollPhysics physics        = null,
     ScrollContext context        = null,
     float initialPixels          = 0.0f,
     bool keepScrollOffset        = true,
     ScrollPosition oldPosition   = null,
     string debugLabel            = null,
     _DraggableSheetExtent extent = null
     ) : base(physics: physics,
              context: context,
              initialPixels: initialPixels,
              keepScrollOffset: keepScrollOffset,
              oldPosition: oldPosition,
              debugLabel: debugLabel)
 {
     D.assert(extent != null);
     this.extent = extent;
 }
Ejemplo n.º 11
0
 public CustomMarkdown(
     Key key         = null,
     string data     = null,
     bool selectable = false,
     MarkdownStyleSheet markdownStyleSheet = null,
     SyntaxHighlighter syntaxHighlighter   = null,
     MarkdownTapLinkCallback onTapLink     = null,
     string imageDirectory                   = null,
     ExtensionSet extensionSet               = null,
     MarkdownImageBuilder imageBuilder       = null,
     MarkdownCheckboxBuilder checkboxBuilder = null,
     ScrollPhysics physics                   = null,
     bool shrinkWrap                     = false,
     Widget contentHead                  = null,
     Widget relatedArticles              = null,
     List <Widget> commentList           = null,
     RefreshController refreshController = null,
     bool enablePullDown                 = false,
     bool enablePullUp                   = false,
     OnRefresh onRefresh                 = null,
     NotificationListenerCallback <ScrollNotification> onNotification = null,
     float initialOffset = 0f,
     bool needRebuildWithCachedCommentPosition = false,
     bool isArticleJumpToCommentStateActive    = false
     ) : base(key, data, markdownStyleSheet, syntaxHighlighter,
              onTapLink, imageDirectory, extensionSet, imageBuilder, checkboxBuilder, selectable)
 {
     this.padding           = EdgeInsets.all(16);
     this.physics           = physics;
     this.shrinkWrap        = shrinkWrap;
     this.contentHead       = contentHead;
     this.relatedArticles   = relatedArticles;
     this.commentList       = commentList;
     this.refreshController = refreshController;
     this.enablePullDown    = enablePullDown;
     this.enablePullUp      = enablePullUp;
     this.onRefresh         = onRefresh;
     this.onNotification    = onNotification;
     this.initialOffset     = initialOffset;
     this.needRebuildWithCachedCommentPosition = needRebuildWithCachedCommentPosition;
     this.isArticleJumpToCommentStateActive    = isArticleJumpToCommentStateActive;
 }
Ejemplo n.º 12
0
 public Markdown(
     Key key         = null,
     string data     = null,
     bool selectable = false,
     MarkdownStyleSheet markdownStyleSheet = null,
     SyntaxHighlighter syntaxHighlighter   = null,
     MarkdownTapLinkCallback onTapLink     = null,
     string imageDirectory                   = null,
     ExtensionSet extensionSet               = null,
     MarkdownImageBuilder imageBuilder       = null,
     MarkdownCheckboxBuilder checkboxBuilder = null,
     ScrollPhysics physics                   = null,
     bool shrinkWrap = false
     ) : base(key, data, markdownStyleSheet, syntaxHighlighter,
              onTapLink, imageDirectory, extensionSet, imageBuilder, checkboxBuilder, selectable)
 {
     this.padding    = EdgeInsets.all(16);
     this.physics    = physics;
     this.shrinkWrap = shrinkWrap;
 }
Ejemplo n.º 13
0
    public static TransformerPageView children(

        int index,
        TimeSpan?duration                        = null,
        Curve curve                              = null,
        Key key                                  = null,
        ScrollPhysics physics                    = null,
        ValueChanged <int> onPageChanged         = null,
        IndexController controller               = null,
        TransformerPageController pageController = null,
        PageTransformer transformer              = null,
        List <Widget> children                   = null,
        float viewportFraction                   = 1,
        bool pageSnapping                        = true,
        bool loop                                = false,
        Axis scrollDirection                     = Axis.horizontal
        )
    {
        return(new TransformerPageView(
                   itemCount: children.Count,
                   itemBuilder: (BuildContext context, int ind) =>
        {
            return children[ind];
        },
                   pageController: pageController,
                   transformer: transformer,
                   pageSnapping: pageSnapping,
                   key: key,
                   index: index,
                   duration: duration,
                   curve: curve ?? Curves.ease,
                   viewportFraction: viewportFraction,
                   scrollDirection: scrollDirection,
                   physics: physics,
                   onPageChanged: onPageChanged,
                   controller: controller
                   ));
    }
Ejemplo n.º 14
0
 public TransformerPageView(
     Key key                                  = null,
     int?index                                = null,
     TimeSpan?duration                        = null,
     Curve curve                              = null,
     float viewportFraction                   = 1.0f,
     bool loop                                = false,
     Axis scrollDirection                     = Axis.horizontal,
     ScrollPhysics physics                    = null,
     bool pageSnapping                        = true,
     ValueChanged <int> onPageChanged         = null,
     IndexController controller               = null,
     PageTransformer transformer              = null,
     IndexedWidgetBuilder itemBuilder         = null,
     TransformerPageController pageController = null,
     int?itemCount                            = null
     ) : base(key: key)
 {
     D.assert(itemCount != null);
     D.assert(itemCount == 0 || itemBuilder != null || transformer != null);
     this.duration =
         duration ?? TimeSpan.FromMilliseconds(TransformerPageViewUtils.kDefaultTransactionDuration);
     this.index            = index;
     this.duration         = duration;
     this.curve            = curve ?? Curves.ease;
     this.viewportFraction = viewportFraction;
     this.loop             = loop;
     this.scrollDirection  = scrollDirection;
     this.physics          = physics;
     this.pageSnapping     = pageSnapping;
     this.onPageChanged    = onPageChanged;
     this.controller       = controller;
     this.transformer      = transformer;
     this.itemBuilder      = itemBuilder;
     this.pageController   = pageController;
     this.itemCount        = itemCount.Value;
 }
Ejemplo n.º 15
0
    /// Creates a scrollable list that works page by page using widgets that are
    /// created on demand.
    ///
    /// This constructor is appropriate for page views with a large (or infinite)
    /// number of children because the builder is called only for those children
    /// that are actually visible.
    ///
    /// Providing a non-null [itemCount] lets the [PageView] compute the maximum
    /// scroll extent.
    ///
    /// [itemBuilder] will be called only with indices greater than or equal to
    /// zero and less than [itemCount].
    public TransformerPageView(

        int index,
        Curve curve,
        ScrollPhysics physics,
        ValueChanged <int> onPageChanged,
        IndexController controller,
        PageTransformer transformer,
        IndexedWidgetBuilder itemBuilder,
        TransformerPageController pageController,
        int itemCount,
        TimeSpan?duration      = null,
        Key key                = null,
        float viewportFraction = 1,
        Axis scrollDirection   = Axis.horizontal,
        bool loop              = false,
        bool pageSnapping      = true
        ) : base(key: key)
    {
        this.index            = index;
        this.curve            = curve == null ? Curves.ease : curve;
        this.loop             = loop;
        this.scrollDirection  = scrollDirection;
        this.physics          = physics;
        this.onPageChanged    = onPageChanged;
        this.controller       = controller;
        this.transformer      = transformer;
        this.itemBuilder      = itemBuilder;
        this.pageController   = pageController;
        this.itemCount        = itemCount;
        this.viewportFraction = viewportFraction;
        this.scrollDirection  = scrollDirection;
        this.loop             = loop;
        this.pageSnapping     = pageSnapping;
        this.duration         = duration ?? TimeSpan.FromMilliseconds(kDefaultTransactionDuration);
    }
Ejemplo n.º 16
0
 public static TransformerPageView children(
     Key key                                  = null,
     int?index                                = null,
     TimeSpan?duration                        = null,
     Curve curve                              = null,
     float viewportFraction                   = 1.0f,
     bool loop                                = false,
     Axis scrollDirection                     = Axis.horizontal,
     ScrollPhysics physics                    = null,
     bool pageSnapping                        = true,
     ValueChanged <int> onPageChanged         = null,
     IndexController controller               = null,
     PageTransformer transformer              = null,
     List <Widget> children                   = null,
     TransformerPageController pageController = null
     )
 {
     D.assert(children != null);
     return(new TransformerPageView(
                itemCount: children.Count,
                itemBuilder: (context, _index) => children[index: _index],
                pageController: pageController,
                transformer: transformer,
                pageSnapping: pageSnapping,
                key: key,
                index: index,
                duration: duration,
                curve: curve,
                viewportFraction: viewportFraction,
                loop: loop,
                scrollDirection: scrollDirection,
                physics: physics,
                onPageChanged: onPageChanged,
                controller: controller
                ));
 }
Ejemplo n.º 17
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,
            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;
        }
Ejemplo n.º 18
0
        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;
        }
Ejemplo n.º 19
0
 public CustomSegmentedControl(
     List <object> items,
     List <Widget> children,
     ValueChanged <int> onValueChanged = null,
     int currentIndex               = 0,
     float headerHeight             = 44,
     Widget trailing                = null,
     Decoration headerDecoration    = null,
     Decoration indicator           = null,
     EdgeInsets headerPadding       = null,
     EdgeInsets labelPadding        = null,
     float?indicatorWidth           = null,
     Color unselectedColor          = null,
     Color selectedColor            = null,
     TextStyle unselectedTextStyle  = null,
     TextStyle selectedTextStyle    = null,
     CustomTabController controller = null,
     ScrollPhysics physics          = null,
     ValueChanged <int> onTap       = null,
     Key key = null
     ) : base(key: key)
 {
     D.assert(items != null);
     D.assert(items.Count >= 2);
     D.assert(children != null);
     D.assert(children.Count >= 2);
     D.assert(children.Count == items.Count);
     D.assert(currentIndex < children.Count);
     this.items            = items;
     this.children         = children;
     this.onValueChanged   = onValueChanged;
     this.unselectedColor  = unselectedColor ?? CColors.TextTitle;
     this.selectedColor    = selectedColor ?? CColors.PrimaryBlue;
     this.currentIndex     = currentIndex;
     this.headerHeight     = headerHeight;
     this.trailing         = trailing;
     this.headerDecoration = headerDecoration ?? new BoxDecoration(
         color: CColors.White,
         border: new Border(bottom: new BorderSide(color: CColors.Separator2))
         );
     this.indicator = indicator ?? new CustomUnderlineTabIndicator(
         insets: EdgeInsets.zero,
         borderSide: new BorderSide(width: 2, color: CColors.PrimaryBlue)
         );
     this.headerPadding       = headerPadding ?? EdgeInsets.zero;
     this.labelPadding        = labelPadding ?? EdgeInsets.symmetric(horizontal: 16, vertical: 10);
     this.indicatorWidth      = indicatorWidth;
     this.unselectedTextStyle = unselectedTextStyle ?? new TextStyle(
         fontSize: 16,
         fontFamily: "Roboto-Regular",
         color: this.unselectedColor
         );
     this.selectedTextStyle = selectedTextStyle ?? new TextStyle(
         fontSize: 16,
         fontFamily: "Roboto-Medium",
         color: this.unselectedColor
         );
     this.controller = controller;
     this.physics    = physics;
     this.onTap      = onTap;
 }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
0
 public override ScrollPhysics applyTo(ScrollPhysics ancestor)
 {
     return(new RefreshScrollPhysics(parent: this.buildParent(ancestor),
                                     enableOverScroll: this.enableOverScroll));
 }
Ejemplo n.º 22
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
                                                                     ));
        }
Ejemplo n.º 23
0
 public override ScrollPhysics applyTo(ScrollPhysics ancestor)
 {
     return(new _SnappingScrollPhysics(parent: this.buildParent(ancestor),
                                       midScrollOffset: this.midScrollOffset));
 }
Ejemplo n.º 24
0
    public static Swiper List(

        PageTransformer transformer,
        IList list,
        float containerHeight,
        float containerWidth,
        float itemHeight,
        float itemWidth,
        CustomLayoutOption customLayoutOption,
        SwiperDataBuilder builder,
        ValueChanged <int> onIndexChanged,
        Key key,
        int index,
        SwiperOnTap onTap,
        ScrollPhysics physics,
        Curve curve,
        float fade,
        SwiperPlugin pagination,
        SwiperPlugin control,
        List <SwiperPlugin> plugins,
        SwiperController controller,
        float viewportFraction = 1.0f,
        bool loop            = true,
        int duration         = kDefaultAutoplayTransactionDuration,
        Axis scrollDirection = Axis.horizontal,
        bool autoplay        = false,
        int autoplayDelay    = kDefaultAutoplayDelayMs,
        bool reverse         = false,
        bool autoplayDisableOnInteraction = true,
        bool outer  = false,
        float scale = 1.0f
        )
    {
        return(new Swiper(
                   transformer: transformer,
                   customLayoutOption: customLayoutOption,
                   containerHeight: containerHeight,
                   containerWidth: containerWidth,
                   viewportFraction: viewportFraction,
                   itemHeight: itemHeight,
                   itemWidth: itemWidth,
                   outer: outer,
                   scale: scale,
                   autoplay: autoplay,
                   autoplayDelay: autoplayDelay,
                   autoplayDisableOnInteraction: autoplayDisableOnInteraction,
                   duration: duration,
                   onIndexChanged: onIndexChanged,
                   index: index,
                   onTap: onTap,
                   curve: curve ?? Curves.ease,
                   key: key,
                   scrollDirection: scrollDirection,
                   pagination: pagination,
                   control: control,
                   controller: controller,
                   loop: loop,
                   plugins: plugins,
                   physics: physics,
                   fade: fade,
                   itemBuilder: (BuildContext context, int ind) =>
        {
            return builder(context, list[ind], ind);
        },
                   itemCount: list.Count));
    }
Ejemplo n.º 25
0
    public static Swiper Children(
        Key key,
        IndexedWidgetBuilder itemBuilder,
        PageTransformer transformer,
        int itemCount,
        ValueChanged <int> onIndexChanged,
        int index,
        SwiperOnTap onTap,
        List <SwiperPlugin> plugins,
        SwiperPlugin control,
        ScrollPhysics physics,
        SwiperController controller,
        SwiperPlugin pagination,
        CustomLayoutOption customLayoutOption,
        List <Widget> children,
        /// since v1.0.0
        float containerHeight,
        float containerWidth,
        float itemHeight,
        float itemWidth,
        float scale,
        float fade,

        ///

        Curve curve,
        float viewportFraction = 1.0f,
        bool autoplay          = false,
        bool loop            = true,
        Axis scrollDirection = Axis.horizontal,
        SwiperLayout layout  = SwiperLayout.DEFAULT,
        int autoplayDelay    = kDefaultAutoplayDelayMs,
        bool autoplayDisableOnInteraction = true,
        int duration = kDefaultAutoplayTransactionDuration,
        bool outer   = false,
        PageIndicatorLayout indicatorLayout = PageIndicatorLayout.NONE,
        bool reverse = false

        )
    {
        D.assert(children != null, () => "children must not be null");

        return(new Swiper(
                   transformer: transformer,
                   customLayoutOption: customLayoutOption,
                   containerHeight: containerHeight,
                   containerWidth: containerWidth,
                   viewportFraction: viewportFraction,
                   itemHeight: itemHeight,
                   itemWidth: itemWidth,
                   outer: outer,
                   scale: scale,
                   fade: fade,
                   autoplay: autoplay,
                   autoplayDelay: autoplayDelay,
                   autoplayDisableOnInteraction: autoplayDisableOnInteraction,
                   duration: duration,
                   onIndexChanged: onIndexChanged,
                   index: index,
                   onTap: onTap,
                   curve: curve ?? Curves.ease,
                   scrollDirection: scrollDirection,
                   pagination: pagination,
                   control: control,
                   controller: controller,
                   loop: loop,
                   plugins: plugins,
                   physics: physics,
                   key: key,
                   itemBuilder: (BuildContext context, int ind) =>
        {
            return children[ind];
        },
                   itemCount: children.Count));
    }
Ejemplo n.º 26
0
    public Swiper(

        IndexedWidgetBuilder itemBuilder,
        int itemCount,
        SwiperPlugin pagination,
        SwiperPlugin control,
        /// since v1.0.0
        float containerHeight,
        float containerWidth,
        float itemHeight,
        float itemWidth,
        float scale = 1,
        float fade  = 1,
        CustomLayoutOption customLayoutOption = null,

        SwiperController controller = null,
        PageTransformer transformer = null,
        int index = 0,
        List <SwiperPlugin> plugins       = null,
        ValueChanged <int> onIndexChanged = null,
        ScrollPhysics physics             = null,
        ///
        SwiperOnTap onTap = null,

        Curve curve                       = null,
        Key key                           = null,
        float viewportFraction            = 1.0f,
        bool autoplay                     = false,
        bool loop                         = true,
        Axis scrollDirection              = Axis.horizontal,
        SwiperLayout layout               = SwiperLayout.DEFAULT,
        int autoplayDelay                 = kDefaultAutoplayDelayMs,
        bool autoplayDisableOnInteraction = true,
        int duration                      = kDefaultAutoplayTransactionDuration,
        bool outer                        = false,

        PageIndicatorLayout indicatorLayout = PageIndicatorLayout.NONE
        ) :
        base(key: key)
    {
        D.assert(itemBuilder != null || transformer != null, () => { return("itemBuilder and transformItemBuilder must not be both null"); });
        D.assert(
            !loop ||
            ((loop &&
              layout == SwiperLayout.DEFAULT &&
              (indicatorLayout == PageIndicatorLayout.SCALE ||
               indicatorLayout == PageIndicatorLayout.COLOR ||
               indicatorLayout == PageIndicatorLayout.NONE)) ||
             (loop && layout != SwiperLayout.DEFAULT)),
            () => "Only support `PageIndicatorLayout.SCALE` and `PageIndicatorLayout.COLOR`when layout==SwiperLayout.DEFAULT in loop mode");

        this.itemBuilder        = itemBuilder;
        this.indicatorLayout    = indicatorLayout;
        this.transformer        = transformer;
        this.onIndexChanged     = onIndexChanged;
        this.itemCount          = itemCount;
        this.index              = index;
        this.onTap              = onTap;
        this.plugins            = plugins;
        this.control            = control;
        this.physics            = physics;
        this.controller         = controller;
        this.pagination         = pagination;
        this.customLayoutOption = customLayoutOption;
        this.containerHeight    = containerHeight;
        this.containerWidth     = containerWidth;
        this.viewportFraction   = viewportFraction;
        this.itemHeight         = itemHeight;
        this.itemWidth          = itemWidth;
        this.scale              = scale;
        this.fade            = fade;
        this.curve           = curve ?? Curves.ease;
        this.autoplay        = autoplay;
        this.loop            = loop;
        this.scrollDirection = scrollDirection;
        this.layout          = layout;
        this.autoplayDelay   = autoplayDelay;
        this.autoplayDisableOnInteraction = autoplayDisableOnInteraction;
        this.duration = duration;
        this.outer    = outer;
    }
Ejemplo n.º 27
0
        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;
        }