Exemplo n.º 1
0
        public override Widget build(BuildContext context)
        {
            Widget image = new DecoratedBox(
                decoration: new BoxDecoration(
                    borderRadius: BorderRadius.circular(6.0f),
                    image: new DecorationImage(
                        image: new AssetImage(
                            this.detail.imageAsset
                            ),
                        fit: BoxFit.cover,
                        alignment: Alignment.center
                        )
                    )
                );

            Widget item;

            if (this.detail.title == null && this.detail.subtitle == null)
            {
                item = new Container(
                    height: 240.0f,
                    padding: EdgeInsets.all(16.0f),
                    child: new SafeArea(
                        top: false,
                        bottom: false,
                        child: image
                        )
                    );
            }
            else
            {
                item = new ListTile(
                    title: new Text(this.detail.title),
                    subtitle: new Text(this.detail.subtitle),
                    leading: new SizedBox(width: 32.0f, height: 32.0f, child: image)
                    );
            }

            return(new DecoratedBox(
                       decoration: new BoxDecoration(color: Colors.grey.shade200),
                       child: item
                       ));
        }
        public override Widget build(BuildContext context)
        {
            float bottomPadding = MediaQuery.of(context).padding.bottom;

            Widget result = new DecoratedBox(
                decoration: new BoxDecoration(
                    border: this.border,
                    color: this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor
                    ),
                child: new SizedBox(
                    height: BottomAppBarUtils._kTabBarHeight + bottomPadding,
                    child: IconTheme.merge( // Default with the inactive state.
                        data: new IconThemeData(
                            color: this.inactiveColor,
                            size: this.iconSize
                            ),
                        child: new DefaultTextStyle( // Default with the inactive state.
                            style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle
                            .copyWith(color: this.inactiveColor),
                            child: new Padding(
                                padding: EdgeInsets.only(bottom: bottomPadding),
                                child: new Row(
                                    crossAxisAlignment: CrossAxisAlignment.end,
                                    children: this._buildTabItems(context)
                                    )
                                )
                            )
                        )
                    )
                );

            if (!this.opaque(context))
            {
                result = new ClipRect(
                    child: new BackdropFilter(
                        filter: ImageFilter.blur(sigmaX: 10.0f, sigmaY: 10.0f),
                        child: result
                        )
                    );
            }

            return(result);
        }
Exemplo n.º 3
0
        public override Widget build(BuildContext context)
        {
            float bottomPadding   = MediaQuery.of(context).padding.bottom;
            Color backgroundColor = CupertinoDynamicColor.resolve(
                this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor,
                context
                );

            BorderSide resolveBorderSide(BorderSide side)
            {
                return(side == BorderSide.none
                    ? side
                    : side.copyWith(color: CupertinoDynamicColor.resolve(side.color, context)));
            }

            Border resolvedBorder = border == null || border.GetType() != typeof(Border)
                ? border
                : new Border(
                top: resolveBorderSide(border.top),
                left: resolveBorderSide(border.left),
                bottom: resolveBorderSide(border.bottom),
                right: resolveBorderSide(border.right)
                );

            Color  inactive = CupertinoDynamicColor.resolve(inactiveColor, context);
            Widget result   = new DecoratedBox(
                decoration: new BoxDecoration(
                    border: resolvedBorder,
                    color: backgroundColor
                    ),
                child: new SizedBox(
                    height: BottomAppBarUtils._kTabBarHeight + bottomPadding,
                    child: IconTheme.merge( // Default with the inactive state.
                        data: new IconThemeData(
                            color: inactiveColor,
                            size: iconSize
                            ),
                        child: new DefaultTextStyle( // Default with the inactive state.
                            style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(color: inactive),
                            child: new Padding(
                                padding: EdgeInsets.only(bottom: bottomPadding),
                                child: new Row(
                                    crossAxisAlignment: CrossAxisAlignment.end,
                                    children: _buildTabItems(context)
                                    )
                                )
                            )
                        )
                    )
                );

            if (!opaque(context))
            {
                result = new ClipRect(
                    child: new BackdropFilter(
                        filter: ImageFilter.blur(sigmaX: 10.0f, sigmaY: 10.0f),
                        child: result
                        )
                    );
            }

            return(result);
        }
            public override void visitElementAfter(markdown.Element element)
            {
                string tag = element.tag;
                if (_isBlockTag(tag))
                {
                    _addAnonymousBLockIfNeeded(styleSheet.styles(tag));

                    _BlockElement current = _blocks.removeLast();
                    Widget child;

                    if (current.children.isNotEmpty())
                    {
                        child = new Column(null, null, null, MainAxisAlignment.start, MainAxisSize.max,
                            CrossAxisAlignment.stretch, VerticalDirection.down, current.children);
                    }
                    else
                    {
                        child = new SizedBox();
                    }

                    if (_isListTag(tag))
                    {
                        Debug.Assert(_listIndents.isNotEmpty(), "_listIndents.isNotEmpty()");
                        _listIndents.removeLast();
                    }
                    else if (tag == "li")
                    {
                        if (_listIndents.isNotEmpty())
                        {
                            child = new Row(
                                null,
                                null,
                                null,
                                MainAxisAlignment.start,
                                MainAxisSize.max,
                                CrossAxisAlignment.start,
                                VerticalDirection.down,
                                new List<Widget>()
                                {
                                    new SizedBox(null, styleSheet.listIndent, null, _buildBullet(_listIndents.last())),
                                    new Expanded(null, 1, child)
                                });
                        }
                    }
                    else if (tag == "blockquote")
                    {
                        child = new DecoratedBox(
                            null,
                            styleSheet.blockquoteDecoration,
                            DecorationPosition.background,
                            new Padding(
                                null,
                                EdgeInsets.all(styleSheet.blockquotePadding),
                                child));
                    }
                    else if (tag == "pre")
                    {
                        child = new DecoratedBox(
                            null,
                            styleSheet.codeblockDecoration,
                            DecorationPosition.background,
                            new Padding(
                                null,
                                EdgeInsets.all(styleSheet.codeblockPadding),
                                child));
                    }
                    else if (tag == "hr")
                    {
                        child = new DecoratedBox(
                            null,
                            styleSheet.horizontalRuleDecoration,
                            DecorationPosition.background,
                            child);
                    }

                    _addBlockChild(child);
                }
                else
                {
                    _InlineElement current = _inlines.removeLast();
                    _InlineElement parent = _inlines.last();

                    if (tag == "img")
                    {
                        current.children.Add(_buildImage(element.attributes["src"]));
                    }
                    else if (tag == "a")
                    {
                        _linkHandlers.removeLast();
                    }

                    if (current.children.isNotEmpty())
                    {
                        parent.children.AddRange(current.children);
                    }
                }
            }
Exemplo n.º 5
0
        public override void visitElementAfter(Element element)
        {
            var tag = element.tag;

            if (builderUtil._isBlockTag(tag))
            {
                this._addAnonymousBlockIfNeeded();

                var    current = this._blocks.removeLast();
                Widget child;

                if (current.children.isNotEmpty())
                {
                    child = new Column(
                        crossAxisAlignment: this.fitContent ? CrossAxisAlignment.start : CrossAxisAlignment.stretch,
                        children: current.children
                        );
                }
                else
                {
                    child = new SizedBox();
                }

                if (builderUtil._isListTag(tag))
                {
                    Debug.Assert(this._listIndents.isNotEmpty());
                    this._listIndents.removeLast();
                }
                else if (tag == "li")
                {
                    if (this._listIndents.isNotEmpty())
                    {
                        if (element.children.Count == 0)
                        {
                            element.children.Add(new Text(""));
                        }

                        Widget bullet;
                        var    el = element.children[0];
                        string elType;
                        if (el is Element && (el as Element).attributes.TryGetValue("type", out elType) &&
                            elType == "checkbox")
                        {
                            var val = (el as Element).attributes["checked"] != "false";
                            bullet = this._buildCheckBox(val);
                        }
                        else
                        {
                            bullet = this._buildBullet(this._listIndents.last());
                        }

                        child = new Row(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget> {
                            new SizedBox(
                                width: this.styleSheet.listIndent,
                                child: bullet
                                ),
                            new Expanded(child: child)
                        }
                            );
                    }
                }
                else if (tag == "table")
                {
                    child = new Table(
                        defaultColumnWidth: this.styleSheet.tableColumnWidth,
                        defaultVerticalAlignment: TableCellVerticalAlignment.middle,
                        border: this.styleSheet.tableBorder,
                        children: this._tables.removeLast().rows
                        );
                }
                else if (tag == "blockquote")
                {
                    this._isInBlockquote = false;
                    child = new DecoratedBox(
                        decoration: this.styleSheet.blockquoteDecoration,
                        child: new Padding(
                            padding: this.styleSheet.blockquotePadding,
                            child: child
                            )
                        );
                }
                else if (tag == "pre")
                {
                    child = new DecoratedBox(
                        decoration: this.styleSheet.codeblockDecoration,
                        child: child
                        );
                }
                else if (tag == "hr")
                {
                    child = new DecoratedBox(
                        decoration: this.styleSheet.horizontalRuleDecoration,
                        child: child
                        );
                }

                this._addBlockChild(child);
            }
            else
            {
                var current = this._inlines.removeLast();
                var parent  = this._inlines.last();

                if (tag == "img")
                {
                    // create an image widget for this image
                    current.children.Add(this._buildImage(element.attributes["src"]));
                }
                else if (tag == "br")
                {
                    current.children.Add(this._buildRichText(new TextSpan(text: "\n")));
                }
                else if (tag == "th" || tag == "td")
                {
                    TextAlign align = TextAlign.left;
                    string    style;
                    element.attributes.TryGetValue("style", out style);
                    if (style == null || style.isEmpty())
                    {
                        align = tag == "th" ? this.styleSheet.tableHeadAlign : TextAlign.left;
                    }
                    else
                    {
                        var   regExp = new Regex(@"text-align: (left|center|right)");
                        Match match  = regExp.matchAsPrefix(style);
                        if (match.Success)
                        {
                            switch (match.Groups[1].Value)
                            {
                            case "left":
                                align = TextAlign.left;
                                break;

                            case "center":
                                align = TextAlign.center;
                                break;

                            case "right":
                                align = TextAlign.right;
                                break;
                            }
                        }
                    }

                    Widget child = this._buildTableCell(this._mergeInlineChildren(current.children),
                                                        textAlign: align
                                                        );
                    this._tables.Single().rows.last().children.Add(child);
                }
                else if (tag == "a")
                {
                    this._linkHandlers.removeLast();
                }

                if (current.children.isNotEmpty())
                {
                    parent.children.AddRange(current.children);
                }
            }
        }