Unverified Commit 2e43b470 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

[Material] ToggleButtons (#34599)

* Introduces ToggleButtons widget

* Introduces ToggleButtonsTheme inherited widget

* Introduces ThemeData.toggleButtonsTheme property
parent f1e87c48
......@@ -114,6 +114,8 @@ export 'src/material/theme.dart';
export 'src/material/theme_data.dart';
export 'src/material/time.dart';
export 'src/material/time_picker.dart';
export 'src/material/toggle_buttons.dart';
export 'src/material/toggle_buttons_theme.dart';
export 'src/material/toggleable.dart';
export 'src/material/tooltip.dart';
export 'src/material/tooltip_theme.dart';
......
......@@ -27,6 +27,7 @@ import 'slider_theme.dart';
import 'snack_bar_theme.dart';
import 'tab_bar_theme.dart';
import 'text_theme.dart';
import 'toggle_buttons_theme.dart';
import 'tooltip_theme.dart';
import 'typography.dart';
......@@ -136,6 +137,7 @@ class ThemeData extends Diagnosticable {
Color disabledColor,
Color buttonColor,
ButtonThemeData buttonTheme,
ToggleButtonsThemeData toggleButtonsTheme,
Color secondaryHeaderColor,
Color textSelectionColor,
Color cursorColor,
......@@ -253,6 +255,7 @@ class ThemeData extends Diagnosticable {
splashColor: splashColor,
materialTapTargetSize: materialTapTargetSize,
);
toggleButtonsTheme ??= const ToggleButtonsThemeData();
disabledColor ??= isDark ? Colors.white38 : Colors.black38;
highlightColor ??= isDark ? _kDarkThemeHighlightColor : _kLightThemeHighlightColor;
splashColor ??= isDark ? _kDarkThemeSplashColor : _kLightThemeSplashColor;
......@@ -297,6 +300,7 @@ class ThemeData extends Diagnosticable {
disabledColor: disabledColor,
buttonTheme: buttonTheme,
buttonColor: buttonColor,
toggleButtonsTheme: toggleButtonsTheme,
toggleableActiveColor: toggleableActiveColor,
secondaryHeaderColor: secondaryHeaderColor,
textSelectionColor: textSelectionColor,
......@@ -368,6 +372,7 @@ class ThemeData extends Diagnosticable {
@required this.disabledColor,
@required this.buttonTheme,
@required this.buttonColor,
@required this.toggleButtonsTheme,
@required this.secondaryHeaderColor,
@required this.textSelectionColor,
@required this.cursorColor,
......@@ -425,6 +430,7 @@ class ThemeData extends Diagnosticable {
assert(disabledColor != null),
assert(toggleableActiveColor != null),
assert(buttonTheme != null),
assert(toggleButtonsTheme != null),
assert(secondaryHeaderColor != null),
assert(textSelectionColor != null),
assert(cursorColor != null),
......@@ -593,6 +599,9 @@ class ThemeData extends Diagnosticable {
/// and [FlatButton].
final ButtonThemeData buttonTheme;
/// Defines the default configuration of [ToggleButtons] widgets.
final ToggleButtonsThemeData toggleButtonsTheme;
/// The default fill color of the [Material] used in [RaisedButton]s.
final Color buttonColor;
......@@ -802,6 +811,7 @@ class ThemeData extends Diagnosticable {
Color unselectedWidgetColor,
Color disabledColor,
ButtonThemeData buttonTheme,
ToggleButtonsTheme toggleButtonsTheme,
Color buttonColor,
Color secondaryHeaderColor,
Color textSelectionColor,
......@@ -863,6 +873,7 @@ class ThemeData extends Diagnosticable {
disabledColor: disabledColor ?? this.disabledColor,
buttonColor: buttonColor ?? this.buttonColor,
buttonTheme: buttonTheme ?? this.buttonTheme,
toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor,
textSelectionColor: textSelectionColor ?? this.textSelectionColor,
cursorColor: cursorColor ?? this.cursorColor,
......@@ -1000,6 +1011,7 @@ class ThemeData extends Diagnosticable {
unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t),
disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t),
buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme,
toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t),
buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t),
secondaryHeaderColor: Color.lerp(a.secondaryHeaderColor, b.secondaryHeaderColor, t),
textSelectionColor: Color.lerp(a.textSelectionColor, b.textSelectionColor, t),
......@@ -1067,6 +1079,7 @@ class ThemeData extends Diagnosticable {
(otherData.disabledColor == disabledColor) &&
(otherData.buttonTheme == buttonTheme) &&
(otherData.buttonColor == buttonColor) &&
(otherData.toggleButtonsTheme == toggleButtonsTheme) &&
(otherData.secondaryHeaderColor == secondaryHeaderColor) &&
(otherData.textSelectionColor == textSelectionColor) &&
(otherData.cursorColor == cursorColor) &&
......@@ -1132,6 +1145,7 @@ class ThemeData extends Diagnosticable {
disabledColor,
buttonTheme,
buttonColor,
toggleButtonsTheme,
toggleableActiveColor,
secondaryHeaderColor,
textSelectionColor,
......@@ -1205,6 +1219,7 @@ class ThemeData extends Diagnosticable {
properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor));
properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor));
properties.add(DiagnosticsProperty<ButtonThemeData>('buttonTheme', buttonTheme));
properties.add(DiagnosticsProperty<ToggleButtonsThemeData>('toggleButtonsTheme', toggleButtonsTheme));
properties.add(DiagnosticsProperty<TextTheme>('textTheme', textTheme));
properties.add(DiagnosticsProperty<TextTheme>('primaryTextTheme', primaryTextTheme));
properties.add(DiagnosticsProperty<TextTheme>('accentTextTheme', accentTextTheme));
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment