Exemplo n.º 1
0
        public bool Equals(TextTheme other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(this.display4 == other.display4 &&
                   this.display3 == other.display3 &&
                   this.display2 == other.display2 &&
                   this.display1 == other.display1 &&
                   this.headline == other.headline &&
                   this.title == other.title &&
                   this.subhead == other.subhead &&
                   this.body2 == other.body2 &&
                   this.body1 == other.body1 &&
                   this.caption == other.caption &&
                   this.button == other.button &&
                   this.subtitle == other.subtitle &&
                   this.overline == other.overline);
        }
Exemplo n.º 2
0
        public Typography(
            TextTheme black       = null,
            TextTheme white       = null,
            TextTheme englishLike = null,
            TextTheme dense       = null,
            TextTheme tall        = null
            )
        {
            black       = black ?? blackMountainView;
            white       = white ?? whiteMountainView;
            englishLike = englishLike ?? englishLike2014;
            dense       = dense ?? dense2014;
            tall        = tall ?? tall2014;

            D.assert(black != null);
            D.assert(white != null);
            D.assert(englishLike != null);
            D.assert(dense != null);
            D.assert(tall != null);

            this.black       = black;
            this.white       = white;
            this.englishLike = englishLike;
            this.dense       = dense;
            this.tall        = tall;
        }
Exemplo n.º 3
0
        TextStyle _subTitleStyle(int index)
        {
            ThemeData themeData = Theme.of(context);
            TextTheme textTheme = themeData.textTheme;

            switch (widget.steps[index].state)
            {
            case StepState.indexed:
            case StepState.editing:
            case StepState.complete:
                return(textTheme.caption);

            case StepState.disabled:
                return(textTheme.caption.copyWith(
                           color: _isDark() ? _kDisabledDark : _kDisabledLight
                           ));

            case StepState.error:
                return(textTheme.caption.copyWith(
                           color: _isDark() ? _kErrorDark : _kErrorLight
                           ));
            }

            return(null);
        }
Exemplo n.º 4
0
        public SliverAppBar(
            Key key        = null,
            Widget leading = null,
            bool automaticallyImplyLeading = true,
            Widget title                   = null,
            List <Widget> actions          = null,
            Widget flexibleSpace           = null,
            PreferredSizeWidget bottom     = null,
            float?elevation                = null,
            bool forceElevated             = false,
            Color backgroundColor          = null,
            Brightness?brightness          = null,
            IconThemeData iconTheme        = null,
            IconThemeData actionsIconTheme = null,
            TextTheme textTheme            = null,
            bool primary                   = true,
            bool?centerTitle               = null,
            float titleSpacing             = NavigationToolbar.kMiddleSpacing,
            float?expandedHeight           = null,
            bool floating                  = false,
            bool pinned  = false,
            bool snap    = false,
            bool stretch = false,
            float stretchTriggerOffset     = 100.0f,
            AsyncCallback onStretchTrigger = null,
            ShapeBorder shape = null
            ) : base(key: key)
        {
            D.assert(floating || !snap, () => "The 'snap' argument only makes sense for floating app bars.");
            D.assert(stretchTriggerOffset > 0.0);

            this.leading = leading;
            this.automaticallyImplyLeading = true;
            this.title                = title;
            this.actions              = actions;
            this.flexibleSpace        = flexibleSpace;
            this.bottom               = bottom;
            this.elevation            = elevation;
            this.forceElevated        = forceElevated;
            this.backgroundColor      = backgroundColor;
            this.brightness           = brightness;
            this.iconTheme            = iconTheme;
            this.actionsIconTheme     = actionsIconTheme;
            this.textTheme            = textTheme;
            this.primary              = primary;
            this.centerTitle          = centerTitle;
            this.titleSpacing         = NavigationToolbar.kMiddleSpacing;
            this.expandedHeight       = expandedHeight;
            this.floating             = floating;
            this.pinned               = pinned;
            this.snap                 = snap;
            this.stretch              = stretch;
            this.stretchTriggerOffset = stretchTriggerOffset;
            this.onStretchTrigger     = onStretchTrigger;
            this.shape                = shape;
        }
Exemplo n.º 5
0
 public static AppBarTheme lerp(AppBarTheme a, AppBarTheme b, float t)
 {
     return(new AppBarTheme(
                brightness: t < 0.5f ? a?.brightness : b?.brightness,
                color: Color.lerp(a?.color, b?.color, t),
                elevation: MathUtils.lerpFloat(a?.elevation ?? 0.0f, b?.elevation ?? 0.0f, t),
                iconTheme: IconThemeData.lerp(a?.iconTheme, b?.iconTheme, t),
                textTheme: TextTheme.lerp(a?.textTheme, b?.textTheme, t)
                ));
 }
Exemplo n.º 6
0
 public static Typography create(
     TextTheme black       = null,
     TextTheme white       = null,
     TextTheme englishLike = null,
     TextTheme dense       = null,
     TextTheme tall        = null
     )
 {
     return(material2014(black, white, englishLike, dense, tall));
 }
Exemplo n.º 7
0
 public static Typography lerp(Typography a, Typography b, double t)
 {
     return(new Typography(
                black: TextTheme.lerp(a.black, b.black, t),
                white: TextTheme.lerp(a.white, b.white, t),
                englishLike: TextTheme.lerp(a.englishLike, b.englishLike, t),
                dense: TextTheme.lerp(a.dense, b.dense, t),
                tall: TextTheme.lerp(a.tall, b.tall, t)
                ));
 }
Exemplo n.º 8
0
        public override Widget build(BuildContext context)
        {
            ColorScheme colorScheme  = Theme.of(context).colorScheme;
            TextTheme   textTheme    = Theme.of(context).textTheme;
            Color       controlColor = colorScheme.onSurface.withOpacity(0.60f);

            var rowChildren = new List <Widget> {
                new Flexible(
                    child: new Container(
                        height: material_._subHeaderHeight,
                        child: new InkWell(
                            onTap: () => widget.onTitlePressed(),
                            child: new Padding(
                                padding: EdgeInsets.symmetric(horizontal: 8),
                                child: new Row(
                                    children: new List <Widget> {
                    new Flexible(
                        child: new Text(
                            widget.title,
                            overflow: TextOverflow.ellipsis,
                            style: textTheme.subtitle2?.copyWith(
                                color: controlColor
                                )
                            )
                        ),
                    new RotationTransition(
                        turns: _controller,
                        child: new Icon(
                            Icons.arrow_drop_down,
                            color: controlColor
                            )
                        ),
                }
                                    )
                                )
                            )
                        )
                    )
            };

            if (widget.mode == DatePickerMode.day)
            {
                // Give space for the prev/next month buttons that are underneath this row
                rowChildren.Add(new SizedBox(width: material_._monthNavButtonsWidth));
            }

            return(new Container(
                       padding: EdgeInsetsDirectional.only(start: 16, end: 4),
                       height: material_._subHeaderHeight,
                       child: new Row(
                           children: rowChildren
                           )
                       ));
        }
Exemplo n.º 9
0
 public _SliverAppBarDelegate(
     Widget leading,
     bool automaticallyImplyLeading,
     Widget title,
     List <Widget> actions,
     Widget flexibleSpace,
     PreferredSizeWidget bottom,
     float?elevation,
     bool forceElevated,
     Color backgroundColor,
     Brightness?brightness,
     IconThemeData iconTheme,
     IconThemeData actionsIconTheme,
     TextTheme textTheme,
     bool primary,
     bool?centerTitle,
     float titleSpacing,
     float?expandedHeight,
     float?collapsedHeight,
     float?topPadding,
     bool floating,
     bool pinned,
     FloatingHeaderSnapConfiguration snapConfiguration,
     OverScrollHeaderStretchConfiguration stretchConfiguration,
     ShapeBorder shape
     )
 {
     D.assert(primary || topPadding == 0.0);
     this.leading = leading;
     this.automaticallyImplyLeading = automaticallyImplyLeading;
     this.title                = title;
     this.actions              = actions;
     this.flexibleSpace        = flexibleSpace;
     this.bottom               = bottom;
     this.elevation            = elevation;
     this.forceElevated        = forceElevated;
     this.backgroundColor      = backgroundColor;
     this.brightness           = brightness;
     this.iconTheme            = iconTheme;
     this.actionsIconTheme     = actionsIconTheme;
     this.textTheme            = textTheme;
     this.primary              = primary;
     this.centerTitle          = centerTitle;
     this.titleSpacing         = titleSpacing;
     this.expandedHeight       = expandedHeight;
     this.collapsedHeight      = collapsedHeight;
     this.topPadding           = topPadding;
     this.floating             = floating;
     this.pinned               = pinned;
     this.snapConfiguration    = snapConfiguration;
     _bottomHeight             = bottom?.preferredSize?.height ?? 0.0f;
     this.snapConfiguration    = snapConfiguration;
     this.stretchConfiguration = stretchConfiguration;
 }
Exemplo n.º 10
0
 public Typography copyWith(
     TextTheme black       = null,
     TextTheme white       = null,
     TextTheme englishLike = null,
     TextTheme dense       = null,
     TextTheme tall        = null)
 {
     return(new Typography(
                black: black ?? this.black,
                white: white ?? this.white,
                englishLike: englishLike ?? this.englishLike,
                dense: dense ?? this.dense,
                tall: tall ?? this.tall));
 }
Exemplo n.º 11
0
 public AppBarTheme(
     Brightness?brightness   = null,
     Color color             = null,
     float?elevation         = null,
     IconThemeData iconTheme = null,
     TextTheme textTheme     = null
     )
 {
     this.brightness = brightness;
     this.color      = color;
     this.elevation  = elevation;
     this.iconTheme  = iconTheme;
     this.textTheme  = textTheme;
 }
Exemplo n.º 12
0
 public static Typography material2018(
     TextTheme black       = null,
     TextTheme white       = null,
     TextTheme englishLike = null,
     TextTheme dense       = null,
     TextTheme tall        = null
     )
 {
     return(Typography._withPlatform(
                black, white,
                englishLike ?? englishLike2018,
                dense ?? dense2018,
                tall ?? tall2018
                ));
 }
Exemplo n.º 13
0
 AppBarTheme copyWith(
     Brightness?brightness   = null,
     Color color             = null,
     float?elevation         = null,
     IconThemeData iconTheme = null,
     TextTheme textTheme     = null
     )
 {
     return(new AppBarTheme(
                brightness: brightness ?? this.brightness,
                color: color ?? this.color,
                elevation: elevation ?? this.elevation,
                iconTheme: iconTheme ?? this.iconTheme,
                textTheme: textTheme ?? this.textTheme
                ));
 }
Exemplo n.º 14
0
 public static ThemeData lerp(ThemeData a, ThemeData b, float t)
 {
     D.assert(a != null);
     D.assert(b != null);
     return(raw(
                brightness: t < 0.5 ? a.brightness : b.brightness,
                primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t),
                primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
                primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t),
                primaryColorDark: Color.lerp(a.primaryColorDark, b.primaryColorDark, t),
                canvasColor: Color.lerp(a.canvasColor, b.canvasColor, t),
                accentColor: Color.lerp(a.accentColor, b.accentColor, t),
                accentColorBrightness: t < 0.5 ? a.accentColorBrightness : b.accentColorBrightness,
                scaffoldBackgroundColor: Color.lerp(a.scaffoldBackgroundColor, b.scaffoldBackgroundColor, t),
                bottomAppBarColor: Color.lerp(a.bottomAppBarColor, b.bottomAppBarColor, t),
                cardColor: Color.lerp(a.cardColor, b.cardColor, t),
                dividerColor: Color.lerp(a.dividerColor, b.dividerColor, t),
                highlightColor: Color.lerp(a.highlightColor, b.highlightColor, t),
                splashColor: Color.lerp(a.splashColor, b.splashColor, t),
                splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory,
                selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t),
                unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t),
                disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t),
                buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme,
                buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t),
                secondaryHeaderColor: Color.lerp(a.secondaryHeaderColor, b.secondaryHeaderColor, t),
                textSelectionColor: Color.lerp(a.textSelectionColor, b.textSelectionColor, t),
                cursorColor: Color.lerp(a.cursorColor, b.cursorColor, t),
                textSelectionHandleColor: Color.lerp(a.textSelectionHandleColor, b.textSelectionHandleColor, t),
                backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t),
                dialogBackgroundColor: Color.lerp(a.dialogBackgroundColor, b.dialogBackgroundColor, t),
                indicatorColor: Color.lerp(a.indicatorColor, b.indicatorColor, t),
                hintColor: Color.lerp(a.hintColor, b.hintColor, t),
                errorColor: Color.lerp(a.errorColor, b.errorColor, t),
                toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t),
                textTheme: TextTheme.lerp(a.textTheme, b.textTheme, t),
                primaryTextTheme: TextTheme.lerp(a.primaryTextTheme, b.primaryTextTheme, t),
                accentTextTheme: TextTheme.lerp(a.accentTextTheme, b.accentTextTheme, t),
                iconTheme: IconThemeData.lerp(a.iconTheme, b.iconTheme, t),
                primaryIconTheme: IconThemeData.lerp(a.primaryIconTheme, b.primaryIconTheme, t),
                accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t),
                materialTapTargetSize: t < 0.5 ? a.materialTapTargetSize : b.materialTapTargetSize,
                pageTransitionsTheme: t < 0.5 ? a.pageTransitionsTheme : b.pageTransitionsTheme,
                colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t),
                typography: Typography.lerp(a.typography, b.typography, t)
                ));
 }
Exemplo n.º 15
0
 public AppBar(
     Key key        = null,
     Widget leading = null,
     bool automaticallyImplyLeading = true,
     Widget title                   = null,
     List <Widget> actions          = null,
     Widget flexibleSpace           = null,
     PreferredSizeWidget bottom     = null,
     float?elevation                = null,
     ShapeBorder shape              = null,
     Color backgroundColor          = null,
     Brightness?brightness          = null,
     IconThemeData iconTheme        = null,
     IconThemeData actionsIconTheme = null,
     TextTheme textTheme            = null,
     bool primary                   = true,
     bool?centerTitle               = null,
     float titleSpacing             = NavigationToolbar.kMiddleSpacing,
     float toolbarOpacity           = 1.0f,
     float bottomOpacity            = 1.0f
     ) : base(key: key)
 {
     D.assert(elevation == null || elevation >= 0.0);
     this.leading = leading;
     this.automaticallyImplyLeading = automaticallyImplyLeading;
     this.title            = title;
     this.actions          = actions;
     this.flexibleSpace    = flexibleSpace;
     this.bottom           = bottom;
     this.elevation        = elevation;
     this.shape            = shape;
     this.backgroundColor  = backgroundColor;
     this.brightness       = brightness;
     this.iconTheme        = iconTheme;
     this.actionsIconTheme = actionsIconTheme;
     this.textTheme        = textTheme;
     this.primary          = primary;
     this.centerTitle      = centerTitle;
     this.titleSpacing     = titleSpacing;
     this.toolbarOpacity   = toolbarOpacity;
     this.bottomOpacity    = bottomOpacity;
     preferredSize         = Size.fromHeight(material_.kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0f));
 }
Exemplo n.º 16
0
        internal static Typography _withPlatform(
            TextTheme black       = null,
            TextTheme white       = null,
            TextTheme englishLike = null,
            TextTheme dense       = null,
            TextTheme tall        = null
            )
        {
            D.assert(englishLike != null);
            D.assert(dense != null);
            D.assert(tall != null);

            //force to use Android color
            black = black ?? blackMountainView;
            white = white ?? whiteMountainView;

            return(new Typography(
                       black, white, englishLike, dense, tall));
        }
Exemplo n.º 17
0
 public static TextTheme lerp(TextTheme a, TextTheme b, float t)
 {
     D.assert(a != null);
     D.assert(b != null);
     return(new TextTheme(
                display4: TextStyle.lerp(a.display4, b.display4, t),
                display3: TextStyle.lerp(a.display3, b.display3, t),
                display2: TextStyle.lerp(a.display2, b.display2, t),
                display1: TextStyle.lerp(a.display1, b.display1, t),
                headline: TextStyle.lerp(a.headline, b.headline, t),
                title: TextStyle.lerp(a.title, b.title, t),
                subhead: TextStyle.lerp(a.subhead, b.subhead, t),
                body2: TextStyle.lerp(a.body2, b.body2, t),
                body1: TextStyle.lerp(a.body1, b.body1, t),
                caption: TextStyle.lerp(a.caption, b.caption, t),
                button: TextStyle.lerp(a.button, b.button, t),
                subtitle: TextStyle.lerp(a.subtitle, b.subtitle, t),
                overline: TextStyle.lerp(a.overline, b.overline, t)
                ));
 }
Exemplo n.º 18
0
        Typography(
            TextTheme black       = null,
            TextTheme white       = null,
            TextTheme englishLike = null,
            TextTheme dense       = null,
            TextTheme tall        = null
            )
        {
            D.assert(black != null);
            D.assert(white != null);
            D.assert(englishLike != null);
            D.assert(dense != null);
            D.assert(tall != null);

            this.black       = black;
            this.white       = white;
            this.englishLike = englishLike;
            this.dense       = dense;
            this.tall        = tall;
        }
Exemplo n.º 19
0
        public TextTheme merge(TextTheme other)
        {
            if (other == null)
            {
                return(this);
            }

            return(this.copyWith(
                       display4: this.display4?.merge(other.display4) ?? other.display4,
                       display3: this.display3?.merge(other.display3) ?? other.display3,
                       display2: this.display2?.merge(other.display2) ?? other.display2,
                       display1: this.display1?.merge(other.display1) ?? other.display1,
                       headline: this.headline?.merge(other.headline) ?? other.headline,
                       title: this.title?.merge(other.title) ?? other.title,
                       subhead: this.subhead?.merge(other.subhead) ?? other.subhead,
                       body2: this.body2?.merge(other.body2) ?? other.body2,
                       body1: this.body1?.merge(other.body1) ?? other.body1,
                       caption: this.caption?.merge(other.caption) ?? other.caption,
                       button: this.button?.merge(other.button) ?? other.button,
                       subtitle: this.subtitle?.merge(other.subtitle) ?? other.subtitle,
                       overline: this.overline?.merge(other.overline) ?? other.overline
                       ));
        }
Exemplo n.º 20
0
        public ThemeData(
            Brightness?brightness             = null,
            MaterialColor primarySwatch       = null,
            Color primaryColor                = null,
            Brightness?primaryColorBrightness = null,
            Color primaryColorLight           = null,
            Color primaryColorDark            = null,
            Color accentColor = null,
            Brightness?accentColorBrightness = null,
            Color canvasColor             = null,
            Color scaffoldBackgroundColor = null,
            Color bottomAppBarColor       = null,
            Color cardColor      = null,
            Color dividerColor   = null,
            Color highlightColor = null,
            Color splashColor    = null,
            InteractiveInkFeatureFactory splashFactory = null,
            Color selectedRowColor         = null,
            Color unselectedWidgetColor    = null,
            Color disabledColor            = null,
            Color buttonColor              = null,
            ButtonThemeData buttonTheme    = null,
            Color secondaryHeaderColor     = null,
            Color textSelectionColor       = null,
            Color cursorColor              = null,
            Color textSelectionHandleColor = null,
            Color backgroundColor          = null,
            Color dialogBackgroundColor    = null,
            Color indicatorColor           = null,
            Color hintColor                = null,
            Color errorColor               = null,
            Color toggleableActiveColor    = null,
            string fontFamily              = null,
            TextTheme textTheme            = null,
            TextTheme primaryTextTheme     = null,
            TextTheme accentTextTheme      = null,
            IconThemeData iconTheme        = null,
            IconThemeData primaryIconTheme = null,
            IconThemeData accentIconTheme  = null,
            MaterialTapTargetSize?materialTapTargetSize = null,
            PageTransitionsTheme pageTransitionsTheme   = null,
            ColorScheme colorScheme = null,
            Typography typography   = null
            )
        {
            brightness = brightness ?? Brightness.light;
            bool isDark = brightness == Brightness.dark;

            primarySwatch          = primarySwatch ?? Colors.blue;
            primaryColor           = primaryColor ?? (isDark ? Colors.grey[900] : primarySwatch);
            primaryColorBrightness = primaryColorBrightness ?? estimateBrightnessForColor(primaryColor);
            primaryColorLight      = primaryColorLight ?? (isDark ? Colors.grey[500] : primarySwatch[100]);
            primaryColorDark       = primaryColorDark ?? (isDark ? Colors.black : primarySwatch[700]);
            bool primaryIsDark = primaryColorBrightness == Brightness.dark;

            toggleableActiveColor = toggleableActiveColor ??
                                    (isDark ? Colors.tealAccent[200] : (accentColor ?? primarySwatch[600]));

            accentColor           = accentColor ?? (isDark ? Colors.tealAccent[200] : primarySwatch[500]);
            accentColorBrightness = accentColorBrightness ?? estimateBrightnessForColor(accentColor);
            bool accentIsDark = accentColorBrightness == Brightness.dark;

            canvasColor             = canvasColor ?? (isDark ? Colors.grey[850] : Colors.grey[50]);
            scaffoldBackgroundColor = scaffoldBackgroundColor ?? canvasColor;
            bottomAppBarColor       = bottomAppBarColor ?? (isDark ? Colors.grey[800] : Colors.white);
            cardColor    = cardColor ?? (isDark ? Colors.grey[800] : Colors.white);
            dividerColor = dividerColor ?? (isDark ? new Color(0x1FFFFFFF) : new Color(0x1F000000));

            colorScheme = colorScheme ?? ColorScheme.fromSwatch(
                primarySwatch: primarySwatch,
                primaryColorDark: primaryColorDark,
                accentColor: accentColor,
                cardColor: cardColor,
                backgroundColor: backgroundColor,
                errorColor: errorColor,
                brightness: brightness);

            splashFactory            = splashFactory ?? InkSplash.splashFactory;
            selectedRowColor         = selectedRowColor ?? Colors.grey[100];
            unselectedWidgetColor    = unselectedWidgetColor ?? (isDark ? Colors.white70 : Colors.black54);
            secondaryHeaderColor     = secondaryHeaderColor ?? (isDark ? Colors.grey[700] : primarySwatch[50]);
            textSelectionColor       = textSelectionColor ?? (isDark ? accentColor : primarySwatch[200]);
            cursorColor              = cursorColor ?? Color.fromRGBO(66, 133, 244, 1.0f);
            textSelectionHandleColor =
                textSelectionHandleColor ?? (isDark ? Colors.tealAccent[400] : primarySwatch[300]);

            backgroundColor       = backgroundColor ?? (isDark ? Colors.grey[700] : primarySwatch[200]);
            dialogBackgroundColor = dialogBackgroundColor ?? (isDark ? Colors.grey[800] : Colors.white);
            indicatorColor        = indicatorColor ?? (accentColor == primaryColor ? Colors.white : accentColor);
            hintColor             = hintColor ?? (isDark ? new Color(0x80FFFFFF) : new Color(0x8A000000));
            errorColor            = errorColor ?? Colors.red[700];

            pageTransitionsTheme = pageTransitionsTheme ?? new PageTransitionsTheme();
            primaryIconTheme     = primaryIconTheme ??
                                   (primaryIsDark
                                   ? new IconThemeData(color: Colors.white)
                                   : new IconThemeData(color: Colors.black));
            accentIconTheme = accentIconTheme ??
                              (accentIsDark
                                  ? new IconThemeData(color: Colors.white)
                                  : new IconThemeData(color: Colors.black));
            iconTheme = iconTheme ??
                        (isDark ? new IconThemeData(color: Colors.white) : new IconThemeData(color: Colors.black87));

            typography = typography ?? new Typography();
            TextTheme defaultTextTheme = isDark ? typography.white : typography.black;

            textTheme = defaultTextTheme.merge(textTheme);
            TextTheme defaultPrimaryTextTheme = primaryIsDark ? typography.white : typography.black;

            primaryTextTheme = defaultPrimaryTextTheme.merge(primaryTextTheme);
            TextTheme defaultAccentTextTheme = accentIsDark ? typography.white : typography.black;

            accentTextTheme       = defaultAccentTextTheme.merge(accentTextTheme);
            materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;
            if (fontFamily != null)
            {
                textTheme        = textTheme.apply(fontFamily: fontFamily);
                primaryTextTheme = primaryTextTheme.apply(fontFamily: fontFamily);
                accentTextTheme  = accentTextTheme.apply(fontFamily: fontFamily);
            }

            buttonColor = buttonColor ?? (isDark ? primarySwatch[600] : Colors.grey[300]);
            buttonTheme = buttonTheme ?? new ButtonThemeData(
                colorScheme: colorScheme,
                buttonColor: buttonColor,
                disabledColor: disabledColor,
                highlightColor: highlightColor,
                splashColor: splashColor,
                materialTapTargetSize: materialTapTargetSize);
            disabledColor  = disabledColor ?? (isDark ? Colors.white30 : Colors.black38);
            highlightColor = highlightColor ??
                             (isDark
                                 ? ThemeDataUtils._kDarkThemeHighlightColor
                                 : ThemeDataUtils._kLightThemeHighlightColor);
            splashColor = splashColor ??
                          (isDark
                              ? ThemeDataUtils._kDarkThemeSplashColor
                              : ThemeDataUtils._kLightThemeSplashColor);

            D.assert(brightness != null);
            D.assert(primaryColor != null);
            D.assert(primaryColorBrightness != null);
            D.assert(primaryColorLight != null);
            D.assert(primaryColorDark != null);
            D.assert(accentColor != null);
            D.assert(accentColorBrightness != null);
            D.assert(canvasColor != null);
            D.assert(scaffoldBackgroundColor != null);
            D.assert(bottomAppBarColor != null);
            D.assert(cardColor != null);
            D.assert(dividerColor != null);
            D.assert(highlightColor != null);
            D.assert(splashColor != null);
            D.assert(splashFactory != null);
            D.assert(selectedRowColor != null);
            D.assert(unselectedWidgetColor != null);
            D.assert(disabledColor != null);
            D.assert(toggleableActiveColor != null);
            D.assert(buttonTheme != null);
            D.assert(secondaryHeaderColor != null);
            D.assert(textSelectionColor != null);
            D.assert(cursorColor != null);
            D.assert(textSelectionHandleColor != null);
            D.assert(backgroundColor != null);
            D.assert(dialogBackgroundColor != null);
            D.assert(indicatorColor != null);
            D.assert(hintColor != null);
            D.assert(errorColor != null);
            D.assert(textTheme != null);
            D.assert(primaryTextTheme != null);
            D.assert(accentTextTheme != null);
            D.assert(iconTheme != null);
            D.assert(primaryIconTheme != null);
            D.assert(accentIconTheme != null);
            D.assert(materialTapTargetSize != null);
            D.assert(pageTransitionsTheme != null);
            D.assert(colorScheme != null);
            D.assert(typography != null);

            D.assert(buttonColor != null);

            this.brightness              = brightness ?? Brightness.light;
            this.primaryColor            = primaryColor;
            this.primaryColorBrightness  = primaryColorBrightness ?? Brightness.light;
            this.primaryColorLight       = primaryColorLight;
            this.primaryColorDark        = primaryColorDark;
            this.canvasColor             = canvasColor;
            this.accentColor             = accentColor;
            this.accentColorBrightness   = accentColorBrightness ?? Brightness.light;
            this.scaffoldBackgroundColor = scaffoldBackgroundColor;
            this.bottomAppBarColor       = bottomAppBarColor;
            this.cardColor                = cardColor;
            this.dividerColor             = dividerColor;
            this.highlightColor           = highlightColor;
            this.splashColor              = splashColor;
            this.splashFactory            = splashFactory;
            this.selectedRowColor         = selectedRowColor;
            this.unselectedWidgetColor    = unselectedWidgetColor;
            this.disabledColor            = disabledColor;
            this.buttonTheme              = buttonTheme;
            this.buttonColor              = buttonColor;
            this.secondaryHeaderColor     = secondaryHeaderColor;
            this.textSelectionColor       = textSelectionColor;
            this.cursorColor              = cursorColor;
            this.textSelectionHandleColor = textSelectionHandleColor;
            this.backgroundColor          = backgroundColor;
            this.dialogBackgroundColor    = dialogBackgroundColor;
            this.indicatorColor           = indicatorColor;
            this.hintColor                = hintColor;
            this.errorColor               = errorColor;
            this.toggleableActiveColor    = toggleableActiveColor;
            this.textTheme                = textTheme;
            this.primaryTextTheme         = primaryTextTheme;
            this.accentTextTheme          = accentTextTheme;
            this.iconTheme                = iconTheme;
            this.primaryIconTheme         = primaryIconTheme;
            this.accentIconTheme          = accentIconTheme;
            this.materialTapTargetSize    = materialTapTargetSize ?? MaterialTapTargetSize.padded;
            this.pageTransitionsTheme     = pageTransitionsTheme;
            this.colorScheme              = colorScheme;
            this.typography               = typography;
        }
        public override Widget build(BuildContext context)
        {
            ThemeData             theme         = Theme.of(context);
            ColorScheme           colorScheme   = theme.colorScheme;
            MaterialLocalizations localizations = MaterialLocalizations.of(context);
            Orientation?          orientation   = MediaQuery.of(context).orientation;
            TextTheme             textTheme     = theme.textTheme;

            float textScaleFactor = Mathf.Min(MediaQuery.of(context).textScaleFactor, 1.3f);

            string dateText = _selectedDate != null
                ? localizations.formatMediumDate(_selectedDate)
                : "Date";

            Color dateColor = colorScheme.brightness == Brightness.light
                ? colorScheme.onPrimary
                : colorScheme.onSurface;
            TextStyle dateStyle = orientation == Orientation.landscape
                ? textTheme.headline5?.copyWith(color: dateColor)
                : textTheme.headline4?.copyWith(color: dateColor);

            Widget actions = new ButtonBar(
                buttonTextTheme: ButtonTextTheme.primary,
                layoutBehavior: ButtonBarLayoutBehavior.constrained,
                children: new List <Widget> {
                new FlatButton(
                    child: new Text(widget.cancelText ?? localizations.cancelButtonLabel),
                    onPressed: _handleCancel
                    ),
                new FlatButton(
                    child: new Text(widget.confirmText ?? localizations.okButtonLabel),
                    onPressed: _handleOk
                    ),
            }
                );

            Widget   picker           = null;
            IconData entryModeIcon    = null;
            string   entryModeTooltip = null;

            switch (_entryMode)
            {
            case DatePickerEntryMode.calendar:
                picker = new CalendarDatePicker(
                    key: _calendarPickerKey,
                    initialDate: _selectedDate,
                    firstDate: widget.firstDate,
                    lastDate: widget.lastDate,
                    onDateChanged: _handleDateChanged,
                    selectableDayPredicate: widget.selectableDayPredicate,
                    initialCalendarMode: widget.initialCalendarMode
                    );
                entryModeIcon    = Icons.edit;
                entryModeTooltip = "Switch to input";
                break;

            case DatePickerEntryMode.input:
                picker = new Form(
                    key: _formKey,
                    autovalidate: _autoValidate,
                    child: new InputDatePickerFormField(
                        initialDate: _selectedDate,
                        firstDate: widget.firstDate,
                        lastDate: widget.lastDate,
                        onDateSubmitted: _handleDateChanged,
                        onDateSaved: _handleDateChanged,
                        selectableDayPredicate: widget.selectableDayPredicate,
                        errorFormatText: widget.errorFormatText,
                        errorInvalidText: widget.errorInvalidText,
                        fieldHintText: widget.fieldHintText,
                        fieldLabelText: widget.fieldLabelText,
                        autofocus: true
                        )
                    );
                entryModeIcon    = Icons.calendar_today;
                entryModeTooltip = "Switch to calendar";
                break;
            }

            Widget header = new DatePickerHeader(
                helpText: widget.helpText ?? "SELECT DATE",
                titleText: dateText,
                titleStyle: dateStyle,
                orientation: orientation,
                isShort: orientation == Orientation.landscape,
                icon: entryModeIcon,
                iconTooltip: entryModeTooltip,
                onIconPressed: _handelEntryModeToggle
                );

            Size        dialogSize  = _dialogSize(context) * textScaleFactor;
            DialogTheme dialogTheme = Theme.of(context).dialogTheme;

            return(new Dialog(
                       child: new AnimatedContainer(
                           width: dialogSize.width,
                           height: dialogSize.height,
                           duration: material_._dialogSizeAnimationDuration,
                           curve: Curves.easeIn,
                           child: new MediaQuery(
                               data: MediaQuery.of(context).copyWith(
                                   textScaleFactor: textScaleFactor
                                   ),
                               child: new Builder(builder: (BuildContext subContext) => {
                switch (orientation)
                {
                case Orientation.portrait:
                    return new Column(
                        mainAxisSize: MainAxisSize.min,
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: new List <Widget> {
                        header,
                        new Expanded(child: picker),
                        actions,
                    }
                        );

                case Orientation.landscape:
                    return new Row(
                        mainAxisSize: MainAxisSize.min,
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: new List <Widget> {
                        header,
                        new Flexible(
                            child: new Column(
                                mainAxisSize: MainAxisSize.min,
                                crossAxisAlignment: CrossAxisAlignment.stretch,
                                children: new List <Widget> {
                            new Expanded(child: picker),
                            actions,
                        }
                                )
                            ),
                    }
                        );
                }

                return null;
            })
                               )
                           ),
                       insetPadding: EdgeInsets.symmetric(horizontal: 16.0f, vertical: 24.0f),
                       shape: dialogTheme.shape ?? new RoundedRectangleBorder(
                           borderRadius: BorderRadius.all(Radius.circular(4.0f))
                           ),
                       clipBehavior: Clip.antiAlias
                       ));
        }
Exemplo n.º 22
0
        public override Widget build(BuildContext context)
        {
            ThemeData   theme       = Theme.of(context);
            ColorScheme colorScheme = theme.colorScheme;
            TextTheme   textTheme   = theme.textTheme;

            bool  isDark = colorScheme.brightness == Brightness.dark;
            Color primarySurfaceColor   = isDark ? colorScheme.surface : colorScheme.primary;
            Color onPrimarySurfaceColor = isDark ? colorScheme.onSurface : colorScheme.onPrimary;

            TextStyle helpStyle = textTheme.overline?.copyWith(
                color: onPrimarySurfaceColor
                );

            Text help = new Text(
                helpText,
                style: helpStyle,
                maxLines: 1,
                overflow: TextOverflow.ellipsis
                );

            Text title = new Text(
                titleText,
                style: titleStyle,
                maxLines: (isShort || orientation == Orientation.portrait) ? 1 : 2,
                overflow: TextOverflow.ellipsis
                );
            IconButton icon = new IconButton(
                icon: new Icon(this.icon),
                color: onPrimarySurfaceColor,
                tooltip: iconTooltip,
                onPressed: onIconPressed
                );

            switch (orientation)
            {
            case Orientation.portrait:
                return(new Column(
                           crossAxisAlignment: CrossAxisAlignment.start,
                           children: new List <Widget> {
                    new Container(
                        height: DatePickerHeaderUtils._datePickerHeaderPortraitHeight,
                        color: primarySurfaceColor,
                        padding: EdgeInsetsDirectional.only(
                            start: 24f,
                            end: 12f
                            ),
                        child: new Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget> {
                        new SizedBox(height: 16f),
                        new Flexible(child: help),
                        new SizedBox(height: 38),
                        new Row(
                            children: new List <Widget> {
                            new Expanded(child: title),
                            icon,
                        }
                            ),
                    }
                            )
                        )
                }
                           ));

            case Orientation.landscape:
                return(new Row(
                           crossAxisAlignment: CrossAxisAlignment.start,
                           children: new List <Widget> {
                    new Container(
                        width: DatePickerHeaderUtils._datePickerHeaderLandscapeWidth,
                        color: primarySurfaceColor,
                        child: new Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget> {
                        new SizedBox(height: 16),
                        new Padding(
                            padding: EdgeInsets.symmetric(
                                horizontal: DatePickerHeaderUtils._headerPaddingLandscape
                                ),
                            child: help
                            ),
                        new SizedBox(height: isShort ? 16 : 56),
                        new Padding(
                            padding: EdgeInsets.symmetric(
                                horizontal: DatePickerHeaderUtils._headerPaddingLandscape
                                ),
                            child: title
                            ),
                        new Spacer(),
                        new Padding(
                            padding: EdgeInsets.symmetric(
                                horizontal: 4
                                ),
                            child: icon
                            ),
                    }
                            )
                        ),
                }
                           ));
            }

            return(null);
        }
Exemplo n.º 23
0
        Widget _buildYearItem(BuildContext context, int index)
        {
            ColorScheme colorScheme = Theme.of(context).colorScheme;
            TextTheme   textTheme   = Theme.of(context).textTheme;

            // Backfill the _YearPicker with disabled years if necessary.
            int         offset = _itemCount < minYears ? (int)(1.0f * (minYears - _itemCount) / 2) : 0;
            int         year = widget.firstDate.Year + index - offset;
            bool        isSelected = year == widget.selectedDate.Year;
            bool        isCurrentYear = year == widget.currentDate.Year;
            bool        isDisabled = year <widget.firstDate.Year || year> widget.lastDate.Year;
            const float decorationHeight = 36.0f;
            const float decorationWidth  = 72.0f;

            Color textColor;

            if (isSelected)
            {
                textColor = colorScheme.onPrimary;
            }
            else if (isDisabled)
            {
                textColor = colorScheme.onSurface.withOpacity(0.38f);
            }
            else if (isCurrentYear)
            {
                textColor = colorScheme.primary;
            }
            else
            {
                textColor = colorScheme.onSurface.withOpacity(0.87f);
            }

            TextStyle itemStyle = textTheme.bodyText1?.apply(color: textColor);

            BoxDecoration decoration = null;

            if (isSelected)
            {
                decoration = new BoxDecoration(
                    color: colorScheme.primary,
                    borderRadius: BorderRadius.circular(decorationHeight / 2),
                    shape: BoxShape.rectangle
                    );
            }
            else if (isCurrentYear && !isDisabled)
            {
                decoration = new BoxDecoration(
                    border: Border.all(
                        color: colorScheme.primary,
                        width: 1
                        ),
                    borderRadius: BorderRadius.circular(decorationHeight / 2),
                    shape: BoxShape.rectangle
                    );
            }

            Widget yearItem = new Center(
                child: new Container(
                    decoration: decoration,
                    height: decorationHeight,
                    width: decorationWidth,
                    child: new Center(
                        child: new Text(year.ToString(), style: itemStyle)
                        )
                    )
                );

            if (!isDisabled)
            {
                yearItem = new InkWell(
                    key: new ValueKey <int>(year),
                    onTap: () => {
                    widget.onChanged(
                        new DateTime(
                            year,
                            widget.initialDate.Month,
                            widget.initialDate.Day
                            )
                        );
                },
                    child: yearItem
                    );
            }

            return(yearItem);
        }
Exemplo n.º 24
0
        public override Widget build(BuildContext context)
        {
            ColorScheme           colorScheme   = Theme.of(context).colorScheme;
            MaterialLocalizations localizations = MaterialLocalizations.of(context);
            TextTheme             textTheme     = Theme.of(context).textTheme;
            TextStyle             dayStyle      = textTheme.caption;
            Color enabledDayColor       = colorScheme.onSurface.withOpacity(0.87f);
            Color disabledDayColor      = colorScheme.onSurface.withOpacity(0.38f);
            Color selectedDayColor      = colorScheme.onPrimary;
            Color selectedDayBackground = colorScheme.primary;
            Color todayColor            = colorScheme.primary;

            int year  = displayedMonth.Year;
            int month = displayedMonth.Month;

            int daysInMonth = utils.getDaysInMonth(year, month);
            int dayOffset   = utils.firstDayOffset(year, month, localizations);

            List <Widget> dayItems = new List <Widget>();
            // 1-based day of month, e.g. 1-31 for January, and 1-29 for February on
            // a leap year.
            int day = -dayOffset;

            while (day < daysInMonth)
            {
                day++;
                if (day < 1)
                {
                    dayItems.Add(new Container());
                }
                else
                {
                    DateTime dayToBuild = new DateTime(year, month, day);
                    bool     isDisabled = dayToBuild > lastDate ||
                                          dayToBuild < firstDate ||
                                          (selectableDayPredicate != null && !selectableDayPredicate(dayToBuild));

                    BoxDecoration decoration    = null;
                    Color         dayColor      = enabledDayColor;
                    bool          isSelectedDay = utils.isSameDay(selectedDate, dayToBuild);
                    if (isSelectedDay)
                    {
                        // The selected day gets a circle background highlight, and a
                        // contrasting text color.
                        dayColor   = selectedDayColor;
                        decoration = new BoxDecoration(
                            color: selectedDayBackground,
                            shape: BoxShape.circle
                            );
                    }
                    else if (isDisabled)
                    {
                        dayColor = disabledDayColor;
                    }
                    else if (utils.isSameDay(currentDate, dayToBuild))
                    {
                        // The current day gets a different text color and a circle stroke
                        // border.
                        dayColor   = todayColor;
                        decoration = new BoxDecoration(
                            border: Border.all(color: todayColor, width: 1),
                            shape: BoxShape.circle
                            );
                    }

                    Widget dayWidget = new Container(
                        decoration: decoration,
                        child: new Center(
                            child: new Text(localizations.formatDecimal(day), style: dayStyle.apply(color: dayColor))
                            )
                        );

                    if (!isDisabled)
                    {
                        dayWidget = new GestureDetector(
                            behavior: HitTestBehavior.opaque,
                            onTap: () => onChanged(dayToBuild),
                            child: dayWidget
                            );
                    }

                    dayItems.Add(dayWidget);
                }
            }

            return(new Padding(
                       padding: EdgeInsets.symmetric(
                           horizontal: material_._monthPickerHorizontalPadding
                           ),
                       child: GridView.custom(
                           physics: new ClampingScrollPhysics(),
                           gridDelegate: material_._dayPickerGridDelegate,
                           childrenDelegate: new SliverChildListDelegate(
                               dayItems,
                               addRepaintBoundaries: false
                               )
                           )
                       ));
        }
Exemplo n.º 25
0
 public ThemeData copyWith(
     Brightness?brightness,
     Color primaryColor,
     Brightness?primaryColorBrightness,
     Color primaryColorLight,
     Color primaryColorDark,
     Color accentColor,
     Brightness?accentColorBrightness,
     Color canvasColor,
     Color scaffoldBackgroundColor,
     Color bottomAppBarColor,
     Color cardColor,
     Color dividerColor,
     Color highlightColor,
     Color splashColor,
     InteractiveInkFeatureFactory splashFactory,
     Color selectedRowColor,
     Color unselectedWidgetColor,
     Color disabledColor,
     ButtonThemeData buttonTheme,
     Color buttonColor,
     Color secondaryHeaderColor,
     Color textSelectionColor,
     Color cursorColor,
     Color textSelectionHandleColor,
     Color backgroundColor,
     Color dialogBackgroundColor,
     Color indicatorColor,
     Color hintColor,
     Color errorColor,
     Color toggleableActiveColor,
     TextTheme textTheme,
     TextTheme primaryTextTheme,
     TextTheme accentTextTheme,
     IconThemeData iconTheme,
     IconThemeData primaryIconTheme,
     IconThemeData accentIconTheme,
     MaterialTapTargetSize?materialTapTargetSize,
     PageTransitionsTheme pageTransitionsTheme,
     ColorScheme colorScheme,
     Typography typography
     )
 {
     return(raw(
                brightness: brightness ?? this.brightness,
                primaryColor: primaryColor ?? this.primaryColor,
                primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness,
                primaryColorLight: primaryColorLight ?? this.primaryColorLight,
                primaryColorDark: primaryColorDark ?? this.primaryColorDark,
                accentColor: accentColor ?? this.accentColor,
                accentColorBrightness: accentColorBrightness ?? this.accentColorBrightness,
                canvasColor: canvasColor ?? this.canvasColor,
                scaffoldBackgroundColor: scaffoldBackgroundColor ?? this.scaffoldBackgroundColor,
                bottomAppBarColor: bottomAppBarColor ?? this.bottomAppBarColor,
                cardColor: cardColor ?? this.cardColor,
                dividerColor: dividerColor ?? this.dividerColor,
                highlightColor: highlightColor ?? this.highlightColor,
                splashColor: splashColor ?? this.splashColor,
                splashFactory: splashFactory ?? this.splashFactory,
                selectedRowColor: selectedRowColor ?? this.selectedRowColor,
                unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor,
                disabledColor: disabledColor ?? this.disabledColor,
                buttonTheme: buttonTheme ?? this.buttonTheme,
                buttonColor: buttonColor ?? this.buttonColor,
                secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor,
                textSelectionColor: textSelectionColor ?? this.textSelectionColor,
                cursorColor: cursorColor ?? this.cursorColor,
                textSelectionHandleColor: textSelectionHandleColor ?? this.textSelectionHandleColor,
                backgroundColor: backgroundColor ?? this.backgroundColor,
                dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor,
                indicatorColor: indicatorColor ?? this.indicatorColor,
                hintColor: hintColor ?? this.hintColor,
                errorColor: errorColor ?? this.errorColor,
                toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor,
                textTheme: textTheme ?? this.textTheme,
                primaryTextTheme: primaryTextTheme ?? this.primaryTextTheme,
                accentTextTheme: accentTextTheme ?? this.accentTextTheme,
                iconTheme: iconTheme ?? this.iconTheme,
                primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
                accentIconTheme: accentIconTheme ?? this.accentIconTheme,
                materialTapTargetSize: materialTapTargetSize ?? this.materialTapTargetSize,
                pageTransitionsTheme: pageTransitionsTheme ?? this.pageTransitionsTheme,
                colorScheme: colorScheme ?? this.colorScheme,
                typography: typography ?? this.typography
                ));
 }
Exemplo n.º 26
0
        List <Widget> _createTiles()
        {
            MaterialLocalizations localizations = MaterialLocalizations.of(this.context);

            D.assert(localizations != null);
            List <Widget> children = new List <Widget> {
            };

            switch (this.widget.type)
            {
            case BottomNavigationBarType.fix:
                ThemeData themeData = Theme.of(this.context);
                TextTheme textTheme = themeData.textTheme;
                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 = new ColorTween(
                    begin: textTheme.caption.color,
                    end: this.widget.fixedColor ?? themeColor
                    );
                for (int i = 0; i < this.widget.items.Count; i += 1)
                {
                    int index = i;
                    children.Add(
                        new _BottomNavigationTile(this.widget.type, this.widget.items[i], this._animations[i],
                                                  this.widget.iconSize,
                                                  onTap: () => {
                        if (this.widget.onTap != null)
                        {
                            this.widget.onTap(index);
                        }
                    },
                                                  colorTween: colorTween,
                                                  selected: i == this.widget.currentIndex,
                                                  indexLabel: localizations.tabLabel(tabIndex: i + 1,
                                                                                     tabCount: this.widget.items.Count)
                                                  )
                        );
                }

                break;

            case BottomNavigationBarType.shifting:
                for (int i = 0; i < this.widget.items.Count; i += 1)
                {
                    int index = i;
                    children.Add(
                        new _BottomNavigationTile(this.widget.type, this.widget.items[i], this._animations[i],
                                                  this.widget.iconSize,
                                                  onTap: () => {
                        if (this.widget.onTap != null)
                        {
                            this.widget.onTap(index);
                        }
                    },
                                                  flex:
                                                  this._evaluateFlex(this._animations[i]),
                                                  selected: i == this.widget.currentIndex,
                                                  indexLabel: localizations.tabLabel(tabIndex: i + 1,
                                                                                     tabCount: this.widget.items.Count)
                                                  )
                        );
                }

                break;
            }

            return(children);
        }
Exemplo n.º 27
0
        public override Widget build(BuildContext context)
        {
            MaterialLocalizations localizations   = MaterialLocalizations.of(context);
            ThemeData             themeData       = Theme.of(context);
            TextTheme             headerTextTheme = themeData.primaryTextTheme;
            Color dayColor  = null;
            Color yearColor = null;

            switch (themeData.primaryColorBrightness)
            {
            case Brightness.light:
                dayColor  = this.mode == DatePickerMode.day ? Colors.black87 : Colors.black54;
                yearColor = this.mode == DatePickerMode.year ? Colors.black87 : Colors.black54;
                break;

            case Brightness.dark:
                dayColor  = this.mode == DatePickerMode.day ? Colors.white : Colors.white70;
                yearColor = this.mode == DatePickerMode.year ? Colors.white : Colors.white70;
                break;
            }

            TextStyle dayStyle        = headerTextTheme.display1.copyWith(color: dayColor, height: 1.4f);
            TextStyle yearStyle       = headerTextTheme.subhead.copyWith(color: yearColor, height: 1.4f);
            Color     backgroundColor = null;

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

            case Brightness.dark:
                backgroundColor = themeData.backgroundColor;
                break;
            }

            float             width             = 0f;
            float             height            = 0f;
            EdgeInsets        padding           = null;
            MainAxisAlignment mainAxisAlignment = MainAxisAlignment.center;

            switch (this.orientation)
            {
            case Orientation.portrait:
                height            = DatePickerUtils._kDatePickerHeaderPortraitHeight;
                padding           = EdgeInsets.symmetric(horizontal: 16.0f);
                mainAxisAlignment = MainAxisAlignment.center;
                break;

            case Orientation.landscape:
                width             = DatePickerUtils._kDatePickerHeaderLandscapeWidth;
                padding           = EdgeInsets.all(8.0f);
                mainAxisAlignment = MainAxisAlignment.start;
                break;
            }

            Widget yearButton = new IgnorePointer(
                ignoring: this.mode != DatePickerMode.day,
                child: new _DateHeaderButton(
                    color: backgroundColor,
                    onTap: Feedback.wrapForTap(() => this._handleChangeMode(DatePickerMode.year), context),
                    child: new Text(localizations.formatYear(this.selectedDate), style: yearStyle)
                    )
                );
            Widget dayButton = new IgnorePointer(
                ignoring: this.mode == DatePickerMode.day,
                child: new _DateHeaderButton(
                    color: backgroundColor,
                    onTap: Feedback.wrapForTap(() => this._handleChangeMode(DatePickerMode.day), context),
                    child: new Text(localizations.formatMediumDate(this.selectedDate), style: dayStyle)
                    )
                );

            return(new Container(
                       width: width,
                       height: height,
                       padding: padding,
                       color: backgroundColor,
                       child: new Column(
                           mainAxisAlignment: mainAxisAlignment,
                           crossAxisAlignment: CrossAxisAlignment.start,
                           children: new List <Widget> {
                yearButton, dayButton
            }
                           )
                       ));
        }
Exemplo n.º 28
0
        public static ThemeData raw(
            Brightness?brightness,
            Color primaryColor,
            Brightness?primaryColorBrightness,
            Color primaryColorLight,
            Color primaryColorDark,
            Color canvasColor,
            Color accentColor,
            Brightness?accentColorBrightness,
            Color scaffoldBackgroundColor,
            Color bottomAppBarColor,
            Color cardColor,
            Color dividerColor,
            Color highlightColor,
            Color splashColor,
            InteractiveInkFeatureFactory splashFactory,
            Color selectedRowColor,
            Color unselectedWidgetColor,
            Color disabledColor,
            ButtonThemeData buttonTheme,
            Color buttonColor,
            Color secondaryHeaderColor,
            Color textSelectionColor,
            Color cursorColor,
            Color textSelectionHandleColor,
            Color backgroundColor,
            Color dialogBackgroundColor,
            Color indicatorColor,
            Color hintColor,
            Color errorColor,
            Color toggleableActiveColor,
            TextTheme textTheme,
            TextTheme primaryTextTheme,
            TextTheme accentTextTheme,
            IconThemeData iconTheme,
            IconThemeData primaryIconTheme,
            IconThemeData accentIconTheme,
            MaterialTapTargetSize?materialTapTargetSize,
            PageTransitionsTheme pageTransitionsTheme,
            ColorScheme colorScheme,
            Typography typography
            )
        {
            D.assert(brightness != null);
            D.assert(primaryColor != null);
            D.assert(primaryColorBrightness != null);
            D.assert(primaryColorLight != null);
            D.assert(primaryColorDark != null);
            D.assert(accentColor != null);
            D.assert(accentColorBrightness != null);
            D.assert(canvasColor != null);
            D.assert(scaffoldBackgroundColor != null);
            D.assert(bottomAppBarColor != null);
            D.assert(cardColor != null);
            D.assert(dividerColor != null);
            D.assert(highlightColor != null);
            D.assert(splashColor != null);
            D.assert(splashFactory != null);
            D.assert(selectedRowColor != null);
            D.assert(unselectedWidgetColor != null);
            D.assert(disabledColor != null);
            D.assert(toggleableActiveColor != null);
            D.assert(buttonTheme != null);
            D.assert(secondaryHeaderColor != null);
            D.assert(textSelectionColor != null);
            D.assert(cursorColor != null);
            D.assert(textSelectionHandleColor != null);
            D.assert(backgroundColor != null);
            D.assert(dialogBackgroundColor != null);
            D.assert(indicatorColor != null);
            D.assert(hintColor != null);
            D.assert(errorColor != null);
            D.assert(textTheme != null);
            D.assert(primaryTextTheme != null);
            D.assert(accentTextTheme != null);
            D.assert(iconTheme != null);
            D.assert(primaryIconTheme != null);
            D.assert(accentIconTheme != null);
            D.assert(materialTapTargetSize != null);
            D.assert(pageTransitionsTheme != null);
            D.assert(colorScheme != null);
            D.assert(typography != null);

            D.assert(buttonColor != null);

            return(new ThemeData(
                       brightness: brightness,
                       primaryColor: primaryColor,
                       primaryColorBrightness: primaryColorBrightness,
                       primaryColorLight: primaryColorLight,
                       primaryColorDark: primaryColorDark,
                       accentColor: accentColor,
                       accentColorBrightness: accentColorBrightness,
                       canvasColor: canvasColor,
                       scaffoldBackgroundColor: scaffoldBackgroundColor,
                       bottomAppBarColor: bottomAppBarColor,
                       cardColor: cardColor,
                       dividerColor: dividerColor,
                       highlightColor: highlightColor,
                       splashColor: splashColor,
                       splashFactory: splashFactory,
                       selectedRowColor: selectedRowColor,
                       unselectedWidgetColor: unselectedWidgetColor,
                       disabledColor: disabledColor,
                       buttonTheme: buttonTheme,
                       buttonColor: buttonColor,
                       toggleableActiveColor: toggleableActiveColor,
                       secondaryHeaderColor: secondaryHeaderColor,
                       textSelectionColor: textSelectionColor,
                       cursorColor: cursorColor,
                       textSelectionHandleColor: textSelectionHandleColor,
                       backgroundColor: backgroundColor,
                       dialogBackgroundColor: dialogBackgroundColor,
                       indicatorColor: indicatorColor,
                       hintColor: hintColor,
                       errorColor: errorColor,
                       textTheme: textTheme,
                       primaryTextTheme: primaryTextTheme,
                       accentTextTheme: accentTextTheme,
                       iconTheme: iconTheme,
                       primaryIconTheme: primaryIconTheme,
                       accentIconTheme: accentIconTheme,
                       materialTapTargetSize: materialTapTargetSize,
                       pageTransitionsTheme: pageTransitionsTheme,
                       colorScheme: colorScheme,
                       typography: typography));
        }