-
Notifications
You must be signed in to change notification settings - Fork 314
ui: Set letter spacing to 1% in buttons #635
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
2 commits
Select commit
Hold shift + click to select a range
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
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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'text.dart'; | ||
|
||
ThemeData zulipThemeData(BuildContext context) { | ||
return ThemeData( | ||
typography: zulipTypography(context), | ||
appBarTheme: const AppBarTheme( | ||
// Set these two fields to prevent a color change in [AppBar]s when | ||
// there is something scrolled under it. If an app bar hasn't been | ||
// given a backgroundColor directly or by theme, it uses | ||
// ColorScheme.surfaceContainer for the scrolled-under state and | ||
// ColorScheme.surface otherwise, and those are different colors. | ||
scrolledUnderElevation: 0, | ||
backgroundColor: Color(0xfff5f5f5), | ||
|
||
shape: Border(bottom: BorderSide(color: Color(0xffcccccc))), | ||
), | ||
// This applies Material 3's color system to produce a palette of | ||
// appropriately matching and contrasting colors for use in a UI. | ||
// The Zulip brand color is a starting point, but doesn't end up as | ||
// one that's directly used. (After all, we didn't design it for that | ||
// purpose; we designed a logo.) See docs: | ||
// https://api.flutter.dev/flutter/material/ColorScheme/ColorScheme.fromSeed.html | ||
// Or try this tool to see the whole palette: | ||
// https://m3.material.io/theme-builder#/custom | ||
colorScheme: ColorScheme.fromSeed( | ||
seedColor: kZulipBrandColor, | ||
), | ||
scaffoldBackgroundColor: const Color(0xfff6f6f6), | ||
tooltipTheme: const TooltipThemeData(preferBelow: false), | ||
); | ||
} | ||
|
||
/// The Zulip "brand color", a purplish blue. | ||
/// | ||
/// This is chosen as the sRGB midpoint of the Zulip logo's gradient. | ||
// As computed by Anders: https://github.com/zulip/zulip-mobile/pull/4467 | ||
const kZulipBrandColor = Color.fromRGBO(0x64, 0x92, 0xfe, 1); |
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
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import 'package:checks/checks.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/rendering.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:zulip/widgets/text.dart'; | ||
import 'package:zulip/widgets/theme.dart'; | ||
|
||
import '../flutter_checks.dart'; | ||
|
||
void main() { | ||
group('button text size and letter spacing', () { | ||
const buttonText = 'Zulip'; | ||
|
||
Future<void> doCheck( | ||
String description, { | ||
required Widget button, | ||
double? ambientTextScaleFactor, | ||
}) async { | ||
testWidgets(description, (WidgetTester tester) async { | ||
if (ambientTextScaleFactor != null) { | ||
tester.platformDispatcher.textScaleFactorTestValue = ambientTextScaleFactor; | ||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); | ||
} | ||
late final double expectedFontSize; | ||
late final double expectedLetterSpacing; | ||
await tester.pumpWidget( | ||
Builder(builder: (context) => MaterialApp( | ||
theme: zulipThemeData(context), | ||
home: Builder(builder: (context) { | ||
expectedFontSize = Theme.of(context).textTheme.labelLarge!.fontSize!; | ||
expectedLetterSpacing = proportionalLetterSpacing(context, | ||
0.01, baseFontSize: expectedFontSize); | ||
return button; | ||
})))); | ||
|
||
final text = tester.renderObject<RenderParagraph>(find.text(buttonText)).text; | ||
check(text.style!) | ||
..fontSize.equals(expectedFontSize) | ||
..letterSpacing.equals(expectedLetterSpacing); | ||
}); | ||
} | ||
|
||
doCheck('with device text size adjusted', | ||
ambientTextScaleFactor: 2.0, | ||
button: ElevatedButton(onPressed: () {}, child: const Text(buttonText))); | ||
|
||
doCheck('ElevatedButton', | ||
button: ElevatedButton(onPressed: () {}, child: const Text(buttonText))); | ||
|
||
doCheck('FilledButton', | ||
button: FilledButton(onPressed: () {}, child: const Text(buttonText))); | ||
|
||
// IconButton can't have text; skip | ||
|
||
doCheck('MenuItemButton', | ||
button: MenuItemButton(onPressed: () {}, child: const Text(buttonText))); | ||
|
||
doCheck('SubmenuButton', | ||
button: const SubmenuButton(menuChildren: [], child: Text(buttonText))); | ||
|
||
doCheck('OutlinedButton', | ||
button: OutlinedButton(onPressed: () {}, child: const Text(buttonText))); | ||
|
||
doCheck('SegmentedButton', | ||
button: SegmentedButton(selected: const {1}, | ||
segments: const [ButtonSegment(value: 1, label: Text(buttonText))])); | ||
|
||
doCheck('TextButton', | ||
button: TextButton(onPressed: () {}, child: const Text(buttonText))); | ||
}); | ||
} |
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.
Cool, good to get this pulled out of
ZulipApp
.