Skip to content

Commit

Permalink
material 3 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwindmill committed Apr 30, 2024
1 parent ae20885 commit cfbc111
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 110 deletions.
14 changes: 5 additions & 9 deletions animations/test/basics/animated_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ void main() {

// Get the initial color of the button.
ElevatedButton button = tester.widget(find.byType(ElevatedButton));
MaterialStateProperty<Color?>? initialColor =
button.style!.backgroundColor;
WidgetStateProperty<Color?>? initialColor = button.style!.backgroundColor;

// Tap the button.
await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();

// Get the updated color of the button.
button = tester.widget(find.byType(ElevatedButton));
MaterialStateProperty<Color?>? updatedColor =
button.style!.backgroundColor;
WidgetStateProperty<Color?>? updatedColor = button.style!.backgroundColor;

// Check if the color has changed.
expect(initialColor, isNot(updatedColor));
Expand All @@ -38,8 +36,7 @@ void main() {

// Get the initial color of the button.
ElevatedButton button = tester.widget(find.byType(ElevatedButton));
MaterialStateProperty<Color?>? initialColor =
button.style!.backgroundColor;
WidgetStateProperty<Color?>? initialColor = button.style!.backgroundColor;

// Tap the button to trigger the animation but don't wait for it to finish.
await tester.tap(find.byType(ElevatedButton));
Expand All @@ -48,16 +45,15 @@ void main() {

// Check that the color has changed but not to the final color.
button = tester.widget(find.byType(ElevatedButton));
MaterialStateProperty<Color?>? changedColor =
button.style!.backgroundColor;
WidgetStateProperty<Color?>? changedColor = button.style!.backgroundColor;
expect(initialColor, isNot(changedColor));

// Wait for the animation to finish.
await tester.pump(const Duration(milliseconds: 400));

// Check that the color has changed to the final color.
button = tester.widget(find.byType(ElevatedButton));
MaterialStateProperty<Color?>? finalColor = button.style!.backgroundColor;
WidgetStateProperty<Color?>? finalColor = button.style!.backgroundColor;
expect(changedColor, isNot(finalColor));
});
});
Expand Down
8 changes: 4 additions & 4 deletions experimental/varfont_shader_puzzle/lib/styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ class TextStyles {
class ButtonStyles {
static ButtonStyle style() {
return ButtonStyle(
fixedSize: MaterialStateProperty.resolveWith<Size>((states) {
fixedSize: WidgetStateProperty.resolveWith<Size>((states) {
return const Size(100, 36);
}),
shape: MaterialStateProperty.resolveWith<OutlinedBorder>((states) {
shape: WidgetStateProperty.resolveWith<OutlinedBorder>((states) {
return const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(18)));
}),
overlayColor: null,
backgroundColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.hovered)) {
backgroundColor: WidgetStateProperty.resolveWith<Color?>((states) {
if (states.contains(WidgetState.hovered)) {
return Colors.black; // Hovered bg (for desktop with mouse)
}
return Colors.grey[600]; // Default bg
Expand Down
2 changes: 1 addition & 1 deletion game_template/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class MyApp extends StatelessWidget {
theme: ThemeData.from(
colorScheme: ColorScheme.fromSeed(
seedColor: palette.darkPen,
background: palette.backgroundMain,
surface: palette.backgroundMain,
),
textTheme: TextTheme(
bodyMedium: TextStyle(
Expand Down
22 changes: 11 additions & 11 deletions material_3_demo/lib/color_palettes_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ class ColorSchemeView extends StatelessWidget {
onColor: colorScheme.surface,
),
ColorChip(
label: 'surfaceVariant',
color: colorScheme.surfaceVariant,
onColor: colorScheme.onSurfaceVariant,
label: 'surfaceContainerHighest',
color: colorScheme.surfaceContainerHighest,
onColor: colorScheme.surfaceContainerHighest,
),
ColorChip(
label: 'onSurfaceVariant',
color: colorScheme.onSurfaceVariant,
onColor: colorScheme.surfaceVariant,
label: 'surfaceContainerHighest',
color: colorScheme.surfaceContainerHighest,
onColor: colorScheme.surfaceContainerHighest,
),
ColorChip(
label: 'surfaceTint',
Expand Down Expand Up @@ -303,13 +303,13 @@ class ColorSchemeView extends StatelessWidget {
children: [
ColorChip(
label: 'background',
color: colorScheme.background,
onColor: colorScheme.onBackground,
color: colorScheme.surface,
onColor: colorScheme.onSurface,
),
ColorChip(
label: 'onBackground',
color: colorScheme.onBackground,
onColor: colorScheme.background,
label: 'onSurface',
color: colorScheme.onSurface,
onColor: colorScheme.surface,
),
ColorChip(
label: 'scrim',
Expand Down
13 changes: 8 additions & 5 deletions material_3_demo/lib/component_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ class Cards extends StatelessWidget {
SizedBox(
width: cardWidth,
child: Card(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
elevation: 0,
child: Container(
padding: const EdgeInsets.fromLTRB(10, 5, 5, 10),
Expand Down Expand Up @@ -849,9 +849,9 @@ class _SwitchRowState extends State<SwitchRow> {
bool value0 = false;
bool value1 = true;

final MaterialStateProperty<Icon?> thumbIcon =
MaterialStateProperty.resolveWith<Icon?>((states) {
if (states.contains(MaterialState.selected)) {
final WidgetStateProperty<Icon?> thumbIcon =
WidgetStateProperty.resolveWith<Icon?>((states) {
if (states.contains(WidgetState.selected)) {
return const Icon(Icons.check);
}
return const Icon(Icons.close);
Expand Down Expand Up @@ -2508,7 +2508,10 @@ class ComponentGroupDecoration extends StatelessWidget {
child: Card(
margin: EdgeInsets.zero,
elevation: 0,
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.3),
color: Theme.of(context)
.colorScheme
.surfaceContainerHighest
.withOpacity(0.3),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 20.0),
child: Center(
Expand Down
4 changes: 2 additions & 2 deletions material_3_demo/lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class _ColorSeedButton extends StatelessWidget {
return PopupMenuButton(
icon: Icon(
Icons.palette_outlined,
color: Theme.of(context).colorScheme.onSurfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
tooltip: 'Select a seed color',
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
Expand Down Expand Up @@ -367,7 +367,7 @@ class _ColorImageButton extends StatelessWidget {
return PopupMenuButton(
icon: Icon(
Icons.image_outlined,
color: Theme.of(context).colorScheme.onSurfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
tooltip: 'Select a color extraction image',
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
Expand Down
2 changes: 1 addition & 1 deletion material_3_demo/test/component_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void main() {

testWidgets('Color theme changes when a color is selected from menu',
(tester) async {
Color m3BaseColor = const Color(0xff6750a4);
Color m3BaseColor = const Color(0xff65558f);
await tester.pumpWidget(Container());
await tester.pumpWidget(const App());
await tester.pump();
Expand Down
4 changes: 2 additions & 2 deletions provider_shopper/lib/screens/catalog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class _AddButton extends StatelessWidget {
cart.add(item);
},
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.pressed)) {
overlayColor: WidgetStateProperty.resolveWith<Color?>((states) {
if (states.contains(WidgetState.pressed)) {
return Theme.of(context).primaryColor;
}
return null; // Defer to the widget's default.
Expand Down
25 changes: 10 additions & 15 deletions tool/flutter_ci_script_beta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ declare -ar PROJECT_NAMES=(
"add_to_app/prebuilt_module/flutter_module"
"analysis_defaults"
"android_splash_screen"
# TODO: 'MaterialStateProperty' is deprecated and shouldn't be used.
# "animations"
"animations"
"background_isolate_channels"
"code_sharing/client"
"code_sharing/server"
Expand All @@ -32,32 +31,28 @@ declare -ar PROJECT_NAMES=(
"experimental/federated_plugin/federated_plugin_platform_interface"
"experimental/federated_plugin/federated_plugin_web"
"experimental/federated_plugin/federated_plugin_windows"
# TODO: 'onBackground' is deprecated and shouldn't be used.
# "experimental/linting_tool"
# TODO: 'MaterialStateProperty' is deprecated and shouldn't be used.
# "experimental/pedometer"
# "experimental/pedometer/example"
# 'MaterialStateProperty' is deprecated and shouldn't be used.
# "experimental/varfont_shader_puzzle"
# TODO: ewindmill to talk to team about removing.
# Depends on package context_menus, which breaks with Material3 by default.
# "experimental/linting_tool"
"experimental/pedometer"
"experimental/pedometer/example"
"experimental/varfont_shader_puzzle"
"experimental/web_dashboard"
"flutter_maps_firestore"
"form_app"
# TODO: 'onBackground' is deprecated and shouldn't be used.
# "game_template"
"game_template"
"google_maps"
"infinite_list"
"ios_app_clip"
"isolate_example"
# TODO(ewindmill): Add back when deps allow
# "material_3_demo"
"material_3_demo"
"navigation_and_routing"
"place_tracker"
"platform_channels"
"platform_design"
"platform_view_swift"
"provider_counter"
# TODO: 'MaterialStateProperty' is deprecated and shouldn't be used.
# "provider_shopper"
"provider_shopper"
"simple_shader"
"simplistic_calculator"
"simplistic_editor"
Expand Down
111 changes: 53 additions & 58 deletions tool/flutter_ci_script_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,59 @@ source "$DIR/flutter_ci_script_shared.sh"
flutter doctor -v

declare -ar PROJECT_NAMES=(
"add_to_app/android_view/flutter_module_using_plugin"
"add_to_app/books/flutter_module_books"
"add_to_app/fullscreen/flutter_module"
"add_to_app/multiple_flutters/multiple_flutters_module"
"add_to_app/plugin/flutter_module_using_plugin"
"add_to_app/prebuilt_module/flutter_module"
"analysis_defaults"
"android_splash_screen"
# TODO: 'MaterialStateProperty' is deprecated and shouldn't be used.
# "animations"
"background_isolate_channels"
"code_sharing/client"
"code_sharing/server"
"code_sharing/shared"
"context_menus"
"deeplink_store_example"
"desktop_photo_search/fluent_ui"
"desktop_photo_search/material"
"experimental/federated_plugin/federated_plugin"
"experimental/federated_plugin/federated_plugin/example"
"experimental/federated_plugin/federated_plugin_macos"
"experimental/federated_plugin/federated_plugin_platform_interface"
"experimental/federated_plugin/federated_plugin_web"
"experimental/federated_plugin/federated_plugin_windows"
# TODO: 'onBackground' is deprecated and shouldn't be used.
# "experimental/linting_tool"
# TODO: 'MaterialStateProperty' is deprecated and shouldn't be used.
# "experimental/pedometer"
# "experimental/pedometer/example"
# 'MaterialStateProperty' is deprecated and shouldn't be used.
# "experimental/varfont_shader_puzzle"
"experimental/web_dashboard"
"flutter_maps_firestore"
"form_app"
# TODO: 'onBackground' is deprecated and shouldn't be used.
# "game_template"
"google_maps"
"infinite_list"
"ios_app_clip"
"isolate_example"
# TODO(ewindmill): Add back when deps allow
# "material_3_demo"
"navigation_and_routing"
"place_tracker"
"platform_channels"
"platform_design"
"platform_view_swift"
"provider_counter"
# TODO: 'MaterialStateProperty' is deprecated and shouldn't be used.
# "provider_shopper"
"simple_shader"
"simplistic_calculator"
"simplistic_editor"
"testing_app"
"veggieseasons"
"web_embedding/element_embedding_demo"
"web/_tool"
"web/samples_index"
"add_to_app/android_view/flutter_module_using_plugin"
"add_to_app/books/flutter_module_books"
"add_to_app/fullscreen/flutter_module"
"add_to_app/multiple_flutters/multiple_flutters_module"
"add_to_app/plugin/flutter_module_using_plugin"
"add_to_app/prebuilt_module/flutter_module"
"analysis_defaults"
"android_splash_screen"
"animations"
"background_isolate_channels"
"code_sharing/client"
"code_sharing/server"
"code_sharing/shared"
"context_menus"
"deeplink_store_example"
"desktop_photo_search/fluent_ui"
"desktop_photo_search/material"
"experimental/federated_plugin/federated_plugin"
"experimental/federated_plugin/federated_plugin/example"
"experimental/federated_plugin/federated_plugin_macos"
"experimental/federated_plugin/federated_plugin_platform_interface"
"experimental/federated_plugin/federated_plugin_web"
"experimental/federated_plugin/federated_plugin_windows"
# TODO: ewindmill to talk to team about removing.
# Depends on package context_menus, which breaks with Material3 by default.
# "experimental/linting_tool"
"experimental/pedometer"
"experimental/pedometer/example"
"experimental/varfont_shader_puzzle"
"experimental/web_dashboard"
"flutter_maps_firestore"
"form_app"
"game_template"
"google_maps"
"infinite_list"
"ios_app_clip"
"isolate_example"
"material_3_demo"
"navigation_and_routing"
"place_tracker"
"platform_channels"
"platform_design"
"platform_view_swift"
"provider_counter"
"provider_shopper"
"simple_shader"
"simplistic_calculator"
"simplistic_editor"
"testing_app"
"veggieseasons"
"web_embedding/element_embedding_demo"
"web/_tool"
"web/samples_index"
)

ci_projects "master" "${PROJECT_NAMES[@]}"
Expand Down
6 changes: 4 additions & 2 deletions tool/flutter_ci_script_stable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source "$DIR/flutter_ci_script_shared.sh"
flutter doctor -v

declare -ar PROJECT_NAMES=(
# "add_to_app/android_view/flutter_module_using_plugin"
"add_to_app/android_view/flutter_module_using_plugin"
"add_to_app/books/flutter_module_books"
"add_to_app/fullscreen/flutter_module"
"add_to_app/multiple_flutters/multiple_flutters_module"
Expand All @@ -31,7 +31,9 @@ declare -ar PROJECT_NAMES=(
"experimental/federated_plugin/federated_plugin_platform_interface"
"experimental/federated_plugin/federated_plugin_web"
"experimental/federated_plugin/federated_plugin_windows"
"experimental/linting_tool"
# TODO: ewindmill to talk to team about removing.
# Depends on package context_menus, which breaks with Material3 by default.
# "experimental/linting_tool"
"experimental/pedometer"
"experimental/pedometer/example"
"experimental/varfont_shader_puzzle"
Expand Down

0 comments on commit cfbc111

Please sign in to comment.