示例#1
0
 public override Widget build(BuildContext context)
 {
     return(new Icon(_getIconData(Theme.of(context).platform)));
 }
示例#2
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            ThemeData     theme     = Theme.of(context);
            ListTileTheme tileTheme = ListTileTheme.of(context);

            IconThemeData iconThemeData = null;

            if (this.leading != null || this.trailing != null)
            {
                iconThemeData = new IconThemeData(color: this._iconColor(theme, tileTheme));
            }

            Widget leadingIcon = null;

            if (this.leading != null)
            {
                leadingIcon = IconTheme.merge(
                    data: iconThemeData,
                    child: this.leading);
            }

            TextStyle titleStyle = this._titleTextStyle(theme, tileTheme);
            Widget    titleText  = new AnimatedDefaultTextStyle(
                style: titleStyle,
                duration: Constants.kThemeChangeDuration,
                child: this.title ?? new SizedBox()
                );

            Widget    subtitleText  = null;
            TextStyle subtitleStyle = null;

            if (this.subtitle != null)
            {
                subtitleStyle = this._subtitleTextStyle(theme, tileTheme);
                subtitleText  = new AnimatedDefaultTextStyle(
                    style: subtitleStyle,
                    duration: Constants.kThemeChangeDuration,
                    child: this.subtitle);
            }

            Widget trailingIcon = null;

            if (this.trailing != null)
            {
                trailingIcon = IconTheme.merge(
                    data: iconThemeData,
                    child: this.trailing);
            }

            EdgeInsets _defaultContentPadding = EdgeInsets.symmetric(horizontal: 16.0f);
            EdgeInsets resolvedContentPadding =
                this.contentPadding ?? tileTheme?.contentPadding ?? _defaultContentPadding;

            return(new InkWell(
                       onTap: this.enabled ? this.onTap : null,
                       onLongPress: this.enabled ? this.onLongPress : null,
                       child: new SafeArea(
                           top: false,
                           bottom: false,
                           mininum: resolvedContentPadding,
                           child: new _ListTile(
                               leading: leadingIcon,
                               title: titleText,
                               subtitle: subtitleText,
                               trailing: trailingIcon,
                               isDense: this._isDenseLayout(tileTheme),
                               isThreeLine: this.isThreeLine,
                               titleBaselineType: titleStyle.textBaseline,
                               subtitleBaselineType: subtitleStyle?.textBaseline
                               )
                           )
                       ));
        }
示例#3
0
 public static DialogTheme of(BuildContext context)
 {
     return(Theme.of(context).dialogTheme);
 }
示例#4
0
        List <Widget> _createTiles()
        {
            MaterialLocalizations localizations = MaterialLocalizations.of(context);

            D.assert(localizations != null);
            ThemeData themeData = Theme.of(context);
            TextStyle effectiveSelectedLabelStyle =
                _effectiveTextStyle(widget.selectedLabelStyle, widget.selectedFontSize);
            TextStyle effectiveUnselectedLabelStyle =
                _effectiveTextStyle(widget.unselectedLabelStyle, widget.unselectedFontSize);
            Color themeColor;

            switch (themeData.brightness)
            {
            case Brightness.light:
                themeColor = themeData.primaryColor;
                break;

            case Brightness.dark:
                themeColor = themeData.accentColor;
                break;

            default:
                throw new Exception("Unknown brightness: " + themeData.brightness);
            }

            ColorTween colorTween;

            switch (widget.type)
            {
            case BottomNavigationBarType.fix:
                colorTween = new ColorTween(
                    begin: widget.unselectedItemColor ?? themeData.textTheme.caption.color,
                    end: widget.selectedItemColor ?? widget.fixedColor ?? themeColor
                    );
                break;

            case BottomNavigationBarType.shifting:
                colorTween = new ColorTween(
                    begin: widget.unselectedItemColor ?? Colors.white,
                    end: widget.selectedItemColor ?? Colors.white
                    );
                break;

            default:
                throw new UIWidgetsError($"Unknown bottom navigation bar type: {widget.type}");
            }

            List <Widget> tiles = new List <Widget>();

            for (int i = 0; i < widget.items.Count; i++)
            {
                int index = i;
                tiles.Add(new _BottomNavigationTile(
                              widget.type,
                              widget.items[i],
                              _animations[i],
                              widget.iconSize,
                              selectedIconTheme: widget.selectedIconTheme,
                              unselectedIconTheme: widget.unselectedIconTheme,
                              selectedLabelStyle: effectiveSelectedLabelStyle,
                              unselectedLabelStyle: effectiveUnselectedLabelStyle,
                              onTap: () => {
                    if (widget.onTap != null)
                    {
                        widget.onTap(index);
                    }
                },
                              colorTween: colorTween,
                              flex: _evaluateFlex(_animations[i]),
                              selected: i == widget.currentIndex,
                              showSelectedLabels: widget.showSelectedLabels,
                              showUnselectedLabels: widget.showUnselectedLabels,
                              indexLabel: localizations.tabLabel(tabIndex: i + 1, tabCount: widget.items.Count)
                              ));
            }

            return(tiles);
        }