Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e1671628
Unverified
Commit
e1671628
authored
Sep 23, 2022
by
Qun Cheng
Committed by
GitHub
Sep 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated `ProgressIndicator` to M3 (#112139)
parent
71c21d60
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
457 additions
and
213 deletions
+457
-213
gen_defaults.dart
dev/tools/gen_defaults/bin/gen_defaults.dart
+4
-0
progress_indicator_template.dart
dev/tools/gen_defaults/lib/progress_indicator_template.dart
+42
-0
progress_indicator.dart
packages/flutter/lib/src/material/progress_indicator.dart
+112
-26
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+1
-0
progress_indicator_test.dart
packages/flutter/test/material/progress_indicator_test.dart
+298
-187
No files found.
dev/tools/gen_defaults/bin/gen_defaults.dart
View file @
e1671628
...
@@ -31,6 +31,7 @@ import 'package:gen_defaults/input_chip_template.dart';
...
@@ -31,6 +31,7 @@ import 'package:gen_defaults/input_chip_template.dart';
import
'package:gen_defaults/input_decorator_template.dart'
;
import
'package:gen_defaults/input_decorator_template.dart'
;
import
'package:gen_defaults/navigation_bar_template.dart'
;
import
'package:gen_defaults/navigation_bar_template.dart'
;
import
'package:gen_defaults/navigation_rail_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/radio_template.dart'
;
import
'package:gen_defaults/surface_tint.dart'
;
import
'package:gen_defaults/surface_tint.dart'
;
import
'package:gen_defaults/switch_template.dart'
;
import
'package:gen_defaults/switch_template.dart'
;
...
@@ -80,6 +81,8 @@ Future<void> main(List<String> args) async {
...
@@ -80,6 +81,8 @@ Future<void> main(List<String> args) async {
'navigation_drawer.json'
,
'navigation_drawer.json'
,
'navigation_rail.json'
,
'navigation_rail.json'
,
'palette.json'
,
'palette.json'
,
'progress_indicator_circular.json'
,
'progress_indicator_linear.json'
,
'radio_button.json'
,
'radio_button.json'
,
'segmented_button_outlined.json'
,
'segmented_button_outlined.json'
,
'shape.json'
,
'shape.json'
,
...
@@ -126,6 +129,7 @@ Future<void> main(List<String> args) async {
...
@@ -126,6 +129,7 @@ Future<void> main(List<String> args) async {
InputDecoratorTemplate
(
'InputDecorator'
,
'
$materialLib
/input_decorator.dart'
,
tokens
).
updateFile
();
InputDecoratorTemplate
(
'InputDecorator'
,
'
$materialLib
/input_decorator.dart'
,
tokens
).
updateFile
();
NavigationBarTemplate
(
'NavigationBar'
,
'
$materialLib
/navigation_bar.dart'
,
tokens
).
updateFile
();
NavigationBarTemplate
(
'NavigationBar'
,
'
$materialLib
/navigation_bar.dart'
,
tokens
).
updateFile
();
NavigationRailTemplate
(
'NavigationRail'
,
'
$materialLib
/navigation_rail.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
();
RadioTemplate
(
'Radio<T>'
,
'
$materialLib
/radio.dart'
,
tokens
).
updateFile
();
SurfaceTintTemplate
(
'SurfaceTint'
,
'
$materialLib
/elevation_overlay.dart'
,
tokens
).
updateFile
();
SurfaceTintTemplate
(
'SurfaceTint'
,
'
$materialLib
/elevation_overlay.dart'
,
tokens
).
updateFile
();
SwitchTemplate
(
'Switch'
,
'
$materialLib
/switch.dart'
,
tokens
).
updateFile
();
SwitchTemplate
(
'Switch'
,
'
$materialLib
/switch.dart'
,
tokens
).
updateFile
();
...
...
dev/tools/gen_defaults/lib/progress_indicator_template.dart
0 → 100644
View file @
e1671628
// 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']}
;
}
'''
;
}
packages/flutter/lib/src/material/progress_indicator.dart
View file @
e1671628
...
@@ -108,11 +108,11 @@ abstract class ProgressIndicator extends StatefulWidget {
...
@@ -108,11 +108,11 @@ abstract class ProgressIndicator extends StatefulWidget {
/// {@endtemplate}
/// {@endtemplate}
final
String
?
semanticsValue
;
final
String
?
semanticsValue
;
Color
_getValueColor
(
BuildContext
context
)
{
Color
_getValueColor
(
BuildContext
context
,
{
Color
?
defaultColor
})
{
return
return
valueColor
?.
value
??
valueColor
?.
value
??
color
??
color
??
ProgressIndicatorTheme
.
of
(
context
).
color
??
ProgressIndicatorTheme
.
of
(
context
).
color
??
defaultColor
??
Theme
.
of
(
context
).
colorScheme
.
primary
;
Theme
.
of
(
context
).
colorScheme
.
primary
;
}
}
...
@@ -331,12 +331,17 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> with
...
@@ -331,12 +331,17 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> with
}
}
Widget
_buildIndicator
(
BuildContext
context
,
double
animationValue
,
TextDirection
textDirection
)
{
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
ProgressIndicatorThemeData
indicatorTheme
=
ProgressIndicatorTheme
.
of
(
context
);
final
Color
trackColor
=
final
Color
trackColor
=
widget
.
backgroundColor
??
widget
.
backgroundColor
??
indicatorTheme
.
linearTrackColor
??
indicatorTheme
.
linearTrackColor
??
Theme
.
of
(
context
).
colorScheme
.
background
;
defaults
.
linearTrackColor
!;
final
double
minHeight
=
widget
.
minHeight
??
indicatorTheme
.
linearMinHeight
??
4.0
;
final
double
minHeight
=
widget
.
minHeight
??
indicatorTheme
.
linearMinHeight
??
defaults
.
linearMinHeight
!;
return
widget
.
_buildSemanticsWrapper
(
return
widget
.
_buildSemanticsWrapper
(
context:
context
,
context:
context
,
...
@@ -348,7 +353,7 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> with
...
@@ -348,7 +353,7 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> with
child:
CustomPaint
(
child:
CustomPaint
(
painter:
_LinearProgressIndicatorPainter
(
painter:
_LinearProgressIndicatorPainter
(
backgroundColor:
trackColor
,
backgroundColor:
trackColor
,
valueColor:
widget
.
_getValueColor
(
context
),
valueColor:
widget
.
_getValueColor
(
context
,
defaultColor:
defaults
.
color
),
value:
widget
.
value
,
// may be null
value:
widget
.
value
,
// may be null
animationValue:
animationValue
,
// ignored if widget.value is not null
animationValue:
animationValue
,
// ignored if widget.value is not null
textDirection:
textDirection
,
textDirection:
textDirection
,
...
@@ -580,29 +585,44 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
...
@@ -580,29 +585,44 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
}
}
Widget
_buildMaterialIndicator
(
BuildContext
context
,
double
headValue
,
double
tailValue
,
double
offsetValue
,
double
rotationValue
)
{
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
;
final
Color
?
trackColor
=
widget
.
backgroundColor
??
ProgressIndicatorTheme
.
of
(
context
).
circularTrackColor
;
return
widget
.
_buildSemanticsWrapper
(
Widget
progressIndicator
=
Container
(
context:
context
,
constraints:
const
BoxConstraints
(
child:
Container
(
minWidth:
_kMinCircularProgressIndicatorSize
,
constraints:
const
BoxConstraints
(
minHeight:
_kMinCircularProgressIndicatorSize
,
minWidth:
_kMinCircularProgressIndicatorSize
,
),
minHeight:
_kMinCircularProgressIndicatorSize
,
child:
CustomPaint
(
),
painter:
_CircularProgressIndicatorPainter
(
child:
CustomPaint
(
backgroundColor:
trackColor
,
painter:
_CircularProgressIndicatorPainter
(
valueColor:
widget
.
_getValueColor
(
context
,
defaultColor:
defaults
.
color
),
backgroundColor:
trackColor
,
value:
widget
.
value
,
// may be null
valueColor:
widget
.
_getValueColor
(
context
),
headValue:
headValue
,
// remaining arguments are ignored if widget.value is not null
value:
widget
.
value
,
// may be null
tailValue:
tailValue
,
headValue:
headValue
,
// remaining arguments are ignored if widget.value is not null
offsetValue:
offsetValue
,
tailValue:
tailValue
,
rotationValue:
rotationValue
,
offsetValue:
offsetValue
,
strokeWidth:
widget
.
strokeWidth
,
rotationValue:
rotationValue
,
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
()
{
Widget
_buildAnimation
()
{
...
@@ -866,3 +886,69 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState {
...
@@ -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
packages/flutter/lib/src/material/theme_data.dart
View file @
e1671628
...
@@ -1266,6 +1266,7 @@ class ThemeData with Diagnosticable {
...
@@ -1266,6 +1266,7 @@ class ThemeData with Diagnosticable {
/// * Lists: [ListTile]
/// * Lists: [ListTile]
/// * Navigation bar: [NavigationBar] (new, replacing [BottomNavigationBar])
/// * Navigation bar: [NavigationBar] (new, replacing [BottomNavigationBar])
/// * [Navigation rail](https://m3.material.io/components/navigation-rail): [NavigationRail]
/// * [Navigation rail](https://m3.material.io/components/navigation-rail): [NavigationRail]
/// * Progress indicators: [CircularProgressIndicator], [LinearProgressIndicator]
/// * Radio button: [Radio]
/// * Radio button: [Radio]
/// * Switch: [Switch]
/// * Switch: [Switch]
/// * Top app bar: [AppBar]
/// * Top app bar: [AppBar]
...
...
packages/flutter/test/material/progress_indicator_test.dart
View file @
e1671628
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment