-
Notifications
You must be signed in to change notification settings - Fork 219
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
accounts-ui: Make accounts list scrollable #593
accounts-ui: Make accounts list scrollable #593
Conversation
8bf59c5
to
5c62d37
Compare
0614b90
to
f752479
Compare
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.
Thanks @sm-sayedi! Generally this looks great; several small comments on the tests.
f752479
to
a246461
Compare
Thanks for the review! Revision pushed. PTAL! |
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.
Thanks for the revision! Generally this looks great; a few small comments below.
test/widgets/app_test.dart
Outdated
|
||
group('ChooseAccountPage', () { | ||
Future<void> setupChooseAccountPage(WidgetTester tester, { | ||
required List<Account>? accounts, |
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.
nit: requiring the caller to explicitly pass this makes sense, but then it may as well just take a list:
required List<Account>? accounts, | |
required List<Account> accounts, |
so the caller explicitly says []
, instead of saying null
and having that mean []
.
(In fact, now that I think of that, even in the version where this parameter was optional it probably should have been List<Account> accounts = [],
rather than being nullable.)
test/widgets/app_test.dart
Outdated
testWidgets('accounts list is scrollable when more than a screenful', | ||
(tester) async { |
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.
nit: we just leave the (tester) async {
part on the same line even if that makes the line long:
testWidgets('accounts list is scrollable when more than a screenful', | |
(tester) async { | |
testWidgets('accounts list is scrollable when more than a screenful', (tester) async { |
Because that part is totally boring and predictable, it's OK if it gets scrolled off screen for the reader.
test/widgets/app_test.dart
Outdated
testWidgets('accounts list is scrollable when more than a screenful', | ||
(tester) async { | ||
final accounts = generateAccounts(15); |
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.
(If OTOH we had a situation where it wasn't so boring and predictable and did need to go on the next line, we'd want to avoid having the (tester) async {
aligned with the body, because it makes it look like part of the body. For a function, the standard way to do that is to indent the body:
testWidgets('accounts list is scrollable when more than a screenful',
(tester) async {
final accounts = generateAccounts(15);
)
test/widgets/app_test.dart
Outdated
final accountRect = tester.getRect(findAccount(account)); | ||
check(accountRect.top).isGreaterThan(thirdOfScreenHeight); | ||
check(accountRect.bottom).isLessThan(screenHeight - thirdOfScreenHeight); |
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.
Let's write this in more thoroughly package:checks
style:
final accountRect = tester.getRect(findAccount(account)); | |
check(accountRect.top).isGreaterThan(thirdOfScreenHeight); | |
check(accountRect.bottom).isLessThan(screenHeight - thirdOfScreenHeight); | |
check(tester.getRect(findAccount(account))) | |
..top.isGreaterThan(thirdOfScreenHeight) | |
..bottom.isLessThan(screenHeight - thirdOfScreenHeight); |
You'll need to write those accessors top
and bottom
, since we haven't yet. They'll go in test/flutter_checks.dart
; see existing examples there.
test/widgets/app_test.dart
Outdated
check(accountRect.top).isGreaterThan(thirdOfScreenHeight); | ||
check(accountRect.bottom).isLessThan(screenHeight - thirdOfScreenHeight); |
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.
Separately, for the numbers, let's just write:
check(accountRect.top).isGreaterThan(thirdOfScreenHeight); | |
check(accountRect.bottom).isLessThan(screenHeight - thirdOfScreenHeight); | |
check(accountRect.top).isGreaterThan(1/3 * screenHeight); | |
check(accountRect.bottom).isLessThan(2/3 * screenHeight); |
For me at least, that's clearer to read than the more word-based version.
a246461
to
680b9ff
Compare
Thanks for the review! Pushed the revision. Please have a look! |
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.
One nit below; otherwise all looks good. I'll fix that nit and merge. Thanks @sm-sayedi for adding this!
test/flutter_checks.dart
Outdated
} | ||
extension AnimationChecks<T> on Subject<Animation<T>> { |
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.
nit:
} | |
extension AnimationChecks<T> on Subject<Animation<T>> { | |
} | |
extension AnimationChecks<T> on Subject<Animation<T>> { |
Before this fix, the list of accounts did not scroll when they were more than a screenful and would show an overflow error on the screen. After this fix, the list of accounts scrolls properly with no overflow error and without shifting other content offscreen. Fixes: zulip#100
680b9ff
to
e6c531a
Compare
Before this fix, the list of accounts did not scroll when they were more than a screenful and would show an overflow error on the screen.
After this fix, the list of accounts scrolls properly with no overflow error and without shifting other content offscreen.
Fixes: #100