Ejemplo n.º 1
0
        public override Widget build(BuildContext context)
        {
            ThemeData theme           = Theme.of(context);
            bool      isDark          = theme.brightness == Brightness.dark;
            float     textScaleFactor = MediaQuery.textScaleFactorOf(context);

            List <Widget> titleChildren = new List <Widget> {
                new Text(
                    this.demo.title,
                    style: theme.textTheme.subhead.copyWith(
                        color: isDark ? Colors.white : new Color(0xFF202124)
                        )
                    ),
            };

            if (this.demo.subtitle != null)
            {
                titleChildren.Add(
                    new Text(
                        this.demo.subtitle,
                        style: theme.textTheme.body1.copyWith(
                            color: isDark ? Colors.white : new Color(0xFF60646B)
                            )
                        )
                    );
            }

            return(new RawMaterialButton(
                       padding: EdgeInsets.zero,
                       splashColor: theme.primaryColor.withOpacity(0.12f),
                       highlightColor: Colors.transparent,
                       onPressed: () => { this._launchDemo(context); },
                       child: new Container(
                           constraints: new BoxConstraints(minHeight: HomeUtils._kDemoItemHeight *textScaleFactor),
                           child: new Row(
                               children: new List <Widget> {
                new Container(
                    width: 56.0f,
                    height: 56.0f,
                    alignment: Alignment.center,
                    child: new Icon(
                        this.demo.icon,
                        size: 24.0f,
                        color: isDark ? Colors.white : HomeUtils._kUIWidgetsBlue
                        )
                    ),
                new Expanded(
                    child: new Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: titleChildren
                        )
                    ),
                new SizedBox(width: 44.0f),
            }
                               )
                           )
                       ));
        }
Ejemplo n.º 2
0
        public override Widget build(BuildContext context)
        {
            FocusScope.of(context).reparentIfNeeded(this.widget.focusNode);

            DefaultTextStyle defaultTextStyle   = DefaultTextStyle.of(context);
            TextStyle        effectiveTextStyle = this.widget.style;

            if (this.widget.style == null || this.widget.style.inherit)
            {
                effectiveTextStyle = defaultTextStyle.style.merge(this.widget.style);
            }

            Widget child = new WealthyText(
                key: this._richTextKey,
                textAlign: this.widget.textAlign ?? defaultTextStyle.textAlign ?? TextAlign.left,
                softWrap: this.widget.softWrap ?? defaultTextStyle.softWrap,
                overflow: this.widget.overflow ?? defaultTextStyle.overflow,
                textScaleFactor: this.widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context),
                maxLines: this.widget.maxLines ?? defaultTextStyle.maxLines,
                textSpanList: this.widget.textSpanList,
                style: effectiveTextStyle,
                onSelectionChanged: () => {
                if (this._hasFocus)
                {
                    return;
                }

                FocusScope.of(this.context).requestFocus(this.widget.focusNode);
            },
                selectionColor: this.widget.selectionColor ?? Colors.blue);

            return(new IgnorePointer(
                       ignoring: false,
                       child: new RichTextSelectionGestureDetector(
                           onTapDown: this._handleTapDown,
                           onSingleTapUp: this._handleSingleTapUp,
                           onSingleTapCancel: this._handleSingleTapCancel,
                           onSingleLongTapStart: this._handleLongPress,
                           onDragSelectionStart: this._handleDragSelectionStart,
                           onDragSelectionUpdate: this._handleDragSelectionUpdate,
                           behavior: HitTestBehavior.translucent,
                           child: child
                           )
                       ));
        }
Ejemplo n.º 3
0
        public override Widget build(BuildContext context)
        {
            float textScaleFactor = MediaQuery.textScaleFactorOf(context);

            return(new Container(
                       constraints: new BoxConstraints(minHeight: GalleryOptionUtils._kItemHeight *textScaleFactor),
                       padding: GalleryOptionUtils._kItemPadding,
                       alignment: AlignmentDirectional.centerStart,
                       child: new DefaultTextStyle(
                           style: DefaultTextStyle.of(context).style,
                           maxLines: 2,
                           overflow: TextOverflow.fade,
                           child: new IconTheme(
                               data: Theme.of(context).primaryIconTheme,
                               child: this.child
                               )
                           )
                       ));
        }
Ejemplo n.º 4
0
        public override Widget build(BuildContext context)
        {
            var defaultTextStyle   = DefaultTextStyle.of(context);
            var effectiveTextStyle = style;

            if (style == null || style.inherit)
            {
                effectiveTextStyle = defaultTextStyle.style.merge(style);
            }

            if (MediaQuery.boldTextOverride(context))
            {
                effectiveTextStyle = effectiveTextStyle.merge(new TextStyle(fontWeight: FontWeight.w700));
            }

            var textSpan = new TextSpan(
                "",
                style: effectiveTextStyle,
                children: _textSpanList
                );

            textSpan.children.ForEach(child =>
            {
                if (child is ImageSpan imageSpan)
                {
                    imageSpan.UpdateImageConfiguration(context);
                }
            });

            var result = new WealthyTextWrapper(
                textAlign: textAlign ?? defaultTextStyle.textAlign ?? TextAlign.left,
                softWrap: softWrap ?? defaultTextStyle.softWrap,
                overflow: overflow ?? defaultTextStyle.overflow,
                textScaleFactor: textScaleFactor ?? MediaQuery.textScaleFactorOf(context),
                maxLines: maxLines ?? defaultTextStyle.maxLines,
                text: textSpan,
                onSelectionChanged: _onSelectionChanged,
                selectionColor: _selectionColor
                );

            return(result);
        }