-
Notifications
You must be signed in to change notification settings - Fork 314
theme: Implement DesignVariables.dark #804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
88bdf69
theme [nfc]: s/bgMain/mainBackground/, following change in Figma
chrisbobbe 1816786
theme [nfc]: Add debugFollowPlatformBrightness, to use in a test
chrisbobbe b2e3ff6
theme test [nfc]: Simplify colorSwatchFor test
chrisbobbe 3ac8cec
theme test [nfc]: Remove a `doTest` helper that we don't want anymore
chrisbobbe af2e178
theme: Implement DesignVariables.dark
chrisbobbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,30 +76,74 @@ void main() { | |
button: TextButton(onPressed: () {}, child: const Text(buttonText))); | ||
}); | ||
|
||
group('colorSwatchFor', () { | ||
void doTest(String description, int baseColor, StreamColorSwatch expected) { | ||
testWidgets('$description $baseColor', (WidgetTester tester) async { | ||
addTearDown(testBinding.reset); | ||
|
||
final subscription = eg.subscription(eg.stream(), color: baseColor); | ||
group('DesignVariables', () { | ||
group('lerp', () { | ||
testWidgets('light -> light', (tester) async { | ||
final a = DesignVariables.light(); | ||
final b = DesignVariables.light(); | ||
check(() => a.lerp(b, 0.5)).returnsNormally(); | ||
}); | ||
|
||
await tester.pumpWidget(const ZulipApp()); | ||
await tester.pump(); | ||
testWidgets('light -> dark', (tester) async { | ||
final a = DesignVariables.light(); | ||
final b = DesignVariables.dark(); | ||
check(() => a.lerp(b, 0.5)).returnsNormally(); | ||
}); | ||
|
||
late StreamColorSwatch actualSwatch; | ||
final navigator = await ZulipApp.navigator; | ||
navigator.push(MaterialWidgetRoute(page: Builder(builder: (context) { | ||
actualSwatch = colorSwatchFor(context, subscription); | ||
return const Placeholder(); | ||
}))); | ||
await tester.pumpAndSettle(); | ||
testWidgets('dark -> light', (tester) async { | ||
final a = DesignVariables.dark(); | ||
final b = DesignVariables.light(); | ||
check(() => a.lerp(b, 0.5)).returnsNormally(); | ||
}); | ||
|
||
// Compares all the swatch's members; see [ColorSwatch]'s `operator ==`. | ||
check(actualSwatch).equals(expected); | ||
testWidgets('dark -> dark', (tester) async { | ||
final a = DesignVariables.dark(); | ||
final b = DesignVariables.dark(); | ||
check(() => a.lerp(b, 0.5)).returnsNormally(); | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
doTest('light', 0xff76ce90, StreamColorSwatch.light(0xff76ce90)); | ||
// TODO(#95) test with Brightness.dark and lerping between light/dark | ||
group('colorSwatchFor', () { | ||
const baseColor = 0xff76ce90; | ||
|
||
testWidgets('light–dark animation', (WidgetTester tester) async { | ||
addTearDown(testBinding.reset); | ||
|
||
final subscription = eg.subscription(eg.stream(), color: baseColor); | ||
|
||
assert(!debugFollowPlatformBrightness); // to be removed with #95 | ||
debugFollowPlatformBrightness = true; | ||
addTearDown(() { debugFollowPlatformBrightness = false; }); | ||
tester.platformDispatcher.platformBrightnessTestValue = Brightness.light; | ||
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue); | ||
|
||
await tester.pumpWidget(const ZulipApp()); | ||
await tester.pump(); | ||
|
||
final navigator = await ZulipApp.navigator; | ||
navigator.push(MaterialWidgetRoute(page: Builder(builder: (context) => | ||
const Placeholder()))); | ||
await tester.pumpAndSettle(); | ||
|
||
final element = tester.element(find.byType(Placeholder)); | ||
// Compares all the swatch's members; see [ColorSwatch]'s `operator ==`. | ||
check(colorSwatchFor(element, subscription)) | ||
Comment on lines
+129
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat! |
||
.equals(StreamColorSwatch.light(baseColor)); | ||
|
||
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark; | ||
await tester.pump(); | ||
|
||
await tester.pump(kThemeAnimationDuration * 0.4); | ||
check(colorSwatchFor(element, subscription)) | ||
.equals(StreamColorSwatch.lerp( | ||
StreamColorSwatch.light(baseColor), | ||
StreamColorSwatch.dark(baseColor), | ||
0.4)!); | ||
|
||
await tester.pump(kThemeAnimationDuration * 0.6); | ||
check(colorSwatchFor(element, subscription)) | ||
.equals(StreamColorSwatch.dark(baseColor)); | ||
}); | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should also get an
addTearDown
call to reset