Ejemplo n.º 1
0
        TextStyle _subtitleTextStyle(ThemeData theme, ListTileTheme tileTheme)
        {
            TextStyle style = theme.textTheme.bodyText2;
            Color     color = _textColor(theme, tileTheme, theme.textTheme.caption.color);

            return(_isDenseLayout(tileTheme)
                ? style.copyWith(color: color, fontSize: 12.0f)
                : style.copyWith(color: color));
        }
Ejemplo n.º 2
0
        public static ChipThemeData fromDefaults(
            Brightness?brightness = null,
            Color primaryColor    = null,
            Color secondaryColor  = null,
            TextStyle labelStyle  = null
            )
        {
            D.assert(primaryColor != null || brightness != null,
                     "One of primaryColor or brightness must be specified");
            D.assert(primaryColor == null || brightness == null,
                     "Only one of primaryColor or brightness may be specified");
            D.assert(secondaryColor != null);
            D.assert(labelStyle != null);

            if (primaryColor != null)
            {
                brightness = ThemeData.estimateBrightnessForColor(primaryColor);
            }

            const int   backgroundAlpha = 0x1f; // 12%
            const int   deleteIconAlpha = 0xde; // 87%
            const int   disabledAlpha   = 0x0c; // 38% * 12% = 5%
            const int   selectAlpha     = 0x3d; // 12% + 12% = 24%
            const int   textLabelAlpha  = 0xde; // 87%
            ShapeBorder shape           = new StadiumBorder();
            EdgeInsets  labelPadding    = EdgeInsets.symmetric(horizontal: 8.0f);
            EdgeInsets  padding         = EdgeInsets.all(4.0f);

            primaryColor = primaryColor ?? (brightness == Brightness.light ? Colors.black : Colors.white);
            Color     backgroundColor        = primaryColor.withAlpha(backgroundAlpha);
            Color     deleteIconColor        = primaryColor.withAlpha(deleteIconAlpha);
            Color     disabledColor          = primaryColor.withAlpha(disabledAlpha);
            Color     selectedColor          = primaryColor.withAlpha(selectAlpha);
            Color     secondarySelectedColor = secondaryColor.withAlpha(selectAlpha);
            TextStyle secondaryLabelStyle    = labelStyle.copyWith(
                color: secondaryColor.withAlpha(textLabelAlpha)
                );

            labelStyle = labelStyle.copyWith(color: primaryColor.withAlpha(textLabelAlpha));

            return(new ChipThemeData(
                       backgroundColor: backgroundColor,
                       deleteIconColor: deleteIconColor,
                       disabledColor: disabledColor,
                       selectedColor: selectedColor,
                       secondarySelectedColor: secondarySelectedColor,
                       labelPadding: labelPadding,
                       padding: padding,
                       shape: shape,
                       labelStyle: labelStyle,
                       secondaryLabelStyle: secondaryLabelStyle,
                       brightness: brightness
                       ));
        }
Ejemplo n.º 3
0
        public override Widget build(BuildContext context)
        {
            TextStyle style = CupertinoActionSheetUtils._kActionSheetActionStyle.copyWith(
                color: isDestructiveAction
                    ? CupertinoDynamicColor.resolve(CupertinoColors.systemRed, context)
                    : CupertinoTheme.of(context).primaryColor);

            if (isDefaultAction)
            {
                style = style.copyWith(fontWeight: FontWeight.w600);
            }

            return(new GestureDetector(
                       onTap: () => onPressed(),
                       behavior: HitTestBehavior.opaque,
                       child: new ConstrainedBox(
                           constraints: new BoxConstraints(
                               minHeight: CupertinoActionSheetUtils._kButtonHeight
                               ),
                           child: new Container(
                               alignment: Alignment.center,
                               padding: EdgeInsets.symmetric(
                                   vertical: 16.0f,
                                   horizontal: 10.0f
                                   ),
                               child: new DefaultTextStyle(
                                   style: style,
                                   child: child,
                                   textAlign: TextAlign.center
                                   )
                               )
                           )
                       ));
        }
Ejemplo n.º 4
0
        protected internal override Widget build(BuildContext context)
        {
            ThemeData   themeData   = Theme.of(context);
            TabBarTheme tabBarTheme = TabBarTheme.of(context);

            TextStyle defaultStyle           = this.labelStyle ?? themeData.primaryTextTheme.body2;
            TextStyle defaultUnselectedStyle =
                this.unselectedLabelStyle ?? this.labelStyle ?? themeData.primaryTextTheme.body2;
            Animation <float> animation = (Animation <float>) this.listenable;
            TextStyle         textStyle = this.selected
                ? TextStyle.lerp(defaultStyle, defaultUnselectedStyle, animation.value)
                : TextStyle.lerp(defaultUnselectedStyle, defaultStyle, animation.value);

            Color selectedColor   = this.labelColor ?? tabBarTheme.labelColor ?? themeData.primaryTextTheme.body2.color;
            Color unselectedColor = this.unselectedLabelColor ??
                                    tabBarTheme.unselectedLabelColor ?? selectedColor.withAlpha(0xB2);
            Color color = this.selected
                ? Color.lerp(selectedColor, unselectedColor, animation.value)
                : Color.lerp(unselectedColor, selectedColor, animation.value);

            return(new DefaultTextStyle(
                       style: textStyle.copyWith(color: color),
                       child: IconTheme.merge(
                           data: new IconThemeData(
                               size: 24.0f,
                               color: color),
                           child: this.child
                           )
                       ));
        }
Ejemplo n.º 5
0
        public override Widget build(BuildContext context)
        {
            float selectedFontSize   = selectedLabelStyle.fontSize ?? 0;
            float unselectedFontSize = unselectedLabelStyle.fontSize ?? 0;

            TextStyle customStyle = TextStyle.lerp(
                unselectedLabelStyle,
                selectedLabelStyle,
                animation.value
                );
            float t = new FloatTween(begin: unselectedFontSize / selectedFontSize, end: 1.0f)
                      .evaluate(animation);
            Widget text = DefaultTextStyle.merge(
                style: customStyle.copyWith(
                    fontSize: selectedFontSize,
                    color: colorTween.evaluate(animation)
                    ),
                child: new Transform(
                    transform: Matrix4.diagonal3Values(t, t, t),
                    alignment: Alignment.bottomCenter,
                    child: item.title
                    )
                );

            if (!showUnselectedLabels && !showSelectedLabels)
            {
                text = new Opacity(
                    opacity: 0.0f,
                    child: text
                    );
            }
            else if (!showUnselectedLabels)
            {
                text = new FadeTransition(
                    opacity: animation,
                    child: text
                    );
            }
            else if (!showSelectedLabels)
            {
                text = new FadeTransition(
                    opacity: new FloatTween(begin: 1.0f, end: 0.0f).animate(animation),
                    child: text
                    );
            }

            return(new Align(
                       alignment: Alignment.bottomCenter,
                       heightFactor: 1.0f,
                       child: new Container(child: text)
                       ));
        }
Ejemplo n.º 6
0
        public override Widget build(BuildContext context)
        {
            Debug.Log("build");
            TextStyle style = CupertinoActionSheetUtils._kActionSheetActionStyle;

            if (this.isDefaultAction)
            {
                style = style.copyWith(fontWeight: FontWeight.w600);
            }

            if (this.isDestructiveAction)
            {
                style = style.copyWith(color: CupertinoColors.destructiveRed);
            }


            return(new GestureDetector(
                       onTap: () => this.onPressed(),
                       behavior: HitTestBehavior.opaque,
                       child: new ConstrainedBox(
                           constraints: new BoxConstraints(
                               minHeight: CupertinoActionSheetUtils._kButtonHeight
                               ),
                           child: new Container(
                               alignment: Alignment.center,
                               padding: EdgeInsets.symmetric(
                                   vertical: 16.0f,
                                   horizontal: 10.0f
                                   ),
                               child: new DefaultTextStyle(
                                   style: style,
                                   child: this.child,
                                   textAlign: TextAlign.center
                                   )
                               )
                           )
                       ));
        }
Ejemplo n.º 7
0
        public override Widget build(BuildContext context)
        {
            ThemeData theme = Theme.of(context);
            TextStyle style = theme.textTheme.subhead;

            if (!this.widget.enabled)
            {
                style = style.copyWith(color: theme.disabledColor);
            }

            Widget item = new AnimatedDefaultTextStyle(
                style: style,
                duration: Constants.kThemeChangeDuration,
                child: new Baseline(
                    baseline: this.widget.height - PopupMenuUtils._kBaselineOffsetFromBottom,
                    baselineType: style.textBaseline,
                    child: this.buildChild()
                    )
                );

            if (!this.widget.enabled)
            {
                bool isDark = theme.brightness == Brightness.dark;
                item = IconTheme.merge(
                    data: new IconThemeData(opacity: isDark ? 0.5f : 0.38f),
                    child: item
                    );
            }

            return(new InkWell(
                       onTap: this.widget.enabled ? this.handleTap : (GestureTapCallback)null,
                       child: new Container(
                           height: this.widget.height,
                           padding: EdgeInsets.symmetric(horizontal: PopupMenuUtils._kMenuHorizontalPadding),
                           child: item
                           )
                       ));
        }
Ejemplo n.º 8
0
        public override Widget build(BuildContext context)
        {
            ThemeData          theme          = Theme.of(context);
            PopupMenuThemeData popupMenuTheme = PopupMenuTheme.of(context);
            TextStyle          style          = widget.textStyle ?? popupMenuTheme.textStyle ?? theme.textTheme.subtitle1;

            if (!widget.enabled)
            {
                style = style.copyWith(color: theme.disabledColor);
            }

            Widget item = new AnimatedDefaultTextStyle(
                style: style,
                duration: material_.kThemeChangeDuration,
                child: new Container(
                    alignment: AlignmentDirectional.centerStart,
                    constraints: new BoxConstraints(minHeight: widget.height),
                    padding: EdgeInsets.symmetric(horizontal: material_._kMenuHorizontalPadding),
                    child: buildChild()
                    )
                );

            if (!widget.enabled)
            {
                bool isDark = theme.brightness == Brightness.dark;
                item = IconTheme.merge(
                    data: new IconThemeData(opacity: isDark ? 0.5f : 0.38f),
                    child: item
                    );
            }

            return(new InkWell(
                       onTap: widget.enabled?handleTap: (GestureTapCallback)null,
                       canRequestFocus: widget.enabled,
                       child: item
                       ));
        }
Ejemplo n.º 9
0
        public override Widget build(BuildContext context)
        {
            return(new LayoutBuilder(
                       builder: (BuildContext _context, BoxConstraints constraints) => {
                FlexibleSpaceBarSettings settings =
                    _context.dependOnInheritedWidgetOfExactType <FlexibleSpaceBarSettings>();
                D.assert(settings != null,
                         () =>
                         "A FlexibleSpaceBar must be wrapped in the widget returned by FlexibleSpaceBar.createSettings().");

                List <Widget> children = new List <Widget>();
                float deltaExtent = settings.maxExtent.Value - settings.minExtent.Value;

                float t = (1.0f - (settings.currentExtent.Value - settings.minExtent.Value) / deltaExtent)
                          .clamp(0.0f, 1.0f);

                if (widget.background != null)
                {
                    float fadeStart = Mathf.Max(0.0f, 1.0f - material_.kToolbarHeight / deltaExtent);
                    float fadeEnd = 1.0f;
                    D.assert(fadeStart <= fadeEnd);

                    float opacity = 1.0f - new Interval(fadeStart, fadeEnd).transform(t);
                    if (opacity > 0.0f)
                    {
                        float height = settings.maxExtent ?? 0;

                        if (widget.stretchModes.Contains(StretchMode.zoomBackground) &&
                            constraints.maxHeight > height)
                        {
                            height = constraints.maxHeight;
                        }

                        children.Add(new Positioned(
                                         top: _getCollapsePadding(t, settings),
                                         left: 0.0f,
                                         right: 0.0f,
                                         height: height,
                                         child: new Opacity(
                                             opacity: opacity,
                                             child: widget.background)
                                         )
                                     );

                        if (widget.stretchModes.Contains(StretchMode.blurBackground) &&
                            constraints.maxHeight > settings.maxExtent)
                        {
                            float blurAmount = (constraints.maxHeight - settings.maxExtent) / 10 ?? 0;
                            children.Add(Positioned.fill(
                                             child: new BackdropFilter(
                                                 child: new Container(
                                                     color: Colors.transparent
                                                     ),
                                                 filter: ui.ImageFilter.blur(
                                                     sigmaX: blurAmount,
                                                     sigmaY: blurAmount
                                                     )
                                                 )
                                             ));
                        }
                    }
                }

                Widget title = null;
                if (widget.title != null)
                {
                    switch (Application.platform)
                    {
                    case RuntimePlatform.IPhonePlayer:
                        title = widget.title;
                        break;

                    default:
                        title = widget.title;
                        break;
                    }
                }

                if (widget.stretchModes.Contains(StretchMode.fadeTitle) &&
                    constraints.maxHeight > settings.maxExtent)
                {
                    float stretchOpacity =
                        1 - (((constraints.maxHeight - settings.maxExtent) / 100)?.clamp(0.0f, 1.0f) ?? 0);
                    title = new Opacity(
                        opacity: stretchOpacity,
                        child: title
                        );
                }

                ThemeData theme = Theme.of(_context);
                float toolbarOpacity = settings.toolbarOpacity.Value;
                if (toolbarOpacity > 0.0f)
                {
                    TextStyle titleStyle = theme.primaryTextTheme.title;
                    titleStyle = titleStyle.copyWith(
                        color: titleStyle.color.withOpacity(toolbarOpacity));

                    bool effectiveCenterTitle = _getEffectiveCenterTitle(theme).Value;
                    EdgeInsetsGeometry padding = widget.titlePadding ??
                                                 EdgeInsets.only(
                        left: effectiveCenterTitle ? 0.0f : 72.0f,
                        bottom: 16.0f
                        );
                    float scaleValue = new FloatTween(begin: 1.5f, end: 1.0f).lerp(t);
                    Matrix4 scaleTransform = Matrix4.diagonal3Values(scaleValue, scaleValue, 1);
                    Alignment titleAlignment = _getTitleAlignment(effectiveCenterTitle);

                    children.Add(new Container(
                                     padding: padding,
                                     child: new Transform(
                                         alignment: titleAlignment,
                                         transform: scaleTransform,
                                         child: new Align(
                                             alignment: titleAlignment,
                                             child: new DefaultTextStyle(
                                                 style: titleStyle,
                                                 child: new LayoutBuilder(
                                                     builder: (BuildContext __context, BoxConstraints _constraints) => {
                        return new Container(
                            width: _constraints.maxWidth / scaleValue,
                            alignment: titleAlignment,
                            child: title
                            );
                    }
                                                     )
                                                 )
                                             )
                                         )
                                     )
                                 );
                }

                return new ClipRect(
                    child: new Stack(
                        children: children)
                    );
            }
                       ));
        }
Ejemplo n.º 10
0
        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
                           )));
        }
Ejemplo n.º 11
0
        public override Widget build(BuildContext context)
        {
            D.assert(material_.debugCheckHasMaterial(context));
            Color     currentColor       = null;
            Color     currentFillColor   = null;
            Color     currentFocusColor  = null;
            Color     currentHoverColor  = null;
            Color     currentSplashColor = null;
            ThemeData theme = Theme.of(context);
            ToggleButtonsThemeData toggleButtonsTheme = ToggleButtonsTheme.of(context);

            if (onPressed != null && selected)
            {
                currentColor = selectedColor
                               ?? toggleButtonsTheme.selectedColor
                               ?? theme.colorScheme.primary;
                currentFillColor = fillColor
                                   ?? theme.colorScheme.primary.withOpacity(0.12f);
                currentFocusColor = focusColor
                                    ?? toggleButtonsTheme.focusColor
                                    ?? theme.colorScheme.primary.withOpacity(0.12f);
                currentHoverColor = hoverColor
                                    ?? toggleButtonsTheme.hoverColor
                                    ?? theme.colorScheme.primary.withOpacity(0.04f);
                currentSplashColor = splashColor
                                     ?? toggleButtonsTheme.splashColor
                                     ?? theme.colorScheme.primary.withOpacity(0.16f);
            }
            else if (onPressed != null && !selected)
            {
                currentColor = color
                               ?? toggleButtonsTheme.color
                               ?? theme.colorScheme.onSurface.withOpacity(0.87f);
                currentFillColor  = theme.colorScheme.surface.withOpacity(0.0f);
                currentFocusColor = focusColor
                                    ?? toggleButtonsTheme.focusColor
                                    ?? theme.colorScheme.onSurface.withOpacity(0.12f);
                currentHoverColor = hoverColor
                                    ?? toggleButtonsTheme.hoverColor
                                    ?? theme.colorScheme.onSurface.withOpacity(0.04f);
                currentSplashColor = splashColor
                                     ?? toggleButtonsTheme.splashColor
                                     ?? theme.colorScheme.onSurface.withOpacity(0.16f);
            }
            else
            {
                currentColor = disabledColor
                               ?? toggleButtonsTheme.disabledColor
                               ?? theme.colorScheme.onSurface.withOpacity(0.38f);
                currentFillColor = theme.colorScheme.surface.withOpacity(0.0f);
            }

            TextStyle      currentTextStyle   = textStyle ?? toggleButtonsTheme.textStyle ?? theme.textTheme.bodyText2;
            BoxConstraints currentConstraints = constraints ?? toggleButtonsTheme.constraints ??
                                                new BoxConstraints(minWidth: material_.kMinInteractiveDimension,
                                                                   minHeight: material_.kMinInteractiveDimension);

            Widget result = new ClipRRect(
                borderRadius: clipRadius,
                child: new RawMaterialButton(
                    textStyle: currentTextStyle.copyWith(
                        color: currentColor
                        ),
                    constraints: currentConstraints,
                    elevation: 0.0f,
                    highlightElevation: 0.0f,
                    fillColor: currentFillColor,
                    focusColor: currentFocusColor,
                    highlightColor: highlightColor
                    ?? theme.colorScheme.surface.withOpacity(0.0f),
                    hoverColor: currentHoverColor,
                    splashColor: currentSplashColor,
                    focusNode: focusNode,
                    materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                    onPressed: onPressed,
                    child: child
                    )
                );

            return(new _SelectToggleButton(
                       key: key,
                       leadingBorderSide: leadingBorderSide,
                       horizontalBorderSide: horizontalBorderSide,
                       trailingBorderSide: trailingBorderSide,
                       borderRadius: borderRadius,
                       isFirstButton: isFirstButton,
                       isLastButton: isLastButton,
                       child: result
                       ));
        }
Ejemplo n.º 12
0
        public override Widget build(BuildContext context)
        {
            FlexibleSpaceBarSettings settings =
                (FlexibleSpaceBarSettings)context.inheritFromWidgetOfExactType(typeof(FlexibleSpaceBarSettings));

            D.assert(settings != null,
                     () => "A FlexibleSpaceBar must be wrapped in the widget returned by FlexibleSpaceBar.createSettings().");

            List <Widget> children    = new List <Widget>();
            float         deltaExtent = settings.maxExtent.Value - settings.minExtent.Value;

            float t = (1.0f - (settings.currentExtent.Value - settings.minExtent.Value) / deltaExtent)
                      .clamp(0.0f, 1.0f);

            if (this.widget.background != null)
            {
                float fadeStart = Mathf.Max(0.0f, 1.0f - Constants.kToolbarHeight / deltaExtent);
                float fadeEnd   = 1.0f;
                D.assert(fadeStart <= fadeEnd);

                float opacity = 1.0f - new Interval(fadeStart, fadeEnd).transform(t);
                if (opacity > 0.0f)
                {
                    children.Add(new Positioned(
                                     top: this._getCollapsePadding(t, settings),
                                     left: 0.0f,
                                     right: 0.0f,
                                     height: settings.maxExtent,
                                     child: new Opacity(
                                         opacity: opacity,
                                         child: this.widget.background)
                                     )
                                 );
                }
            }

            Widget title = null;

            if (this.widget.title != null)
            {
                switch (Application.platform)
                {
                case RuntimePlatform.IPhonePlayer:
                    title = this.widget.title;
                    break;

                default:
                    title = this.widget.title;
                    break;
                }
            }

            ThemeData theme          = Theme.of(context);
            float     toolbarOpacity = settings.toolbarOpacity.Value;

            if (toolbarOpacity > 0.0f)
            {
                TextStyle titleStyle = theme.primaryTextTheme.title;
                titleStyle = titleStyle.copyWith(
                    color: titleStyle.color.withOpacity(toolbarOpacity));

                bool       effectiveCenterTitle = this._getEffectiveCenterTitle(theme).Value;
                EdgeInsets padding = this.widget.titlePadding ??
                                     EdgeInsets.only(
                    left: effectiveCenterTitle ? 0.0f : 72.0f,
                    bottom: 16.0f
                    );
                float     scaleValue     = new FloatTween(begin: 1.5f, end: 1.0f).lerp(t);
                Matrix4   scaleTransform = new Matrix4().diagonal3Values(scaleValue, scaleValue, 1);
                Alignment titleAlignment = this._getTitleAlignment(effectiveCenterTitle);

                children.Add(new Container(
                                 padding: padding,
                                 child: new Transform(
                                     alignment: titleAlignment,
                                     transform: scaleTransform,
                                     child: new Align(
                                         alignment: titleAlignment,
                                         child: new DefaultTextStyle(
                                             style: titleStyle,
                                             child: title)
                                         )
                                     )
                                 )
                             );
            }

            return(new ClipRect(
                       child: new Stack(
                           children: children)
                       ));
        }
Ejemplo n.º 13
0
        public override Widget build(BuildContext context)
        {
            ThemeData theme            = Theme.of(context);
            TextStyle titleStyle       = theme.textTheme.headline.copyWith(color: Colors.white);
            TextStyle descriptionStyle = theme.textTheme.subhead;

            return(new SafeArea(
                       top: false,
                       bottom: false,
                       child: new Container(
                           padding: EdgeInsets.all(8.0f),
                           height: height,
                           child: new Card(
                               shape: this.shape,
                               child: new Column(
                                   crossAxisAlignment: CrossAxisAlignment.start,
                                   children: new List <Widget> {
                new SizedBox(
                    height: 184.0f,
                    child: new Stack(
                        children: new List <Widget> {
                    Positioned.fill(
                        child: Image.asset(this.destination.assetName,
                                           fit: BoxFit.cover
                                           )
                        ),
                    new Positioned(
                        bottom: 16.0f,
                        left: 16.0f,
                        right: 16.0f,
                        child: new FittedBox(
                            fit: BoxFit.scaleDown,
                            alignment: Alignment.centerLeft,
                            child: new Text(this.destination.title,
                                            style: titleStyle
                                            )
                            )
                        )
                }
                        )
                    ),
                new Expanded(
                    child: new Padding(
                        padding: EdgeInsets.fromLTRB(16.0f, 16.0f, 16.0f, 0.0f),
                        child: new DefaultTextStyle(
                            softWrap: false,
                            overflow: TextOverflow.ellipsis,
                            style: descriptionStyle,
                            child: new Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: new List <Widget> {
                    new Padding(
                        padding: EdgeInsets.only(bottom: 8.0f),
                        child: new Text(this.destination.description[0],
                                        style: descriptionStyle.copyWith(color: Colors.black54)
                                        )
                        ),
                    new Text(this.destination.description[1]),
                    new Text(this.destination.description[2])
                }
                                )
                            )
                        )
                    ),
                ButtonTheme.bar(
                    child: new ButtonBar(
                        alignment: MainAxisAlignment.start,
                        children: new List <Widget> {
                    new FlatButton(
                        child: new Text("SHARE"),
                        textColor: Colors.amber.shade500,
                        onPressed: () => {
                        /* do nothing */
                    }
                        ),
                    new FlatButton(
                        child: new Text("EXPLORE"),
                        textColor: Colors.amber.shade500,
                        onPressed: () => {
                        /* do nothing */
                    }
                        )
                }
                        )
                    ),
            }
                                   )
                               )
                           )
                       ));
        }
Ejemplo n.º 14
0
        public override Widget build(BuildContext context)
        {
            D.assert(WidgetsD.debugCheckHasMediaQuery(context));
            ThemeData theme     = Theme.of(context);
            TextStyle textStyle = theme.primaryTextTheme.subhead.copyWith(color: this.foregroundColor);
            Color     effectiveBackgroundColor = this.backgroundColor;

            if (effectiveBackgroundColor == null)
            {
                switch (ThemeData.estimateBrightnessForColor(textStyle.color))
                {
                case Brightness.dark:
                    effectiveBackgroundColor = theme.primaryColorLight;
                    break;

                case Brightness.light:
                    effectiveBackgroundColor = theme.primaryColorDark;
                    break;
                }
            }
            else if (this.foregroundColor == null)
            {
                switch (ThemeData.estimateBrightnessForColor(this.backgroundColor))
                {
                case Brightness.dark:
                    textStyle = textStyle.copyWith(color: theme.primaryColorLight);
                    break;

                case Brightness.light:
                    textStyle = textStyle.copyWith(color: theme.primaryColorDark);
                    break;
                }
            }

            float minDiameter = this._minDiameter;
            float maxDiameter = this._maxDiameter;

            return(new AnimatedContainer(
                       constraints: new BoxConstraints(
                           minHeight: minDiameter,
                           minWidth: minDiameter,
                           maxWidth: maxDiameter,
                           maxHeight: maxDiameter
                           ),
                       duration: Constants.kThemeChangeDuration,
                       decoration: new BoxDecoration(
                           color: effectiveBackgroundColor,
                           image: this.backgroundImage != null
                        ? new DecorationImage(image: this.backgroundImage, fit: BoxFit.cover)
                        : null,
                           shape: BoxShape.circle
                           ),
                       child: this.child == null
                    ? null
                    : new Center(
                           child: new MediaQuery(
                               data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0f),
                               child: new IconTheme(
                                   data: theme.iconTheme.copyWith(color: textStyle.color),
                                   child: new DefaultTextStyle(
                                       style: textStyle,
                                       child: this.child
                                       )
                                   )
                               )
                           )
                       ));
        }
Ejemplo n.º 15
0
        public override Widget build(BuildContext context)
        {
            ThemeData theme            = Theme.of(context);
            TextStyle titleStyle       = theme.textTheme.headline5.copyWith(color: Colors.white);
            TextStyle descriptionStyle = theme.textTheme.subtitle1;

            var children = new List <Widget>
            {
                // Photo and title.
                new SizedBox(
                    height: 184.0f,
                    child: new Stack(
                        children: new List <Widget>
                {
                    Positioned.fill(
                        // In order to have the ink splash appear above the image, you
                        // must use Ink.image. This allows the image to be painted as part
                        // of the Material and display ink effects above it. Using a
                        // standard Image will obscure the ink splash.
                        child: Ink.image(
                            image: new FileImage(System.IO.Path.Combine(destination.assetPackage,
                                                                        destination.assetName)),
                            fit: BoxFit.cover,
                            child: new Container()
                            )
                        ),
                    new Positioned(
                        bottom: 16.0f,
                        left: 16.0f,
                        right: 16.0f,
                        child: new FittedBox(
                            fit: BoxFit.scaleDown,
                            alignment: Alignment.centerLeft,
                            child: new Text(this.destination.title,
                                            style: titleStyle
                                            )
                            )
                        )
                }
                        )
                    ),
                // Description and share/explore buttons.
                new Padding(
                    padding: EdgeInsets.fromLTRB(16.0f, 16.0f, 16.0f, 0.0f),
                    child: new DefaultTextStyle(
                        softWrap: false,
                        overflow: TextOverflow.ellipsis,
                        style: descriptionStyle,
                        child: new Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget>
                {
                    // three line description
                    new Padding(
                        padding: EdgeInsets.only(bottom: 8.0f),
                        child: new Text(this.destination.description,
                                        style: descriptionStyle.copyWith(color: Colors.black54)
                                        )
                        ),
                    new Text(this.destination.city),
                    new Text(this.destination.location)
                }
                            )
                        )
                    )
            };

            if (this.destination.type == CardDemoType.standard)
            {
                // share, explore buttons
                children.Add(new ButtonBar(
                                 alignment: MainAxisAlignment.start,
                                 children: new List <Widget>
                {
                    new FlatButton(
                        child: new Text("SHARE"),
                        textColor: Colors.amber.shade500,
                        onPressed: () => { Debug.Log("pressed"); }
                        ),
                    new FlatButton(
                        child: new Text("EXPLORE"),
                        textColor: Colors.amber.shade500,
                        onPressed: () => { Debug.Log("pressed"); }
                        )
                }
                                 ));
            }

            return(new Column(
                       crossAxisAlignment: CrossAxisAlignment.start,
                       children: children
                       ));
        }
Ejemplo n.º 16
0
 static TextStyle _effectiveTextStyle(TextStyle textStyle, float fontSize)
 {
     textStyle = textStyle ?? new TextStyle();
     return(textStyle.fontSize == null?textStyle.copyWith(fontSize : fontSize) : textStyle);
 }