public override Widget build(BuildContext context) { D.assert(MaterialD.debugCheckHasMaterial(context)); Color currentColor; if (this.onPressed != null) { currentColor = this.color; } else { currentColor = this.disabledColor ?? Theme.of(context).disabledColor; } Widget result = new ConstrainedBox( constraints: new BoxConstraints(minWidth: IconButtonUtils._kMinButtonSize, minHeight: IconButtonUtils._kMinButtonSize), child: new Padding( padding: this.padding, child: new SizedBox( height: this.iconSize, width: this.iconSize, child: new Align( alignment: this.alignment, child: IconTheme.merge( data: new IconThemeData( size: this.iconSize, color: currentColor), child: this.icon) ) ) ) ); if (this.tooltip != null) { result = new Tooltip( message: this.tooltip, child: result); } return(new InkResponse( onTap: () => { if (this.onPressed != null) { this.onPressed(); } }, child: result, highlightColor: this.highlightColor ?? Theme.of(context).highlightColor, splashColor: this.splashColor ?? Theme.of(context).splashColor, radius: Mathf.Max( Material.defaultSplashRadius, (this.iconSize + Mathf.Min(this.padding.horizontal, this.padding.vertical)) * 0.7f) )); }
public override Widget build(BuildContext context) { Widget current = this.child; if (this.child == null && (this.constraints == null || !this.constraints.isTight)) { current = new LimitedBox( maxWidth: 0.0, maxHeight: 0.0, child: new ConstrainedBox(constraints: BoxConstraints.expand()) ); } if (this.alignment != null) { current = new Align(alignment: this.alignment, child: current); } EdgeInsets effetivePadding = this._paddingIncludingDecoration; if (effetivePadding != null) { current = new Padding(padding: effetivePadding, child: current); } if (this.decoration != null) { current = new DecoratedBox(decoration: this.decoration, child: current); } if (this.foregroundDecoration != null) { current = new DecoratedBox( decoration: this.foregroundDecoration, position: DecorationPosition.foreground, child: current ); } if (this.constraints != null) { current = new ConstrainedBox(constraints: this.constraints, child: current); } if (this.margin != null) { current = new Padding(padding: this.margin, child: current); } if (this.transform != null) { current = new Transform(transform: new Matrix3(this.transform), child: current); } return(current); }
public override Widget build(BuildContext context) { float elevation = this.widget.enabled ? (this._highlight ? this.widget.highlightElevation : this.widget.elevation) : this.widget.disabledElevation; Widget result = new ConstrainedBox( constraints: this.widget.constraints, child: new Material( elevation: elevation, textStyle: this.widget.textStyle, shape: this.widget.shape, color: this.widget.fillColor, type: this.widget.fillColor == null ? MaterialType.transparency : MaterialType.button, animationDuration: this.widget.animationDuration, clipBehavior: this.widget.clipBehavior, child: new InkWell( onHighlightChanged: this._handleHighlightChanged, splashColor: this.widget.splashColor, highlightColor: this.widget.highlightColor, onTap: this.widget.onPressed == null ? (GestureTapCallback)null : () => { if (this.widget.onPressed != null) { this.widget.onPressed(); } }, customBorder: this.widget.shape, child: IconTheme.merge( data: new IconThemeData(color: this.widget.textStyle?.color), child: new Container( padding: this.widget.padding, child: new Center( widthFactor: 1.0f, heightFactor: 1.0f, child: this.widget.child) ) ) ) ) ); return(result); }
public override Widget build(BuildContext context) { if (direction == Axis.horizontal) { List <Widget> children = texts.Select( s => { Widget child = new Text(s, style: style, textAlign: textAlign, maxLines: maxLines); child = new ConstrainedBox( constraints: new BoxConstraints( minWidth: minWidth ?? 0.0f, maxWidth: maxWidth ?? MediaQuery.of(context).size.width, minHeight: minHeight ?? 0.0f, maxHeight: maxHeight ?? MediaQuery.of(context).size.height ), child: child ); if (decoration != null) { child = new Container( padding: padding, child: child, decoration: decoration ); } return(child); } ).ToList(); return(new Table( children: new List <TableRow> { new TableRow(children: children) }, defaultColumnWidth: new IntrinsicColumnWidth() )); } else { List <TableRow> children = texts.Select( s => { Widget child = new Text(s, style: style, textAlign: textAlign, maxLines: maxLines); child = new ConstrainedBox( constraints: new BoxConstraints( minWidth: minWidth ?? 10.0f, maxWidth: maxWidth ?? MediaQuery.of(context).size.width, minHeight: minHeight ?? 10.0f, maxHeight: maxHeight ?? MediaQuery.of(context).size.height ), child: child ); if (decoration != null) { child = new Container( padding: padding, child: child, decoration: decoration ); } return(new TableRow(children: new List <Widget> { child })); } ).ToList(); return(new Table( defaultColumnWidth: new IntrinsicColumnWidth(), children: children )); } }
public override Widget build(BuildContext context) { float unit = 1.0f / (route.items.Count + 1.5f); List <Widget> children = new List <Widget>(); PopupMenuThemeData popupMenuTheme = PopupMenuTheme.of(context); for (int i = 0; i < route.items.Count; i += 1) { int index = i; float start = (index + 1) * unit; float end = (start + 1.5f * unit).clamp(0.0f, 1.0f); CurvedAnimation opacityCurvedAnimation = new CurvedAnimation( parent: route.animation, curve: new Interval(start, end) ); Widget item = route.items[index]; if (route.initialValue != null && route.items[index].represents((T)route.initialValue)) { item = new Container( color: Theme.of(context).highlightColor, child: item ); } children.Add( new _MenuItem( onLayout: (Size size) => { route.itemSizes[index] = size; }, child: new FadeTransition( opacity: opacityCurvedAnimation, child: item ) ) ); } CurveTween opacity = new CurveTween(curve: new Interval(0.0f, 1.0f / 3.0f)); CurveTween width = new CurveTween(curve: new Interval(0.0f, unit)); CurveTween height = new CurveTween(curve: new Interval(0.0f, unit * route.items.Count)); Widget child = new ConstrainedBox( constraints: new BoxConstraints( minWidth: material_._kMenuMinWidth, maxWidth: material_._kMenuMaxWidth ), child: new IntrinsicWidth( stepWidth: material_._kMenuWidthStep, child: new SingleChildScrollView( padding: EdgeInsets.symmetric( vertical: material_._kMenuVerticalPadding ), child: new ListBody(children: children) ) ) ); return(new AnimatedBuilder( animation: route.animation, builder: (_, builderChild) => { return new Opacity( opacity: opacity.evaluate(route.animation), child: new Material( shape: route.shape ?? popupMenuTheme.shape, color: route.color ?? popupMenuTheme.color, type: MaterialType.card, elevation: route.elevation ?? popupMenuTheme.elevation ?? 8.0f, child: new Align( alignment: Alignment.topRight, widthFactor: width.evaluate(route.animation), heightFactor: height.evaluate(route.animation), child: builderChild ) ) ); }, child: child )); }
public override Widget build(BuildContext context) { D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); ThemeData themeData = Theme.of(context); ScaffoldState scaffold = Scaffold.of(context, nullOk: true); ModalRoute parentRoute = ModalRoute.of(context); bool hasDrawer = scaffold?.hasDrawer ?? false; bool hasEndDrawer = scaffold?.hasEndDrawer ?? false; bool canPop = parentRoute?.canPop ?? false; bool useCloseButton = parentRoute is PageRoute && ((PageRoute)parentRoute).fullscreenDialog; IconThemeData appBarIconTheme = this.widget.iconTheme ?? themeData.primaryIconTheme; TextStyle centerStyle = this.widget.textTheme?.title ?? themeData.primaryTextTheme.title; TextStyle sideStyle = this.widget.textTheme?.body1 ?? themeData.primaryTextTheme.body1; if (this.widget.toolbarOpacity != 1.0f) { float opacity = new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget.toolbarOpacity); if (centerStyle?.color != null) { centerStyle = centerStyle.copyWith(color: centerStyle.color.withOpacity(opacity)); } if (sideStyle?.color != null) { sideStyle = sideStyle.copyWith(color: sideStyle.color.withOpacity(opacity)); } appBarIconTheme = appBarIconTheme.copyWith( opacity: opacity * (appBarIconTheme.opacity ?? 1.0f) ); } Widget leading = this.widget.leading; if (leading == null && this.widget.automaticallyImplyLeading) { if (hasDrawer) { leading = new IconButton( icon: new Icon(Icons.menu), onPressed: this._handleDrawerButton, tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip); } else { if (canPop) { leading = useCloseButton ? (Widget) new CloseButton() : new BackButton(); } } } if (leading != null) { leading = new ConstrainedBox( constraints: BoxConstraints.tightFor(width: AppBarUtils._kLeadingWidth), child: leading); } Widget title = this.widget.title; if (title != null) { title = new DefaultTextStyle( style: centerStyle, softWrap: false, overflow: TextOverflow.ellipsis, child: title); } Widget actions = null; if (this.widget.actions != null && this.widget.actions.isNotEmpty()) { actions = new Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: this.widget.actions); } else if (hasEndDrawer) { actions = new IconButton( icon: new Icon(Icons.menu), onPressed: this._handleDrawerButtonEnd, tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip); } Widget toolbar = new NavigationToolbar( leading: leading, middle: title, trailing: actions, centerMiddle: this.widget._getEffectiveCenterTitle(themeData).Value, middleSpacing: this.widget.titleSpacing); Widget appBar = new ClipRect( child: new CustomSingleChildLayout( layoutDelegate: new _ToolbarContainerLayout(), child: IconTheme.merge( data: appBarIconTheme, child: new DefaultTextStyle( style: sideStyle, child: toolbar) ) ) ); if (this.widget.bottom != null) { appBar = new Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new Flexible( child: new ConstrainedBox( constraints: new BoxConstraints(maxHeight: Constants.kToolbarHeight), child: appBar ) ), this.widget.bottomOpacity == 1.0f ? (Widget)this.widget.bottom : new Opacity( opacity: new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget .bottomOpacity), child: this.widget.bottom ) } ); } if (this.widget.primary) { appBar = new SafeArea( top: true, child: appBar); } appBar = new Align( alignment: Alignment.topCenter, child: appBar); if (this.widget.flexibleSpace != null) { appBar = new Stack( fit: StackFit.passthrough, children: new List <Widget> { this.widget.flexibleSpace, appBar } ); } Brightness brightness = this.widget.brightness ?? themeData.primaryColorBrightness; SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark; return(new AnnotatedRegion <SystemUiOverlayStyle>( value: overlayStyle, child: new Material( color: this.widget.backgroundColor ?? themeData.primaryColor, elevation: this.widget.elevation, child: appBar ))); }
public override Widget build(BuildContext context) { Widget current = child; if (child == null && (constraints == null || !constraints.isTight)) { current = new LimitedBox( maxWidth: 0.0f, maxHeight: 0.0f, child: new ConstrainedBox(constraints: BoxConstraints.expand()) ); } if (alignment != null) { current = new Align(alignment: alignment, child: current); } EdgeInsetsGeometry effetivePadding = _paddingIncludingDecoration; if (effetivePadding != null) { current = new Padding(padding: effetivePadding, child: current); } if (color != null) { current = new ColoredBox(color: color, child: current); } if (decoration != null) { current = new DecoratedBox(decoration: decoration, child: current); } if (foregroundDecoration != null) { current = new DecoratedBox( decoration: foregroundDecoration, position: DecorationPosition.foreground, child: current ); } if (constraints != null) { current = new ConstrainedBox(constraints: constraints, child: current); } if (margin != null) { current = new Padding(padding: margin, child: current); } if (transform != null) { current = new Transform(transform: new Matrix4(transform), child: current); } if (clipBehavior != Clip.none) { current = new ClipPath( clipper: new _DecorationClipper( textDirection: Directionality.of(context), decoration: decoration ), clipBehavior: clipBehavior, child: current ); } return(current); }
public override Widget build(BuildContext context) { Color effectiveTextColor = MaterialStateProperty <Color> .resolveAs <Color>(widget.textStyle?.color, _states); ShapeBorder effectiveShape = MaterialStateProperty <Color> .resolveAs <ShapeBorder>(widget.shape, _states); Offset densityAdjustment = widget.visualDensity.baseSizeAdjustment; BoxConstraints effectiveConstraints = widget.visualDensity.effectiveConstraints(widget.constraints); EdgeInsetsGeometry padding = widget.padding.add( EdgeInsets.only( left: densityAdjustment.dx, top: densityAdjustment.dy, right: densityAdjustment.dx, bottom: densityAdjustment.dy ) ).clamp(EdgeInsets.zero, EdgeInsetsGeometry.infinity) as EdgeInsets; Widget result = new ConstrainedBox( constraints: effectiveConstraints, child: new Material( elevation: _effectiveElevation, textStyle: widget.textStyle?.copyWith(color: effectiveTextColor), shape: effectiveShape, color: widget.fillColor, type: widget.fillColor == null ? MaterialType.transparency : MaterialType.button, animationDuration: widget.animationDuration, clipBehavior: widget.clipBehavior, child: new InkWell( focusNode: widget.focusNode, canRequestFocus: widget.enabled, onFocusChange: _handleFocusedChanged, autofocus: widget.autofocus, onHighlightChanged: _handleHighlightChanged, splashColor: widget.splashColor, highlightColor: widget.highlightColor, focusColor: widget.focusColor, hoverColor: widget.hoverColor, onHover: _handleHoveredChanged, onTap: widget.onPressed == null ? (GestureTapCallback)null : () => { if (widget.onPressed != null) { widget.onPressed(); } }, onLongPress: widget.onLongPress, enableFeedback: widget.enableFeedback, customBorder: effectiveShape, child: IconTheme.merge( data: new IconThemeData(color: effectiveTextColor), child: new Container( padding: padding, child: new Center( widthFactor: 1.0f, heightFactor: 1.0f, child: widget.child) ) ) ) ) ); Size minSize = null; switch (widget.materialTapTargetSize) { case MaterialTapTargetSize.padded: minSize = new Size( material_.kMinInteractiveDimension + densityAdjustment.dx, material_.kMinInteractiveDimension + densityAdjustment.dy ); D.assert(minSize.width >= 0.0f); D.assert(minSize.height >= 0.0f); break; case MaterialTapTargetSize.shrinkWrap: minSize = Size.zero; break; } return(new _InputPadding( minSize: minSize, child: result )); }
public override Widget build(BuildContext context) { Widget themedIcon = new IconTheme( data: iconTheme, child: icon ); Widget styledLabel = new DefaultTextStyle( style: labelTextStyle, child: label ); Widget content = null; switch (labelType) { case NavigationRailLabelType.none: Widget iconPart = new SizedBox( width: minWidth, height: minWidth, child: new Align( alignment: Alignment.center, child: themedIcon ) ); if (extendedTransitionAnimation.value == 0) { content = new Stack( children: new List <Widget>() { iconPart, new SizedBox( width: 0, height: 0, child: new Opacity( opacity: 0.0f, child: label ) ) } ) ; } else { content = new ConstrainedBox( constraints: new BoxConstraints( minWidth: MathUtils.lerpNullableFloat(minWidth, minExtendedWidth, extendedTransitionAnimation.value) ?? 0 ), child: new ClipRect( child: new Row( children: new List <Widget> { iconPart, new Align( heightFactor: 1.0f, widthFactor: extendedTransitionAnimation.value, alignment: AlignmentDirectional.centerStart, child: new Opacity( opacity: _extendedLabelFadeValue(), child: styledLabel ) ), new SizedBox(width: material_._horizontalDestinationPadding), } ) ) ); } break; case NavigationRailLabelType.selected: float appearingAnimationValue = 1 - _positionAnimation.value; float verticalPadding = MathUtils.lerpNullableFloat(material_._verticalDestinationPaddingNoLabel, material_._verticalDestinationPaddingWithLabel, appearingAnimationValue); content = new Container( constraints: new BoxConstraints( minWidth: minWidth ?? 0, minHeight: minWidth ?? 0 ), padding: EdgeInsets.symmetric(horizontal: material_._horizontalDestinationPadding), child: new ClipRect( child: new Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: new List <Widget>() { new SizedBox(height: verticalPadding), themedIcon, new Align( alignment: Alignment.topCenter, heightFactor: appearingAnimationValue, widthFactor: 1.0f, child: new Opacity( opacity: selected ?? false ? _normalLabelFadeInValue() : _normalLabelFadeOutValue(), child: styledLabel ) ), new SizedBox(height: verticalPadding) } ) ) ); break; case NavigationRailLabelType.all: content = new Container( constraints: new BoxConstraints( minWidth: minWidth ?? 0, minHeight: minWidth ?? 0 ), padding: EdgeInsets.symmetric(horizontal: material_._horizontalDestinationPadding), child: new Column( children: new List <Widget>() { new SizedBox(height: material_._verticalDestinationPaddingWithLabel), themedIcon, styledLabel, new SizedBox(height: material_._verticalDestinationPaddingWithLabel), } )); break; } ColorScheme colors = Theme.of(context).colorScheme; return(new Material( type: MaterialType.transparency, clipBehavior: Clip.none, child: new InkResponse( onTap: () => onTap(), onHover: (_) => { }, highlightShape: BoxShape.rectangle, borderRadius: BorderRadius.all(Radius.circular((minWidth ?? 0) / 2.0f)), containedInkWell: true, splashColor: colors.primary.withOpacity(0.12f), hoverColor: colors.primary.withOpacity(0.04f), child: content ) )); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterial(context)); ThemeData theme = Theme.of(context); Color currentColor; if (onPressed != null) { currentColor = color; } else { currentColor = disabledColor ?? Theme.of(context).disabledColor; } VisualDensity effectiveVisualDensity = visualDensity ?? theme.visualDensity; BoxConstraints unadjustedConstraints = constraints ?? new BoxConstraints( minWidth: material_._kMinButtonSize, minHeight: material_._kMinButtonSize ); BoxConstraints adjustedConstraints = effectiveVisualDensity.effectiveConstraints(unadjustedConstraints); Widget result = new ConstrainedBox( constraints: adjustedConstraints, child: new Padding( padding: padding, child: new SizedBox( height: iconSize, width: iconSize, child: new Align( alignment: alignment, child: IconTheme.merge( data: new IconThemeData( size: iconSize, color: currentColor ), child: icon ) ) ) ) ); if (tooltip != null) { result = new Tooltip( message: tooltip, child: result); } return(new InkResponse( focusNode: focusNode, autofocus: autofocus, canRequestFocus: onPressed != null, onTap: () => { if (onPressed != null) { onPressed(); } }, enableFeedback: enableFeedback ?? false, child: result, focusColor: focusColor ?? Theme.of(context).focusColor, hoverColor: hoverColor ?? Theme.of(context).hoverColor, highlightColor: highlightColor ?? Theme.of(context).highlightColor, splashColor: splashColor ?? Theme.of(context).splashColor, radius: Mathf.Max( Material.defaultSplashRadius, (iconSize + Mathf.Min(padding.horizontal, padding.vertical)) * 0.7f) )); }