Unverified Commit e1671628 authored by Qun Cheng's avatar Qun Cheng Committed by GitHub

Updated `ProgressIndicator` to M3 (#112139)

parent 71c21d60
......@@ -31,6 +31,7 @@ import 'package:gen_defaults/input_chip_template.dart';
import 'package:gen_defaults/input_decorator_template.dart';
import 'package:gen_defaults/navigation_bar_template.dart';
import 'package:gen_defaults/navigation_rail_template.dart';
import 'package:gen_defaults/progress_indicator_template.dart';
import 'package:gen_defaults/radio_template.dart';
import 'package:gen_defaults/surface_tint.dart';
import 'package:gen_defaults/switch_template.dart';
......@@ -80,6 +81,8 @@ Future<void> main(List<String> args) async {
'navigation_drawer.json',
'navigation_rail.json',
'palette.json',
'progress_indicator_circular.json',
'progress_indicator_linear.json',
'radio_button.json',
'segmented_button_outlined.json',
'shape.json',
......@@ -126,6 +129,7 @@ Future<void> main(List<String> args) async {
InputDecoratorTemplate('InputDecorator', '$materialLib/input_decorator.dart', tokens).updateFile();
NavigationBarTemplate('NavigationBar', '$materialLib/navigation_bar.dart', tokens).updateFile();
NavigationRailTemplate('NavigationRail', '$materialLib/navigation_rail.dart', tokens).updateFile();
ProgressIndicatorTemplate('ProgressIndicator', '$materialLib/progress_indicator.dart', tokens).updateFile();
RadioTemplate('Radio<T>', '$materialLib/radio.dart', tokens).updateFile();
SurfaceTintTemplate('SurfaceTint', '$materialLib/elevation_overlay.dart', tokens).updateFile();
SwitchTemplate('Switch', '$materialLib/switch.dart', tokens).updateFile();
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'template.dart';
class ProgressIndicatorTemplate extends TokenTemplate {
const ProgressIndicatorTemplate(super.blockName, super.fileName, super.tokens, {
super.colorSchemePrefix = '_colors.',
});
@override
String generate() => '''
class _Circular${blockName}DefaultsM3 extends ProgressIndicatorThemeData {
_Circular${blockName}DefaultsM3(this.context);
final BuildContext context;
late final ColorScheme _colors = Theme.of(context).colorScheme;
static const double circularProgressIndicatorSize = ${tokens['md.comp.circular-progress-indicator.size']};
@override
Color get color => ${componentColor('md.comp.circular-progress-indicator.active-indicator')};
}
class _Linear${blockName}DefaultsM3 extends ProgressIndicatorThemeData {
_Linear${blockName}DefaultsM3(this.context);
final BuildContext context;
late final ColorScheme _colors = Theme.of(context).colorScheme;
@override
Color get color => ${componentColor('md.comp.linear-progress-indicator.active-indicator')};
@override
Color get linearTrackColor => ${componentColor('md.comp.linear-progress-indicator.track')};
@override
double get linearMinHeight => ${tokens['md.comp.linear-progress-indicator.track.height']};
}
''';
}
......@@ -108,11 +108,11 @@ abstract class ProgressIndicator extends StatefulWidget {
/// {@endtemplate}
final String? semanticsValue;
Color _getValueColor(BuildContext context) {
return
valueColor?.value ??
Color _getValueColor(BuildContext context, {Color? defaultColor}) {
return valueColor?.value ??
color ??
ProgressIndicatorTheme.of(context).color ??
defaultColor ??
Theme.of(context).colorScheme.primary;
}
......@@ -331,12 +331,17 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> with
}
Widget _buildIndicator(BuildContext context, double animationValue, TextDirection textDirection) {
final ProgressIndicatorThemeData defaults = Theme.of(context).useMaterial3
? _LinearProgressIndicatorDefaultsM3(context)
: _LinearProgressIndicatorDefaultsM2(context);
final ProgressIndicatorThemeData indicatorTheme = ProgressIndicatorTheme.of(context);
final Color trackColor =
widget.backgroundColor ??
final Color trackColor = widget.backgroundColor ??
indicatorTheme.linearTrackColor ??
Theme.of(context).colorScheme.background;
final double minHeight = widget.minHeight ?? indicatorTheme.linearMinHeight ?? 4.0;
defaults.linearTrackColor!;
final double minHeight = widget.minHeight ??
indicatorTheme.linearMinHeight ??
defaults.linearMinHeight!;
return widget._buildSemanticsWrapper(
context: context,
......@@ -348,7 +353,7 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> with
child: CustomPaint(
painter: _LinearProgressIndicatorPainter(
backgroundColor: trackColor,
valueColor: widget._getValueColor(context),
valueColor: widget._getValueColor(context, defaultColor: defaults.color),
value: widget.value, // may be null
animationValue: animationValue, // ignored if widget.value is not null
textDirection: textDirection,
......@@ -580,11 +585,12 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
}
Widget _buildMaterialIndicator(BuildContext context, double headValue, double tailValue, double offsetValue, double rotationValue) {
final ProgressIndicatorThemeData defaults = Theme.of(context).useMaterial3
? _CircularProgressIndicatorDefaultsM3(context)
: _CircularProgressIndicatorDefaultsM2(context);
final Color? trackColor = widget.backgroundColor ?? ProgressIndicatorTheme.of(context).circularTrackColor;
return widget._buildSemanticsWrapper(
context: context,
child: Container(
Widget progressIndicator = Container(
constraints: const BoxConstraints(
minWidth: _kMinCircularProgressIndicatorSize,
minHeight: _kMinCircularProgressIndicatorSize,
......@@ -592,7 +598,7 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
child: CustomPaint(
painter: _CircularProgressIndicatorPainter(
backgroundColor: trackColor,
valueColor: widget._getValueColor(context),
valueColor: widget._getValueColor(context, defaultColor: defaults.color),
value: widget.value, // may be null
headValue: headValue, // remaining arguments are ignored if widget.value is not null
tailValue: tailValue,
......@@ -601,10 +607,24 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
strokeWidth: widget.strokeWidth,
),
),
);
if (Theme.of(context).useMaterial3) {
progressIndicator = SizedBox(
height: _CircularProgressIndicatorDefaultsM3.circularProgressIndicatorSize,
width: _CircularProgressIndicatorDefaultsM3.circularProgressIndicatorSize,
child: Center(
child: progressIndicator
),
);
}
return widget._buildSemanticsWrapper(
context: context,
child: progressIndicator,
);
}
Widget _buildAnimation() {
return AnimatedBuilder(
animation: _controller,
......@@ -866,3 +886,69 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState {
);
}
}
// Hand coded defaults based on Material Design 2.
class _CircularProgressIndicatorDefaultsM2 extends ProgressIndicatorThemeData {
_CircularProgressIndicatorDefaultsM2(this.context);
final BuildContext context;
late final ColorScheme _colors = Theme.of(context).colorScheme;
@override
Color get color => _colors.primary;
}
class _LinearProgressIndicatorDefaultsM2 extends ProgressIndicatorThemeData {
_LinearProgressIndicatorDefaultsM2(this.context);
final BuildContext context;
late final ColorScheme _colors = Theme.of(context).colorScheme;
@override
Color get color => _colors.primary;
@override
Color get linearTrackColor => _colors.background;
@override
double get linearMinHeight => 4.0;
}
// BEGIN GENERATED TOKEN PROPERTIES - ProgressIndicator
// Do not edit by hand. The code between the "BEGIN GENERATED" and
// "END GENERATED" comments are generated from data in the Material
// Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Token database version: v0_132
class _CircularProgressIndicatorDefaultsM3 extends ProgressIndicatorThemeData {
_CircularProgressIndicatorDefaultsM3(this.context);
final BuildContext context;
late final ColorScheme _colors = Theme.of(context).colorScheme;
static const double circularProgressIndicatorSize = 48.0;
@override
Color get color => _colors.primary;
}
class _LinearProgressIndicatorDefaultsM3 extends ProgressIndicatorThemeData {
_LinearProgressIndicatorDefaultsM3(this.context);
final BuildContext context;
late final ColorScheme _colors = Theme.of(context).colorScheme;
@override
Color get color => _colors.primary;
@override
Color get linearTrackColor => _colors.surfaceVariant;
@override
double get linearMinHeight => 4.0;
}
// END GENERATED TOKEN PROPERTIES - ProgressIndicator
......@@ -1266,6 +1266,7 @@ class ThemeData with Diagnosticable {
/// * Lists: [ListTile]
/// * Navigation bar: [NavigationBar] (new, replacing [BottomNavigationBar])
/// * [Navigation rail](https://m3.material.io/components/navigation-rail): [NavigationRail]
/// * Progress indicators: [CircularProgressIndicator], [LinearProgressIndicator]
/// * Radio button: [Radio]
/// * Switch: [Switch]
/// * Top app bar: [AppBar]
......
......@@ -20,6 +20,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart';
void main() {
final ThemeData theme = ThemeData();
// The "can be constructed" tests that follow are primarily to ensure that any
// animations started by the progress indicators are stopped at dispose() time.
......@@ -27,7 +28,9 @@ void main() {
testWidgets('LinearProgressIndicator(value: 0.0) can be constructed and has empty semantics by default', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -36,6 +39,7 @@ void main() {
),
),
),
),
);
expect(tester.getSemantics(find.byType(LinearProgressIndicator)), matchesSemantics());
......@@ -45,7 +49,9 @@ void main() {
testWidgets('LinearProgressIndicator(value: null) can be constructed and has empty semantics by default', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.rtl,
child: Center(
child: SizedBox(
......@@ -54,6 +60,7 @@ void main() {
),
),
),
),
);
expect(tester.getSemantics(find.byType(LinearProgressIndicator)), matchesSemantics());
......@@ -62,7 +69,9 @@ void main() {
testWidgets('LinearProgressIndicator custom minHeight', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -71,6 +80,7 @@ void main() {
),
),
),
),
);
expect(
find.byType(LinearProgressIndicator),
......@@ -82,7 +92,7 @@ void main() {
// Same test, but using the theme
await tester.pumpWidget(
Theme(
data: ThemeData(
data: theme.copyWith(
progressIndicatorTheme: const ProgressIndicatorThemeData(
linearMinHeight: 2.0,
),
......@@ -108,7 +118,9 @@ void main() {
testWidgets('LinearProgressIndicator paint (LTR)', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -117,6 +129,7 @@ void main() {
),
),
),
),
);
expect(
......@@ -131,7 +144,9 @@ void main() {
testWidgets('LinearProgressIndicator paint (RTL)', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.rtl,
child: Center(
child: SizedBox(
......@@ -140,6 +155,7 @@ void main() {
),
),
),
),
);
expect(
......@@ -154,7 +170,9 @@ void main() {
testWidgets('LinearProgressIndicator indeterminate (LTR)', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -163,6 +181,7 @@ void main() {
),
),
),
),
);
await tester.pump(const Duration(milliseconds: 300));
......@@ -181,7 +200,9 @@ void main() {
testWidgets('LinearProgressIndicator paint (RTL)', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.rtl,
child: Center(
child: SizedBox(
......@@ -190,6 +211,7 @@ void main() {
),
),
),
),
);
await tester.pump(const Duration(milliseconds: 300));
......@@ -209,7 +231,9 @@ void main() {
testWidgets('LinearProgressIndicator with colors', (WidgetTester tester) async {
// With valueColor & color provided
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -223,6 +247,7 @@ void main() {
),
),
),
),
);
// Should use valueColor
......@@ -235,7 +260,9 @@ void main() {
// With just color provided
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -248,6 +275,7 @@ void main() {
),
),
),
),
);
// Should use color
......@@ -260,10 +288,9 @@ void main() {
// With no color provided
const Color primaryColor = Color(0xff008800);
final ThemeData theme = ThemeData(colorScheme: ColorScheme.fromSwatch().copyWith(primary: primaryColor));
await tester.pumpWidget(
Theme(
data: theme,
data: theme.copyWith(colorScheme: ColorScheme.fromSwatch().copyWith(primary: primaryColor)),
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
......@@ -291,7 +318,7 @@ void main() {
const Color indicatorColor = Color(0xff0000ff);
await tester.pumpWidget(
Theme(
data: ThemeData(
data: theme.copyWith(
progressIndicatorTheme: const ProgressIndicatorThemeData(
color: indicatorColor,
linearTrackColor: Colors.black,
......@@ -323,7 +350,9 @@ void main() {
testWidgets('LinearProgressIndicator with animation with null colors', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -336,6 +365,7 @@ void main() {
),
),
),
),
);
expect(
......@@ -349,12 +379,15 @@ void main() {
testWidgets('CircularProgressIndicator(value: 0.0) can be constructed and has value semantics by default', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: CircularProgressIndicator(value: 0.0),
),
),
),
);
expect(tester.getSemantics(find.byType(CircularProgressIndicator)), matchesSemantics(
......@@ -367,9 +400,12 @@ void main() {
testWidgets('CircularProgressIndicator(value: null) can be constructed and has empty semantics by default', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
const Center(
Theme(
data: theme,
child: const Center(
child: CircularProgressIndicator(),
),
),
);
expect(tester.getSemantics(find.byType(CircularProgressIndicator)), matchesSemantics());
......@@ -377,25 +413,31 @@ void main() {
});
testWidgets('LinearProgressIndicator causes a repaint when it changes', (WidgetTester tester) async {
await tester.pumpWidget(Directionality(
await tester.pumpWidget(Theme(
data: theme,
child: Directionality(
textDirection: TextDirection.ltr,
child: ListView(children: const <Widget>[LinearProgressIndicator(value: 0.0)]),
),
));
final List<Layer> layers1 = tester.layers;
await tester.pumpWidget(Directionality(
await tester.pumpWidget(Theme(
data: theme,
child: Directionality(
textDirection: TextDirection.ltr,
child: ListView(children: const <Widget>[LinearProgressIndicator(value: 0.5)]),
),
));
final List<Layer> layers2 = tester.layers;
expect(layers1, isNot(equals(layers2)));
});
testWidgets('CircularProgressIndicator stoke width', (WidgetTester tester) async {
await tester.pumpWidget(const CircularProgressIndicator());
await tester.pumpWidget(Theme(data: theme, child: const CircularProgressIndicator()));
expect(find.byType(CircularProgressIndicator), paints..arc(strokeWidth: 4.0));
await tester.pumpWidget(const CircularProgressIndicator(strokeWidth: 16.0));
await tester.pumpWidget(Theme(data: theme, child: const CircularProgressIndicator(strokeWidth: 16.0)));
expect(find.byType(CircularProgressIndicator), paints..arc(strokeWidth: 16.0));
});
......@@ -406,39 +448,48 @@ void main() {
const Color red = Color(0xFFFF0000);
// With valueColor & color provided
await tester.pumpWidget(const CircularProgressIndicator(
await tester.pumpWidget(Theme(
data: theme,
child: const CircularProgressIndicator(
color: red,
valueColor: AlwaysStoppedAnimation<Color>(blue),
),
));
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
expect(find.byType(CircularProgressIndicator), paints..arc(color: blue));
// With just color provided
await tester.pumpWidget(const CircularProgressIndicator(
await tester.pumpWidget(Theme(
data: theme,
child: const CircularProgressIndicator(
color: red,
),
));
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
expect(find.byType(CircularProgressIndicator), paints..arc(color: red));
// With no color provided
await tester.pumpWidget(Theme(
data: ThemeData(colorScheme: ColorScheme.fromSwatch().copyWith(primary: green)),
data: theme.copyWith(colorScheme: ColorScheme.fromSwatch().copyWith(primary: green)),
child: const CircularProgressIndicator(),
));
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
expect(find.byType(CircularProgressIndicator), paints..arc(color: green));
// With background
await tester.pumpWidget(const CircularProgressIndicator(
await tester.pumpWidget(Theme(
data: theme,
child: const CircularProgressIndicator(
backgroundColor: green,
color: blue,
),
));
expect(find.byType(CircularProgressIndicator), paintsExactlyCountTimes(#drawArc, 2));
expect(find.byType(CircularProgressIndicator), paints..arc(color: green)..arc(color: blue));
// With ProgressIndicatorTheme
await tester.pumpWidget(Theme(
data: ThemeData(progressIndicatorTheme: const ProgressIndicatorThemeData(
data: theme.copyWith(progressIndicatorTheme: const ProgressIndicatorThemeData(
color: green,
circularTrackColor: blue,
)),
......@@ -454,32 +505,41 @@ void main() {
const Color red = Color(0xFFFF0000);
// With valueColor & color provided
await tester.pumpWidget(const RefreshProgressIndicator(
await tester.pumpWidget(Theme(
data: theme,
child: const RefreshProgressIndicator(
color: red,
valueColor: AlwaysStoppedAnimation<Color>(blue),
),
));
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
expect(find.byType(RefreshProgressIndicator), paints..arc(color: blue));
// With just color provided
await tester.pumpWidget(const RefreshProgressIndicator(
await tester.pumpWidget(Theme(
data: theme,
child: const RefreshProgressIndicator(
color: red,
),
));
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
expect(find.byType(RefreshProgressIndicator), paints..arc(color: red));
// With no color provided
await tester.pumpWidget(Theme(
data: ThemeData(colorScheme: ColorScheme.fromSwatch().copyWith(primary: green)),
data: theme.copyWith(colorScheme: ColorScheme.fromSwatch().copyWith(primary: green)),
child: const RefreshProgressIndicator(),
));
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
expect(find.byType(RefreshProgressIndicator), paints..arc(color: green));
// With background
await tester.pumpWidget(const RefreshProgressIndicator(
await tester.pumpWidget(Theme(
data: theme,
child: const RefreshProgressIndicator(
color: blue,
backgroundColor: green,
),
));
expect(find.byType(RefreshProgressIndicator), paintsExactlyCountTimes(#drawArc, 1));
expect(find.byType(RefreshProgressIndicator), paints..arc(color: blue));
......@@ -492,7 +552,7 @@ void main() {
// With ProgressIndicatorTheme
await tester.pumpWidget(Theme(
data: ThemeData(progressIndicatorTheme: const ProgressIndicatorThemeData(
data: theme.copyWith(progressIndicatorTheme: const ProgressIndicatorThemeData(
color: green,
refreshBackgroundColor: blue,
)),
......@@ -512,7 +572,9 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/13782
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -521,6 +583,7 @@ void main() {
),
),
),
),
);
expect(tester.hasRunningAnimations, isTrue);
......@@ -551,7 +614,9 @@ void main() {
double? progressValue;
late StateSetter setState;
await tester.pumpWidget(
Directionality(
Theme(
data: theme,
child: Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: StatefulBuilder(
......@@ -562,6 +627,7 @@ void main() {
),
),
),
),
);
expect(tester.hasRunningAnimations, isTrue);
......@@ -576,7 +642,9 @@ void main() {
testWidgets('LinearProgressIndicator with height 12.0', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -586,6 +654,7 @@ void main() {
),
),
),
),
);
expect(
find.byType(LinearProgressIndicator),
......@@ -598,7 +667,9 @@ void main() {
testWidgets('LinearProgressIndicator with a height less than the minimum', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -608,6 +679,7 @@ void main() {
),
),
),
),
);
expect(
find.byType(LinearProgressIndicator),
......@@ -620,7 +692,9 @@ void main() {
testWidgets('LinearProgressIndicator with default height', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
Theme(
data: theme,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: SizedBox(
......@@ -630,6 +704,7 @@ void main() {
),
),
),
),
);
expect(
find.byType(LinearProgressIndicator),
......@@ -646,7 +721,9 @@ void main() {
const String label = 'Label';
const String value = '25%';
await tester.pumpWidget(
Directionality(
Theme(
data: theme,
child: Directionality(
textDirection: TextDirection.ltr,
child: LinearProgressIndicator(
key: key,
......@@ -655,6 +732,7 @@ void main() {
semanticsValue: value,
),
),
),
);
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
......@@ -671,7 +749,9 @@ void main() {
final GlobalKey key = GlobalKey();
const String label = 'Label';
await tester.pumpWidget(
Directionality(
Theme(
data: theme,
child: Directionality(
textDirection: TextDirection.ltr,
child: LinearProgressIndicator(
key: key,
......@@ -679,6 +759,7 @@ void main() {
semanticsLabel: label,
),
),
),
);
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
......@@ -694,13 +775,16 @@ void main() {
final SemanticsHandle handle = tester.ensureSemantics();
final GlobalKey key = GlobalKey();
await tester.pumpWidget(
Directionality(
Theme(
data: theme,
child: Directionality(
textDirection: TextDirection.ltr,
child: LinearProgressIndicator(
key: key,
value: 0.25,
),
),
),
);
expect(tester.getSemantics(find.byKey(key)), matchesSemantics());
......@@ -713,7 +797,9 @@ void main() {
final GlobalKey key = GlobalKey();
const String label = 'Progress';
await tester.pumpWidget(
Directionality(
Theme(
data: theme,
child: Directionality(
textDirection: TextDirection.ltr,
child: LinearProgressIndicator(
key: key,
......@@ -721,6 +807,7 @@ void main() {
semanticsLabel: label,
),
),
),
);
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
......@@ -737,7 +824,9 @@ void main() {
const String label = 'Label';
const String value = '25%';
await tester.pumpWidget(
Directionality(
Theme(
data: theme,
child: Directionality(
textDirection: TextDirection.ltr,
child: CircularProgressIndicator(
key: key,
......@@ -746,6 +835,7 @@ void main() {
semanticsValue: value,
),
),
),
);
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
......@@ -763,7 +853,9 @@ void main() {
const String label = 'Label';
const String value = '25%';
await tester.pumpWidget(
Directionality(
Theme(
data: theme,
child: Directionality(
textDirection: TextDirection.ltr,
child: RefreshProgressIndicator(
key: key,
......@@ -771,6 +863,7 @@ void main() {
semanticsValue: value,
),
),
),
);
expect(tester.getSemantics(find.byKey(key)), matchesSemantics(
......@@ -805,8 +898,9 @@ void main() {
'Adaptive CircularProgressIndicator displays CupertinoActivityIndicator in iOS',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
MaterialApp(
theme: ThemeData(),
home: const Scaffold(
body: Material(
child: CircularProgressIndicator.adaptive(),
),
......@@ -826,8 +920,9 @@ void main() {
'Adaptive CircularProgressIndicator can use backgroundColor to change tick color for iOS',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
MaterialApp(
theme: ThemeData(),
home: const Scaffold(
body: Material(
child: CircularProgressIndicator.adaptive(
backgroundColor: Color(0xFF5D3FD3),
......@@ -854,8 +949,9 @@ void main() {
'Adaptive CircularProgressIndicator does not display CupertinoActivityIndicator in non-iOS',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
MaterialApp(
theme: theme,
home: const Scaffold(
body: Material(
child: CircularProgressIndicator.adaptive(),
),
......@@ -893,7 +989,7 @@ void main() {
);
await tester.pumpWidget(MaterialApp(
home: progressTheme,
home: Theme(data: theme, child: progressTheme),
));
final Widget wrappedTheme = progressTheme.wrap(builderContext, Container());
......@@ -903,6 +999,21 @@ void main() {
expect(wrappedTheme, isInstanceOf<ProgressIndicatorTheme>());
expect((wrappedTheme as ProgressIndicatorTheme).data, themeData);
});
testWidgets('default size of CircularProgressIndicator is 48x48 - M3', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: theme.copyWith(useMaterial3: true),
home: const Scaffold(
body: Material(
child: CircularProgressIndicator(),
),
),
),
);
expect(tester.getSize(find.byType(CircularProgressIndicator)), const Size(48, 48));
});
}
class _RefreshProgressIndicatorGolden extends StatefulWidget {
......
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