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'; ...@@ -114,6 +114,8 @@ export 'src/material/theme.dart';
export 'src/material/theme_data.dart'; export 'src/material/theme_data.dart';
export 'src/material/time.dart'; export 'src/material/time.dart';
export 'src/material/time_picker.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/toggleable.dart';
export 'src/material/tooltip.dart'; export 'src/material/tooltip.dart';
export 'src/material/tooltip_theme.dart'; export 'src/material/tooltip_theme.dart';
......
...@@ -27,6 +27,7 @@ import 'slider_theme.dart'; ...@@ -27,6 +27,7 @@ import 'slider_theme.dart';
import 'snack_bar_theme.dart'; import 'snack_bar_theme.dart';
import 'tab_bar_theme.dart'; import 'tab_bar_theme.dart';
import 'text_theme.dart'; import 'text_theme.dart';
import 'toggle_buttons_theme.dart';
import 'tooltip_theme.dart'; import 'tooltip_theme.dart';
import 'typography.dart'; import 'typography.dart';
...@@ -136,6 +137,7 @@ class ThemeData extends Diagnosticable { ...@@ -136,6 +137,7 @@ class ThemeData extends Diagnosticable {
Color disabledColor, Color disabledColor,
Color buttonColor, Color buttonColor,
ButtonThemeData buttonTheme, ButtonThemeData buttonTheme,
ToggleButtonsThemeData toggleButtonsTheme,
Color secondaryHeaderColor, Color secondaryHeaderColor,
Color textSelectionColor, Color textSelectionColor,
Color cursorColor, Color cursorColor,
...@@ -253,6 +255,7 @@ class ThemeData extends Diagnosticable { ...@@ -253,6 +255,7 @@ class ThemeData extends Diagnosticable {
splashColor: splashColor, splashColor: splashColor,
materialTapTargetSize: materialTapTargetSize, materialTapTargetSize: materialTapTargetSize,
); );
toggleButtonsTheme ??= const ToggleButtonsThemeData();
disabledColor ??= isDark ? Colors.white38 : Colors.black38; disabledColor ??= isDark ? Colors.white38 : Colors.black38;
highlightColor ??= isDark ? _kDarkThemeHighlightColor : _kLightThemeHighlightColor; highlightColor ??= isDark ? _kDarkThemeHighlightColor : _kLightThemeHighlightColor;
splashColor ??= isDark ? _kDarkThemeSplashColor : _kLightThemeSplashColor; splashColor ??= isDark ? _kDarkThemeSplashColor : _kLightThemeSplashColor;
...@@ -297,6 +300,7 @@ class ThemeData extends Diagnosticable { ...@@ -297,6 +300,7 @@ class ThemeData extends Diagnosticable {
disabledColor: disabledColor, disabledColor: disabledColor,
buttonTheme: buttonTheme, buttonTheme: buttonTheme,
buttonColor: buttonColor, buttonColor: buttonColor,
toggleButtonsTheme: toggleButtonsTheme,
toggleableActiveColor: toggleableActiveColor, toggleableActiveColor: toggleableActiveColor,
secondaryHeaderColor: secondaryHeaderColor, secondaryHeaderColor: secondaryHeaderColor,
textSelectionColor: textSelectionColor, textSelectionColor: textSelectionColor,
...@@ -368,6 +372,7 @@ class ThemeData extends Diagnosticable { ...@@ -368,6 +372,7 @@ class ThemeData extends Diagnosticable {
@required this.disabledColor, @required this.disabledColor,
@required this.buttonTheme, @required this.buttonTheme,
@required this.buttonColor, @required this.buttonColor,
@required this.toggleButtonsTheme,
@required this.secondaryHeaderColor, @required this.secondaryHeaderColor,
@required this.textSelectionColor, @required this.textSelectionColor,
@required this.cursorColor, @required this.cursorColor,
...@@ -425,6 +430,7 @@ class ThemeData extends Diagnosticable { ...@@ -425,6 +430,7 @@ class ThemeData extends Diagnosticable {
assert(disabledColor != null), assert(disabledColor != null),
assert(toggleableActiveColor != null), assert(toggleableActiveColor != null),
assert(buttonTheme != null), assert(buttonTheme != null),
assert(toggleButtonsTheme != null),
assert(secondaryHeaderColor != null), assert(secondaryHeaderColor != null),
assert(textSelectionColor != null), assert(textSelectionColor != null),
assert(cursorColor != null), assert(cursorColor != null),
...@@ -593,6 +599,9 @@ class ThemeData extends Diagnosticable { ...@@ -593,6 +599,9 @@ class ThemeData extends Diagnosticable {
/// and [FlatButton]. /// and [FlatButton].
final ButtonThemeData buttonTheme; final ButtonThemeData buttonTheme;
/// Defines the default configuration of [ToggleButtons] widgets.
final ToggleButtonsThemeData toggleButtonsTheme;
/// The default fill color of the [Material] used in [RaisedButton]s. /// The default fill color of the [Material] used in [RaisedButton]s.
final Color buttonColor; final Color buttonColor;
...@@ -802,6 +811,7 @@ class ThemeData extends Diagnosticable { ...@@ -802,6 +811,7 @@ class ThemeData extends Diagnosticable {
Color unselectedWidgetColor, Color unselectedWidgetColor,
Color disabledColor, Color disabledColor,
ButtonThemeData buttonTheme, ButtonThemeData buttonTheme,
ToggleButtonsTheme toggleButtonsTheme,
Color buttonColor, Color buttonColor,
Color secondaryHeaderColor, Color secondaryHeaderColor,
Color textSelectionColor, Color textSelectionColor,
...@@ -863,6 +873,7 @@ class ThemeData extends Diagnosticable { ...@@ -863,6 +873,7 @@ class ThemeData extends Diagnosticable {
disabledColor: disabledColor ?? this.disabledColor, disabledColor: disabledColor ?? this.disabledColor,
buttonColor: buttonColor ?? this.buttonColor, buttonColor: buttonColor ?? this.buttonColor,
buttonTheme: buttonTheme ?? this.buttonTheme, buttonTheme: buttonTheme ?? this.buttonTheme,
toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor, secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor,
textSelectionColor: textSelectionColor ?? this.textSelectionColor, textSelectionColor: textSelectionColor ?? this.textSelectionColor,
cursorColor: cursorColor ?? this.cursorColor, cursorColor: cursorColor ?? this.cursorColor,
...@@ -1000,6 +1011,7 @@ class ThemeData extends Diagnosticable { ...@@ -1000,6 +1011,7 @@ class ThemeData extends Diagnosticable {
unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t), unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t),
disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t), disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t),
buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme, buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme,
toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t),
buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t), buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t),
secondaryHeaderColor: Color.lerp(a.secondaryHeaderColor, b.secondaryHeaderColor, t), secondaryHeaderColor: Color.lerp(a.secondaryHeaderColor, b.secondaryHeaderColor, t),
textSelectionColor: Color.lerp(a.textSelectionColor, b.textSelectionColor, t), textSelectionColor: Color.lerp(a.textSelectionColor, b.textSelectionColor, t),
...@@ -1067,6 +1079,7 @@ class ThemeData extends Diagnosticable { ...@@ -1067,6 +1079,7 @@ class ThemeData extends Diagnosticable {
(otherData.disabledColor == disabledColor) && (otherData.disabledColor == disabledColor) &&
(otherData.buttonTheme == buttonTheme) && (otherData.buttonTheme == buttonTheme) &&
(otherData.buttonColor == buttonColor) && (otherData.buttonColor == buttonColor) &&
(otherData.toggleButtonsTheme == toggleButtonsTheme) &&
(otherData.secondaryHeaderColor == secondaryHeaderColor) && (otherData.secondaryHeaderColor == secondaryHeaderColor) &&
(otherData.textSelectionColor == textSelectionColor) && (otherData.textSelectionColor == textSelectionColor) &&
(otherData.cursorColor == cursorColor) && (otherData.cursorColor == cursorColor) &&
...@@ -1132,6 +1145,7 @@ class ThemeData extends Diagnosticable { ...@@ -1132,6 +1145,7 @@ class ThemeData extends Diagnosticable {
disabledColor, disabledColor,
buttonTheme, buttonTheme,
buttonColor, buttonColor,
toggleButtonsTheme,
toggleableActiveColor, toggleableActiveColor,
secondaryHeaderColor, secondaryHeaderColor,
textSelectionColor, textSelectionColor,
...@@ -1205,6 +1219,7 @@ class ThemeData extends Diagnosticable { ...@@ -1205,6 +1219,7 @@ class ThemeData extends Diagnosticable {
properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor)); properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor));
properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor)); properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor));
properties.add(DiagnosticsProperty<ButtonThemeData>('buttonTheme', buttonTheme)); properties.add(DiagnosticsProperty<ButtonThemeData>('buttonTheme', buttonTheme));
properties.add(DiagnosticsProperty<ToggleButtonsThemeData>('toggleButtonsTheme', toggleButtonsTheme));
properties.add(DiagnosticsProperty<TextTheme>('textTheme', textTheme)); properties.add(DiagnosticsProperty<TextTheme>('textTheme', textTheme));
properties.add(DiagnosticsProperty<TextTheme>('primaryTextTheme', primaryTextTheme)); properties.add(DiagnosticsProperty<TextTheme>('primaryTextTheme', primaryTextTheme));
properties.add(DiagnosticsProperty<TextTheme>('accentTextTheme', accentTextTheme)); 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