TextStyle _titleTextStyle(ThemeData theme, ListTileTheme tileTheme) { TextStyle style = null; if (tileTheme != null) { switch (tileTheme.style) { case ListTileStyle.drawer: style = theme.textTheme.body2; break; case ListTileStyle.list: style = theme.textTheme.subhead; break; } } else { style = theme.textTheme.subhead; } Color color = this._textColor(theme, tileTheme, style.color); return(this._isDenseLayout(tileTheme) ? style.copyWith(fontSize: 13.0f, color: color) : style.copyWith(color: color)); }
public static Widget merge( Key key = null, bool?dense = null, ListTileStyle?style = null, Color selectedColor = null, Color iconColor = null, Color textColor = null, EdgeInsets contentPadding = null, Widget child = null) { D.assert(child != null); return(new Builder( builder: (BuildContext context) => { ListTileTheme parent = of(context); return new ListTileTheme( key: key, dense: dense ?? parent.dense, style: style ?? parent.style, selectedColor: selectedColor ?? parent.selectedColor, iconColor: iconColor ?? parent.iconColor, textColor: textColor ?? parent.textColor, contentPadding: contentPadding ?? parent.contentPadding, child: child); } )); }
Color _textColor(ThemeData theme, ListTileTheme tileTheme, Color defaultColor) { if (!this.enabled) { return(theme.disabledColor); } if (this.selected && tileTheme?.selectedColor != null) { return(tileTheme.selectedColor); } if (!this.selected && tileTheme?.textColor != null) { return(tileTheme.textColor); } if (this.selected) { switch (theme.brightness) { case Brightness.light: return(theme.primaryColor); case Brightness.dark: return(theme.accentColor); } } return(defaultColor); }
Widget _buildChildren(BuildContext context, Widget child) { Color borderSideColor = this._borderColor.value ?? Colors.transparent; return(new Container( decoration: new BoxDecoration( color: this._backgroundColor.value ?? Colors.transparent, border: new Border( top: new BorderSide(color: borderSideColor), bottom: new BorderSide(color: borderSideColor))), child: new Column( mainAxisSize: MainAxisSize.min, children: new List <Widget> { ListTileTheme.merge( iconColor: this._iconColor.value, textColor: this._headerColor.value, child: new ListTile( onTap: this._handleTap, leading: this.widget.leading, title: this.widget.title, trailing: this.widget.trailing ?? new RotationTransition( turns: this._iconTurns, child: new Icon(Icons.expand_more) ) ) ), new ClipRect( child: new Align( heightFactor: this._heightFactor.value, child: child) ) } ) )); }
Color _iconColor(ThemeData theme, ListTileTheme tileTheme) { if (!this.enabled) { return(theme.disabledColor); } if (this.selected && tileTheme?.selectedColor != null) { return(tileTheme.selectedColor); } if (!this.selected && tileTheme?.iconColor != null) { return(tileTheme.iconColor); } switch (theme.brightness) { case Brightness.light: return(this.selected ? theme.primaryColor : Colors.black45); case Brightness.dark: return(this.selected ? theme.accentColor : null); } return(null); }
TextStyle _subtitleTextStyle(ThemeData theme, ListTileTheme tileTheme) { TextStyle style = theme.textTheme.body1; Color color = this._textColor(theme, tileTheme, theme.textTheme.caption.color); return(this._isDenseLayout(tileTheme) ? style.copyWith(color: color, fontSize: 12.0f) : style.copyWith(color: color)); }
public override bool updateShouldNotify(InheritedWidget oldWidget) { ListTileTheme _oldWidget = (ListTileTheme)oldWidget; return(this.dense != _oldWidget.dense || this.style != _oldWidget.style || this.selectedColor != _oldWidget.selectedColor || this.iconColor != _oldWidget.iconColor || this.textColor != _oldWidget.textColor || this.contentPadding != _oldWidget.contentPadding); }
public override Widget build(BuildContext context) { Widget control = null; switch (_switchListTileType) { case _SwitchListTileType.adaptive: control = Switch.adaptive( value: value, onChanged: onChanged, activeColor: activeColor, activeThumbImage: activeThumbImage, inactiveThumbImage: inactiveThumbImage, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, activeTrackColor: activeTrackColor, inactiveTrackColor: inactiveTrackColor, inactiveThumbColor: inactiveThumbColor ); break; case _SwitchListTileType.material: control = new Switch( value: value, onChanged: onChanged, activeColor: activeColor, activeThumbImage: activeThumbImage, inactiveThumbImage: inactiveThumbImage, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, activeTrackColor: activeTrackColor, inactiveTrackColor: inactiveTrackColor, inactiveThumbColor: inactiveThumbColor ); break; } return(ListTileTheme.merge( selectedColor: activeColor ?? Theme.of(context).accentColor, child: new ListTile( leading: secondary, title: title, subtitle: subtitle, trailing: control, isThreeLine: isThreeLine, dense: dense, contentPadding: contentPadding, enabled: onChanged != null, onTap: onChanged != null ? () => { onChanged(!value); } : (GestureTapCallback)null, selected: selected ) )); }
public override Widget wrap(BuildContext context, Widget child) { ListTileTheme ancestorTheme = context.findAncestorWidgetOfExactType <ListTileTheme>(); return(ReferenceEquals(this, ancestorTheme) ? child : new ListTileTheme( dense: dense, style: style, selectedColor: selectedColor, iconColor: iconColor, textColor: textColor, contentPadding: contentPadding, child: child )); }
public override Widget build(BuildContext context) { Widget control = new Checkbox( value: value, onChanged: onChanged, activeColor: activeColor, checkColor: checkColor, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap ); Widget leading = null; Widget trailing = null; switch (controlAffinity) { case ListTileControlAffinity.leading: leading = control; trailing = secondary; break; case ListTileControlAffinity.trailing: case ListTileControlAffinity.platform: leading = secondary; trailing = control; break; } return(ListTileTheme.merge( selectedColor: activeColor ?? Theme.of(context).accentColor, child: new ListTile( leading: leading, title: title, subtitle: subtitle, trailing: trailing, isThreeLine: isThreeLine, dense: dense, enabled: onChanged != null, onTap: onChanged != null ? () => { onChanged(!value); } : (GestureTapCallback)null, selected: selected ) )); }
public static ListTileTheme of(BuildContext context) { ListTileTheme result = (ListTileTheme)context.inheritFromWidgetOfExactType(typeof(ListTileTheme)); return(result ?? new ListTileTheme()); }
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 ) ) )); }
bool _isDenseLayout(ListTileTheme tileTheme) { return(this.dense != null ? this.dense ?? false : (tileTheme?.dense ?? false)); }
public static ListTileTheme of(BuildContext context) { ListTileTheme result = context.dependOnInheritedWidgetOfExactType <ListTileTheme>(); return(result ?? new ListTileTheme()); }
bool _isDenseLayout(ListTileTheme tileTheme) { return(dense ?? tileTheme?.dense ?? false); }