Run dart format

pull/2113/head
Qun Cheng 1 year ago
parent a55a69605d
commit 5b2eff51f7

@ -46,7 +46,9 @@ class ColorPalettesScreen extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 15),
child: ColorSchemeView(
handleColorRoleChange: handleColorRoleChange,
colorScheme: brightness == Brightness.light ? lightColorScheme : darkColorScheme,
colorScheme: brightness == Brightness.light
? lightColorScheme
: darkColorScheme,
brightness: brightness,
),
);
@ -266,7 +268,8 @@ class _ColorSchemeViewState extends State<ColorSchemeView> {
color: _colorScheme.onSecondaryContainer,
onColor: _colorScheme.secondaryContainer,
updateColorScheme: (color) {
_colorScheme = _colorScheme.copyWith(onSecondaryContainer: color);
_colorScheme =
_colorScheme.copyWith(onSecondaryContainer: color);
widget.handleColorRoleChange(
widget.brightness,
onSecondaryContainer: color,
@ -319,7 +322,8 @@ class _ColorSchemeViewState extends State<ColorSchemeView> {
color: _colorScheme.onTertiaryContainer,
onColor: _colorScheme.tertiaryContainer,
updateColorScheme: (color) {
_colorScheme = _colorScheme.copyWith(onTertiaryContainer: color);
_colorScheme =
_colorScheme.copyWith(onTertiaryContainer: color);
widget.handleColorRoleChange(
widget.brightness,
onTertiaryContainer: color,
@ -611,7 +615,8 @@ class _EditableColorChipState extends State<EditableColorChip> {
ColorLabelType.hsv,
ColorLabelType.hsl
],
pickerAreaBorderRadius: const BorderRadius.all(Radius.circular(10)),
pickerAreaBorderRadius:
const BorderRadius.all(Radius.circular(10)),
hexInputController: textController,
portraitOnly: true,
),
@ -623,22 +628,23 @@ class _EditableColorChipState extends State<EditableColorChip> {
prefixText: '#',
suffix: IconButton(
icon: const Icon(Icons.content_paste_rounded),
onPressed: () => copyToClipboard(textController.text),
onPressed: () =>
copyToClipboard(textController.text),
),
),
autofocus: true,
maxLength: 8,
inputFormatters: [
UpperCaseTextFormatter(),
FilteringTextInputFormatter.allow(RegExp(kValidHexPattern)),
FilteringTextInputFormatter.allow(
RegExp(kValidHexPattern)),
],
),
)
],
),
);
}
);
});
},
child: ColorChip(
label: widget.label,

@ -10,8 +10,9 @@ import 'constants.dart';
import 'elevation_screen.dart';
import 'typography_screen.dart';
typedef ConfigColorSchemeCallback = void Function(Brightness brightness,
{ Color? primary,
typedef ConfigColorSchemeCallback = void Function(
Brightness brightness, {
Color? primary,
Color? onPrimary,
Color? primaryContainer,
Color? onPrimaryContainer,
@ -41,7 +42,7 @@ typedef ConfigColorSchemeCallback = void Function(Brightness brightness,
Color? onInverseSurface,
Color? inversePrimary,
Color? surfaceTint,
});
});
class Home extends StatefulWidget {
const Home({

@ -75,8 +75,9 @@ class _AppState extends State<App> {
});
}
void handleColorRoleChange(Brightness brightness,
{ Color? primary,
void handleColorRoleChange(
Brightness brightness, {
Color? primary,
Color? onPrimary,
Color? primaryContainer,
Color? onPrimaryContainer,
@ -106,8 +107,7 @@ class _AppState extends State<App> {
Color? onInverseSurface,
Color? inversePrimary,
Color? surfaceTint,
}
) {
}) {
ColorScheme? copyWith(ColorScheme? colorScheme) {
return colorScheme?.copyWith(
primary: primary,

@ -70,7 +70,8 @@ void main() {
addTearDown(tester.view.resetPhysicalSize);
await tester.pumpWidget(const App());
Finder colorPageIndicator = find.descendant(of: find.byType(NavigationRail),
Finder colorPageIndicator = find.descendant(
of: find.byType(NavigationRail),
matching: find.byIcon(Icons.format_paint_outlined));
expect(colorPageIndicator, findsOneWidget);
await tester.tap(colorPageIndicator);
@ -85,7 +86,8 @@ void main() {
addTearDown(tester.view.resetPhysicalSize);
await tester.pumpWidget(const App());
Finder colorPageIndicator = find.descendant(of: find.byType(NavigationRail),
Finder colorPageIndicator = find.descendant(
of: find.byType(NavigationRail),
matching: find.byIcon(Icons.format_paint_outlined));
expect(colorPageIndicator, findsOneWidget);
await tester.tap(colorPageIndicator);
@ -104,12 +106,16 @@ void main() {
expect(find.text('73a450'), findsOneWidget);
// Test if the chip color is changed to 73a450.
Finder primaryChip = find.descendant(of: find.widgetWithText(ColorChip, 'primary').first, matching: find.byType(Container));
Finder primaryChip = find.descendant(
of: find.widgetWithText(ColorChip, 'primary').first,
matching: find.byType(Container));
Container container = tester.widget<Container>(primaryChip);
expect(container.color, const Color(0xFF73A450));
});
testWidgets('Light ColorScheme is configurable; changes can be applied to the widget page', (tester) async {
testWidgets(
'Light ColorScheme is configurable; changes can be applied to the widget page',
(tester) async {
widgetSetup(tester, 1200);
addTearDown(tester.view.resetPhysicalSize);
await tester.pumpWidget(const App());
@ -121,7 +127,8 @@ void main() {
await updatePrimaryChipColor(tester, const Color(0xff123456), true);
// Go to the component screen
Finder componentPageIndicator = find.descendant(of: find.byType(NavigationRail),
Finder componentPageIndicator = find.descendant(
of: find.byType(NavigationRail),
matching: find.byIcon(Icons.widgets_outlined));
expect(componentPageIndicator, findsOneWidget);
await tester.tap(componentPageIndicator);
@ -140,7 +147,9 @@ void main() {
expect(material.color, const Color(0xff123456));
});
testWidgets('Dark ColorScheme is configurable; changes can be applied to the widget page', (tester) async {
testWidgets(
'Dark ColorScheme is configurable; changes can be applied to the widget page',
(tester) async {
widgetSetup(tester, 1200);
addTearDown(tester.view.resetPhysicalSize);
await tester.pumpWidget(const App());
@ -155,7 +164,8 @@ void main() {
await updatePrimaryChipColor(tester, const Color(0xff654321), false);
// Go to the component screen
Finder componentPageIndicator = find.descendant(of: find.byType(NavigationRail),
Finder componentPageIndicator = find.descendant(
of: find.byType(NavigationRail),
matching: find.byIcon(Icons.widgets_outlined));
expect(componentPageIndicator, findsOneWidget);
await tester.tap(componentPageIndicator);
@ -175,13 +185,17 @@ void main() {
});
}
Future<void> updatePrimaryChipColor(WidgetTester tester, Color newColor, bool isLight) async {
Finder colorPageIndicator = find.descendant(of: find.byType(NavigationRail),
Future<void> updatePrimaryChipColor(
WidgetTester tester, Color newColor, bool isLight) async {
Finder colorPageIndicator = find.descendant(
of: find.byType(NavigationRail),
matching: find.byIcon(Icons.format_paint_outlined));
expect(colorPageIndicator, findsOneWidget);
await tester.tap(colorPageIndicator);
await tester.pumpAndSettle();
expect(isLight ? find.text('Light ColorScheme') : find.text('Dark ColorScheme'), findsOneWidget);
expect(
isLight ? find.text('Light ColorScheme') : find.text('Dark ColorScheme'),
findsOneWidget);
Finder primaryColorChip = isLight
? find.widgetWithText(EditableColorChip, 'primary').first
@ -190,7 +204,8 @@ Future<void> updatePrimaryChipColor(WidgetTester tester, Color newColor, bool is
await tester.pump();
expect(find.byType(AlertDialog), findsOneWidget);
await tester.enterText(find.byType(TextField), newColor.value.toRadixString(16));
await tester.enterText(
find.byType(TextField), newColor.value.toRadixString(16));
// Tap on the barrier.
await tester.tapAt(const Offset(10.0, 10.0));

Loading…
Cancel
Save