style: 统一下拉与加载指示器
This commit is contained in:
1 parent
397483d339
commit
6f1da5aa39
26 files changed
+127
-241
No files matched your search
@@ -44,28 +44,32 @@ void main() {
|
||||
find.descendant(of: list, matching: find.byType(Scrollable)).first,
|
||||
);
|
||||
expect(scrollable.position.pixels, 0);
|
||||
expect(find.text('Pull to refresh'), findsOneWidget);
|
||||
expect(_contentOffset(tester), greaterThan(0));
|
||||
final indicator = find.byKey(const Key('pull-refresh-indicator'));
|
||||
expect(indicator, findsOneWidget);
|
||||
expect(
|
||||
tester.widget<Text>(find.text('Pull to refresh')).style?.color,
|
||||
AppColors.navSelected,
|
||||
find.descendant(
|
||||
of: indicator,
|
||||
matching: find.byType(CircularProgressIndicator),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.getSize(indicator), const Size(40, 40));
|
||||
final background = tester.widget<Container>(indicator).decoration;
|
||||
final backgroundDecoration = background! as BoxDecoration;
|
||||
expect(backgroundDecoration.color, AppColors.refreshIndicatorSurface);
|
||||
expect(backgroundDecoration.borderRadius, BorderRadius.circular(20));
|
||||
expect(find.text('Pull to refresh'), findsNothing);
|
||||
expect(_contentOffset(tester), greaterThan(0));
|
||||
|
||||
await gesture.moveBy(const Offset(0, 120));
|
||||
await tester.pump();
|
||||
expect(find.text('Release to refresh'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<Text>(find.text('Release to refresh')).style?.color,
|
||||
AppColors.navSelected,
|
||||
);
|
||||
expect(indicator, findsOneWidget);
|
||||
expect(find.text('Release to refresh'), findsNothing);
|
||||
|
||||
await gesture.up();
|
||||
await tester.pump();
|
||||
expect(find.text('Refreshing…'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<Text>(find.text('Refreshing…')).style?.color,
|
||||
AppColors.navSelected,
|
||||
);
|
||||
expect(indicator, findsOneWidget);
|
||||
expect(find.text('Refreshing…'), findsNothing);
|
||||
expect(calls, 1);
|
||||
final releaseOffset = _contentOffset(tester);
|
||||
expect(releaseOffset, greaterThan(56));
|
||||
@@ -87,6 +91,7 @@ void main() {
|
||||
await tester.pump();
|
||||
await tester.pumpAndSettle();
|
||||
expect(_contentOffset(tester), closeTo(0, 0.1));
|
||||
expect(indicator, findsNothing);
|
||||
expect(find.text('Refreshing…'), findsNothing);
|
||||
expect(find.text('Pull to refresh'), findsNothing);
|
||||
});
|
||||
@@ -122,7 +127,8 @@ void main() {
|
||||
final releaseOffset = _contentOffset(tester);
|
||||
expect(releaseOffset, greaterThan(0));
|
||||
expect(releaseOffset, lessThan(56));
|
||||
expect(find.text('Pull to refresh'), findsOneWidget);
|
||||
expect(find.byKey(const Key('pull-refresh-indicator')), findsOneWidget);
|
||||
expect(find.text('Pull to refresh'), findsNothing);
|
||||
|
||||
await gesture.up();
|
||||
await tester.pump();
|
||||
@@ -136,6 +142,7 @@ void main() {
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
expect(_contentOffset(tester), closeTo(0, 0.1));
|
||||
expect(find.byKey(const Key('pull-refresh-indicator')), findsNothing);
|
||||
expect(find.text('Pull to refresh'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -388,7 +388,8 @@ void main() {
|
||||
);
|
||||
await tester.drag(_verticalFeed, const Offset(0, 240));
|
||||
await tester.pump();
|
||||
expect(find.text('Refreshing…'), findsOneWidget);
|
||||
expect(find.byKey(const Key('pull-refresh-indicator')), findsOneWidget);
|
||||
expect(find.text('Refreshing…'), findsNothing);
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ void main() {
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('ranking-row-39')), findsOneWidget);
|
||||
expect(find.byKey(const Key('ranking-row-40')), findsNothing);
|
||||
expect(find.byKey(const Key('ranking-no-more')), findsOneWidget);
|
||||
expect(find.byKey(const Key('ranking-no-more')), findsNothing);
|
||||
|
||||
position.jumpTo(0);
|
||||
await tester.pump();
|
||||
@@ -211,7 +211,7 @@ void main() {
|
||||
expect(position.pixels, 0);
|
||||
position.jumpTo(position.maxScrollExtent);
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('ranking-load-more')), findsOneWidget);
|
||||
expect(find.byKey(const Key('ranking-load-more')), findsNothing);
|
||||
expect(find.byKey(const Key('ranking-no-more')), findsNothing);
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
@@ -243,7 +243,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
position.jumpTo(position.maxScrollExtent);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('new-releases-no-more')), findsOneWidget);
|
||||
expect(find.byKey(const Key('new-releases-no-more')), findsNothing);
|
||||
|
||||
position.jumpTo(0);
|
||||
await tester.pump();
|
||||
|
||||
@@ -99,7 +99,8 @@ void main() {
|
||||
);
|
||||
await tester.drag(find.byType(ListView), const Offset(0, 240));
|
||||
await tester.pump();
|
||||
expect(find.text('Refreshing…'), findsOneWidget);
|
||||
expect(find.byKey(const Key('pull-refresh-indicator')), findsOneWidget);
|
||||
expect(find.text('Refreshing…'), findsNothing);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('favorite-remove-signal')));
|
||||
|
||||
@@ -24,9 +24,10 @@ void main() {
|
||||
await _pump(tester, repository);
|
||||
|
||||
expect(find.text('Notice 1'), findsOneWidget);
|
||||
expect(find.byKey(const Key('notices-load-more')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('notices-load-more')));
|
||||
await tester.drag(
|
||||
find.byKey(const Key('notices-list')),
|
||||
const Offset(0, -300),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Notice 3'), findsOneWidget);
|
||||
|
||||
Reference in new issue
Block a user