Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions integration_test/scrolling_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,32 @@ void main() {
await tester.pump();
}

await binding.traceAction(
() async {
await tester.tap(bestTabFinder);
await tester.pump();
await binding.traceAction(() async {
await tester.tap(bestTabFinder);
await tester.pump();

const int count = 10;
const int count = 10;

for (int i = 0; i < count; i++) {
await scrollDown(tester);
}
for (int i = 0; i < count; i++) {
await scrollDown(tester);
}

for (int i = 0; i < count - 3; i++) {
await scrollUp(tester);
}
for (int i = 0; i < count - 3; i++) {
await scrollUp(tester);
}

await tester.pumpAndSettle(const Duration(seconds: 2));
await tester.pumpAndSettle(const Duration(seconds: 2));

final Finder storyFinder = find.byType(StoryTile);
final Finder storyFinder = find.byType(StoryTile);

expect(storyFinder, findsWidgets);
expect(storyFinder, findsWidgets);

final Finder firstStoryFinder = storyFinder.first;
final Finder firstStoryFinder = storyFinder.first;

expect(firstStoryFinder, findsOneWidget);
expect(firstStoryFinder, findsOneWidget);

await tester.tap(firstStoryFinder);
await tester.pump(const Duration(seconds: 5));
},
reportKey: 'scrolling_timeline',
);
await tester.tap(firstStoryFinder);
await tester.pump(const Duration(seconds: 5));
}, reportKey: 'scrolling_timeline');
});
}
34 changes: 13 additions & 21 deletions lib/blocs/auth/auth_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> with Loggable {
PreferenceRepository? preferenceRepository,
HackerNewsRepository? hackerNewsRepository,
SembastRepository? sembastRepository,
}) : _authRepository = authRepository ?? locator.get<AuthRepository>(),
_preferenceRepository =
preferenceRepository ?? locator.get<PreferenceRepository>(),
_hackerNewsRepository =
hackerNewsRepository ?? locator.get<HackerNewsRepository>(),
_sembastRepository =
sembastRepository ?? locator.get<SembastRepository>(),
super(const AuthState.init()) {
}) : _authRepository = authRepository ?? locator.get<AuthRepository>(),
_preferenceRepository =
preferenceRepository ?? locator.get<PreferenceRepository>(),
_hackerNewsRepository =
hackerNewsRepository ?? locator.get<HackerNewsRepository>(),
_sembastRepository =
sembastRepository ?? locator.get<SembastRepository>(),
super(const AuthState.init()) {
on<AuthInitialize>(onInitialize);
on<AuthLogin>(onLogin);
on<AuthLogout>(onLogout);
Expand Down Expand Up @@ -51,20 +51,11 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> with Loggable {

logInfo('silently logged in as ${user.id}.');
emit(
state.copyWith(
isLoggedIn: true,
user: user,
status: Status.success,
),
state.copyWith(isLoggedIn: true, user: user, status: Status.success),
);
} else {
logInfo('no previous session found.');
emit(
state.copyWith(
isLoggedIn: false,
status: Status.success,
),
);
emit(state.copyWith(isLoggedIn: false, status: Status.success));
}
});
}
Expand Down Expand Up @@ -92,8 +83,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> with Loggable {
);

if (successful) {
final User? user =
await _hackerNewsRepository.fetchUser(id: event.username);
final User? user = await _hackerNewsRepository.fetchUser(
id: event.username,
);
logInfo('user logged in as ${user?.id}.');
emit(
state.copyWith(
Expand Down
10 changes: 2 additions & 8 deletions lib/blocs/auth/auth_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ class AuthInitialize extends AuthEvent {
}

class AuthLogin extends AuthEvent {
AuthLogin({
required this.username,
required this.password,
});
AuthLogin({required this.username, required this.password});

final String username;
final String password;

@override
List<Object?> get props => <Object?>[
username,
password,
];
List<Object?> get props => <Object?>[username, password];
}

class AuthToggleAgreeToEULA extends AuthEvent {
Expand Down
15 changes: 5 additions & 10 deletions lib/blocs/auth/auth_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class AuthState extends Equatable {
});

const AuthState.init()
: user = const User.empty(),
isLoggedIn = false,
status = Status.success,
agreedToEULA = false;
: user = const User.empty(),
isLoggedIn = false,
status = Status.success,
agreedToEULA = false;

final User user;
final bool isLoggedIn;
Expand All @@ -36,10 +36,5 @@ class AuthState extends Equatable {
}

@override
List<Object?> get props => <Object?>[
user,
isLoggedIn,
agreedToEULA,
status,
];
List<Object?> get props => <Object?>[user, isLoggedIn, agreedToEULA, status];
}
Loading