Example #1
0
 public MaterialBannerTheme(
     Key key = null,
     MaterialBannerThemeData data = null,
     Widget child = null
     ) : base(key: key, child: child)
 {
     this.data = data;
 }
Example #2
0
        public override Widget build(BuildContext context)
        {
            D.assert(actions.isNotEmpty);

            ThemeData theme = Theme.of(context);
            MaterialBannerThemeData bannerTheme = MaterialBannerTheme.of(context);

            bool isSingleRow           = actions.Count == 1 && !forceActionsBelow;
            EdgeInsetsGeometry padding = this.padding ?? bannerTheme?.padding ?? (isSingleRow
                ? EdgeInsetsDirectional.only(start: 16.0f, top: 2.0f)
                : EdgeInsetsDirectional.only(start: 16.0f, top: 24.0f, end: 16.0f,
                                             bottom: 4.0f));
            EdgeInsetsGeometry leadingPadding = this.leadingPadding
                                                ?? bannerTheme?.padding
                                                ?? EdgeInsetsDirectional.only(end: 16.0f);

            Widget buttonBar = new ButtonBar(
                layoutBehavior: ButtonBarLayoutBehavior.constrained,
                children: actions
                );

            Color backgroundColor = this.backgroundColor
                                    ?? bannerTheme?.backgroundColor
                                    ?? theme.colorScheme.surface;
            TextStyle textStyle = contentTextStyle
                                  ?? bannerTheme?.contentTextStyle
                                  ?? theme.textTheme.bodyText2;

            var rowList = new List <Widget>();

            if (leading != null)
            {
                rowList.Add(new Padding(
                                padding: leadingPadding,
                                child: leading
                                ));
            }

            rowList.Add(new Expanded(
                            child: new DefaultTextStyle(
                                style: textStyle,
                                child: content
                                )
                            ));
            if (isSingleRow)
            {
                rowList.Add(buttonBar);
            }

            var columnList = new List <Widget>();

            columnList.Add(new Padding(
                               padding: padding,
                               child: new Row(
                                   children: rowList
                                   )
                               ));
            if (!isSingleRow)
            {
                columnList.Add(buttonBar);
            }

            columnList.Add(new Divider(height: 0));

            return(new Container(
                       color: backgroundColor,
                       child: new Column(
                           children: columnList
                           )
                       ));
        }