Unverified Commit 525365db authored by Hans Muller's avatar Hans Muller Committed by GitHub

Revert "Added AppBar.textButtonTheme (#85585)" (#85714)

parent 7a739151
......@@ -22,8 +22,6 @@ import 'material_localizations.dart';
import 'material_state.dart';
import 'scaffold.dart';
import 'tabs.dart';
import 'text_button.dart';
import 'text_button_theme.dart';
import 'text_theme.dart';
import 'theme.dart';
......@@ -195,7 +193,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
this.iconTheme,
this.actionsIconTheme,
this.textTheme,
this.textButtonTheme,
this.primary = true,
this.centerTitle,
this.excludeHeaderSemantics = false,
......@@ -521,8 +518,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
///
/// * [actionsIconTheme], which defines the appearance of icons in
/// in the [actions] list.
/// * [textButtonTheme], which defines the appearance of [TextButton]s
/// in the tool bar.
final IconThemeData? iconTheme;
/// {@template flutter.material.appbar.actionsIconTheme}
......@@ -553,25 +548,6 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
/// {@endtemplate}
final TextTheme? textTheme;
/// {@template flutter.material.appbar.textButtonTheme}
/// Defines the [ButtonStyle] applied to [TextButton]s that
/// appear in the in the app bar's toolbar.
///
/// If this property is null, then a [ButtonStyle] configured with
/// [foregroundColor] is used. This is useful because the default
/// [ButtonStyle.foregroundColor] is [ColorScheme.primary], which
/// is the same as the default value for the app bar's [backgroundColor].
///
/// This property is null by default.
///
/// See also:
///
/// * [actionsIconTheme], which defines the appearance of icons in
/// in the [actions] list.
/// * [iconTheme], which defines the appearance of all of the toolbar icons.
/// {@endtemplate}
final TextButtonThemeData? textButtonTheme;
/// {@template flutter.material.appbar.primary}
/// Whether this app bar is being displayed at the top of the screen.
///
......@@ -853,10 +829,6 @@ class _AppBarState extends State<AppBar> {
?? appBarTheme.iconTheme
?? theme.iconTheme.copyWith(color: foregroundColor);
final TextButtonThemeData textButtonTheme = widget.textButtonTheme
?? appBarTheme.textButtonTheme
?? TextButtonThemeData(style: TextButton.styleFrom(primary: foregroundColor));
IconThemeData actionsIconTheme = widget.actionsIconTheme
?? appBarTheme.actionsIconTheme
?? overallIconTheme;
......@@ -1001,10 +973,7 @@ class _AppBarState extends State<AppBar> {
data: overallIconTheme,
child: DefaultTextStyle(
style: toolbarTextStyle!,
child: TextButtonTheme(
data: textButtonTheme,
child: toolbar,
),
child: toolbar,
),
),
),
......@@ -1117,7 +1086,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
required this.iconTheme,
required this.actionsIconTheme,
required this.textTheme,
required this.textButtonTheme,
required this.primary,
required this.centerTitle,
required this.excludeHeaderSemantics,
......@@ -1160,7 +1128,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
final IconThemeData? iconTheme;
final IconThemeData? actionsIconTheme;
final TextTheme? textTheme;
final TextButtonThemeData? textButtonTheme;
final bool primary;
final bool? centerTitle;
final bool excludeHeaderSemantics;
......@@ -1235,7 +1202,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
iconTheme: iconTheme,
actionsIconTheme: actionsIconTheme,
textTheme: textTheme,
textButtonTheme: textButtonTheme,
primary: primary,
centerTitle: centerTitle,
excludeHeaderSemantics: excludeHeaderSemantics,
......@@ -1271,7 +1237,6 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|| iconTheme != oldDelegate.iconTheme
|| actionsIconTheme != oldDelegate.actionsIconTheme
|| textTheme != oldDelegate.textTheme
|| textButtonTheme != oldDelegate.textButtonTheme
|| primary != oldDelegate.primary
|| centerTitle != oldDelegate.centerTitle
|| titleSpacing != oldDelegate.titleSpacing
......@@ -1508,7 +1473,6 @@ class SliverAppBar extends StatefulWidget {
this.iconTheme,
this.actionsIconTheme,
this.textTheme,
this.textButtonTheme,
this.primary = true,
this.centerTitle,
this.excludeHeaderSemantics = false,
......@@ -1622,11 +1586,6 @@ class SliverAppBar extends StatefulWidget {
/// This property is used to configure an [AppBar].
final TextTheme? textTheme;
/// {@macro flutter.material.appbar.textButtonTheme}
///
/// This property is used to configure an [AppBar].
final TextButtonThemeData? textButtonTheme;
/// {@macro flutter.material.appbar.primary}
///
/// This property is used to configure an [AppBar].
......@@ -1883,7 +1842,6 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
iconTheme: widget.iconTheme,
actionsIconTheme: widget.actionsIconTheme,
textTheme: widget.textTheme,
textButtonTheme: widget.textButtonTheme,
primary: widget.primary,
centerTitle: widget.centerTitle,
excludeHeaderSemantics: widget.excludeHeaderSemantics,
......
......@@ -8,7 +8,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'text_button_theme.dart';
import 'text_theme.dart';
import 'theme.dart';
......@@ -38,7 +37,6 @@ class AppBarTheme with Diagnosticable {
this.iconTheme,
this.actionsIconTheme,
this.textTheme,
this.textButtonTheme,
this.centerTitle,
this.titleSpacing,
this.toolbarHeight,
......@@ -137,17 +135,6 @@ class AppBarTheme with Diagnosticable {
/// [AppBar.titleTextStyle in all descendant [AppBar] widgets.
final TextTheme? textTheme;
/// Overrides the default value of the [AppBar.textButtonTheme]
/// property in all descendant [AppBar] widgets.
///
/// See also:
///
/// * [actionsIconTheme], which overrides the default value for
/// [AppBar.actionsIconTheme] in all descendant [AppBar] widgets.
/// * [foregroundColor], which overrides the default value
/// [AppBar.foregroundColor] in all descendant widgets.
final TextButtonThemeData? textButtonTheme;
/// Overrides the default value for [AppBar.centerTitle].
/// property in all descendant widgets.
final bool? centerTitle;
......@@ -209,7 +196,6 @@ class AppBarTheme with Diagnosticable {
Color? shadowColor,
IconThemeData? iconTheme,
TextTheme? textTheme,
TextButtonThemeData? textButtonTheme,
bool? centerTitle,
double? titleSpacing,
double? toolbarHeight,
......@@ -231,7 +217,6 @@ class AppBarTheme with Diagnosticable {
iconTheme: iconTheme ?? this.iconTheme,
actionsIconTheme: actionsIconTheme ?? this.actionsIconTheme,
textTheme: textTheme ?? this.textTheme,
textButtonTheme: textButtonTheme ?? this.textButtonTheme,
centerTitle: centerTitle ?? this.centerTitle,
titleSpacing: titleSpacing ?? this.titleSpacing,
toolbarHeight: toolbarHeight ?? this.toolbarHeight,
......@@ -263,7 +248,6 @@ class AppBarTheme with Diagnosticable {
iconTheme: IconThemeData.lerp(a?.iconTheme, b?.iconTheme, t),
actionsIconTheme: IconThemeData.lerp(a?.actionsIconTheme, b?.actionsIconTheme, t),
textTheme: TextTheme.lerp(a?.textTheme, b?.textTheme, t),
textButtonTheme: TextButtonThemeData.lerp(a?.textButtonTheme, b?.textButtonTheme, t),
centerTitle: t < 0.5 ? a?.centerTitle : b?.centerTitle,
titleSpacing: lerpDouble(a?.titleSpacing, b?.titleSpacing, t),
toolbarHeight: lerpDouble(a?.toolbarHeight, b?.toolbarHeight, t),
......@@ -285,7 +269,6 @@ class AppBarTheme with Diagnosticable {
iconTheme,
actionsIconTheme,
textTheme,
textButtonTheme,
centerTitle,
titleSpacing,
toolbarHeight,
......@@ -311,7 +294,6 @@ class AppBarTheme with Diagnosticable {
&& other.iconTheme == iconTheme
&& other.actionsIconTheme == actionsIconTheme
&& other.textTheme == textTheme
&& other.textButtonTheme == textButtonTheme
&& other.centerTitle == centerTitle
&& other.titleSpacing == titleSpacing
&& other.toolbarHeight == toolbarHeight
......@@ -332,7 +314,6 @@ class AppBarTheme with Diagnosticable {
properties.add(DiagnosticsProperty<IconThemeData>('iconTheme', iconTheme, defaultValue: null));
properties.add(DiagnosticsProperty<IconThemeData>('actionsIconTheme', actionsIconTheme, defaultValue: null));
properties.add(DiagnosticsProperty<TextTheme>('textTheme', textTheme, defaultValue: null));
properties.add(DiagnosticsProperty<TextButtonThemeData>('textButtonTheme', textButtonTheme, defaultValue: null));
properties.add(DiagnosticsProperty<bool>('centerTitle', centerTitle, defaultValue: null));
properties.add(DiagnosticsProperty<double>('titleSpacing', titleSpacing, defaultValue: null));
properties.add(DiagnosticsProperty<double>('toolbarHeight', toolbarHeight, defaultValue: null));
......
......@@ -20,10 +20,8 @@ void main() {
home: Scaffold(
appBar: AppBar(
backwardsCompatibility: false,
title: TextButton(onPressed: () { }, child: const Text('TitleButton')),
actions: <Widget>[
IconButton(onPressed: () { }, icon: const Icon(Icons.share)),
TextButton(onPressed: () { }, child: const Text('ActionButton')),
IconButton(icon: const Icon(Icons.share), onPressed: () { }),
],
),
),
......@@ -31,22 +29,18 @@ void main() {
);
final Material widget = _getAppBarMaterial(tester);
final RichText titleButtonText = _getAppBarButtonRichText(tester, 'TitleButton');
final IconTheme iconTheme = _getAppBarIconTheme(tester);
final IconTheme actionsIconTheme = _getAppBarActionsIconTheme(tester);
final RichText actionIconText = _getAppBarIconRichText(tester);
final RichText actionButtonText = _getAppBarButtonRichText(tester, 'ActionButton');
final DefaultTextStyle text = _getAppBarText(tester);
expect(SystemChrome.latestStyle!.statusBarBrightness, SystemUiOverlayStyle.light.statusBarBrightness);
expect(titleButtonText.text.style!.color, Colors.white);
expect(widget.color, Colors.blue);
expect(widget.elevation, 4.0);
expect(widget.shadowColor, Colors.black);
expect(iconTheme.data, const IconThemeData(color: Colors.white));
expect(actionsIconTheme.data, const IconThemeData(color: Colors.white));
expect(actionIconText.text.style!.color, Colors.white);
expect(actionButtonText.text.style!.color, Colors.white);
expect(text.style, Typography.material2014().englishLike.bodyText2!.merge(Typography.material2014().white.bodyText2));
expect(tester.getSize(find.byType(AppBar)).height, kToolbarHeight);
expect(tester.getSize(find.byType(AppBar)).width, 800);
......@@ -63,8 +57,7 @@ void main() {
backwardsCompatibility: false,
title: const Text('App Bar Title'),
actions: <Widget>[
IconButton(onPressed: () { }, icon: const Icon(Icons.share)),
TextButton(onPressed: () { }, child: const Text('ActionButton')),
IconButton(icon: const Icon(Icons.share), onPressed: () { }),
],
),
),
......@@ -75,7 +68,6 @@ void main() {
final IconTheme iconTheme = _getAppBarIconTheme(tester);
final IconTheme actionsIconTheme = _getAppBarActionsIconTheme(tester);
final RichText actionIconText = _getAppBarIconRichText(tester);
final RichText actionButtonText = _getAppBarButtonRichText(tester, 'ActionButton');
final DefaultTextStyle text = _getAppBarText(tester);
expect(SystemChrome.latestStyle!.statusBarBrightness, appBarTheme.brightness);
......@@ -85,7 +77,6 @@ void main() {
expect(iconTheme.data, appBarTheme.iconTheme);
expect(actionsIconTheme.data, appBarTheme.actionsIconTheme);
expect(actionIconText.text.style!.color, appBarTheme.actionsIconTheme!.color);
expect(actionButtonText.text.style!.color, Colors.pink);
expect(text.style, appBarTheme.toolbarTextStyle);
expect(tester.getSize(find.byType(AppBar)).height, appBarTheme.toolbarHeight);
expect(tester.getSize(find.byType(AppBar)).width, 800);
......@@ -144,7 +135,6 @@ void main() {
const Color shadowColor = Colors.red;
const IconThemeData iconThemeData = IconThemeData(color: Colors.green);
const IconThemeData actionsIconThemeData = IconThemeData(color: Colors.lightBlue);
const TextButtonThemeData textButtonTheme = TextButtonThemeData();
const TextStyle toolbarTextStyle = TextStyle(color: Colors.pink);
const TextStyle titleTextStyle = TextStyle(color: Colors.orange);
......@@ -161,7 +151,6 @@ void main() {
shadowColor: shadowColor,
iconTheme: iconThemeData,
actionsIconTheme: actionsIconThemeData,
textButtonTheme: textButtonTheme,
toolbarTextStyle: toolbarTextStyle,
titleTextStyle: titleTextStyle,
actions: <Widget>[
......@@ -186,7 +175,6 @@ void main() {
expect(actionsIconTheme.data, actionsIconThemeData);
expect(actionIconText.text.style!.color, actionsIconThemeData.color);
expect(text.style, toolbarTextStyle);
expect(_getAppBarTextButtonTheme(tester).data, textButtonTheme);
});
testWidgets('AppBar icon color takes priority over everything', (WidgetTester tester) async {
......@@ -548,22 +536,16 @@ AppBarTheme _appBarTheme() {
const Color shadowColor = Colors.red;
const IconThemeData iconThemeData = IconThemeData(color: Colors.black);
const IconThemeData actionsIconThemeData = IconThemeData(color: Colors.pink);
final TextButtonThemeData textButtonThemeData = TextButtonThemeData(
style: TextButton.styleFrom(
primary: Colors.pink,
),
);
return AppBarTheme(
return const AppBarTheme(
actionsIconTheme: actionsIconThemeData,
brightness: brightness,
backgroundColor: backgroundColor,
elevation: elevation,
shadowColor: shadowColor,
iconTheme: iconThemeData,
textButtonTheme: textButtonThemeData,
toolbarHeight: 96,
toolbarTextStyle: const TextStyle(color: Colors.yellow),
titleTextStyle: const TextStyle(color: Colors.pink),
toolbarTextStyle: TextStyle(color: Colors.yellow),
titleTextStyle: TextStyle(color: Colors.pink),
);
}
......@@ -572,7 +554,7 @@ Material _getAppBarMaterial(WidgetTester tester) {
find.descendant(
of: find.byType(AppBar),
matching: find.byType(Material),
).first,
),
);
}
......@@ -594,15 +576,6 @@ IconTheme _getAppBarActionsIconTheme(WidgetTester tester) {
);
}
TextButtonTheme _getAppBarTextButtonTheme(WidgetTester tester) {
return tester.widget<TextButtonTheme>(
find.descendant(
of: find.byType(AppBar),
matching: find.byType(TextButtonTheme),
).first,
);
}
RichText _getAppBarIconRichText(WidgetTester tester) {
return tester.widget<RichText>(
find.descendant(
......@@ -612,15 +585,6 @@ RichText _getAppBarIconRichText(WidgetTester tester) {
);
}
RichText _getAppBarButtonRichText(WidgetTester tester, String text) {
return tester.widget<RichText>(
find.descendant(
of: find.text(text),
matching: find.byType(RichText),
).first,
);
}
DefaultTextStyle _getAppBarText(WidgetTester tester) {
return tester.widget<DefaultTextStyle>(
find.descendant(
......
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