|
|
@ -7,44 +7,27 @@ import 'package:pinball_theme/pinball_theme.dart';
|
|
|
|
part 'leaderboard_event.dart';
|
|
|
|
part 'leaderboard_event.dart';
|
|
|
|
part 'leaderboard_state.dart';
|
|
|
|
part 'leaderboard_state.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LeaderboardRepository {
|
|
|
|
|
|
|
|
Future<List<Competitor>> fetchRanking() {
|
|
|
|
|
|
|
|
return Future.value([]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class LeaderboardBloc extends Bloc<LeaderboardEvent, LeaderboardState> {
|
|
|
|
class LeaderboardBloc extends Bloc<LeaderboardEvent, LeaderboardState> {
|
|
|
|
LeaderboardBloc() : super(const LeaderboardState()) {
|
|
|
|
LeaderboardBloc(this._leaderboardRepository)
|
|
|
|
|
|
|
|
: super(const LeaderboardState()) {
|
|
|
|
on<LeaderboardRequested>(_onLeaderboardRequested);
|
|
|
|
on<LeaderboardRequested>(_onLeaderboardRequested);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final LeaderboardRepository _leaderboardRepository;
|
|
|
|
|
|
|
|
|
|
|
|
FutureOr<void> _onLeaderboardRequested(
|
|
|
|
FutureOr<void> _onLeaderboardRequested(
|
|
|
|
LeaderboardRequested event,
|
|
|
|
LeaderboardRequested event,
|
|
|
|
Emitter<LeaderboardState> emit,
|
|
|
|
Emitter<LeaderboardState> emit,
|
|
|
|
) {
|
|
|
|
) async {
|
|
|
|
emit(state.copyWith(status: LeaderboardStatus.loading));
|
|
|
|
emit(state.copyWith(status: LeaderboardStatus.loading));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const ranking = <Competitor>[
|
|
|
|
final ranking = await _leaderboardRepository.fetchRanking();
|
|
|
|
Competitor(
|
|
|
|
|
|
|
|
rank: 1,
|
|
|
|
|
|
|
|
characterTheme: DashTheme(),
|
|
|
|
|
|
|
|
initials: 'ABC',
|
|
|
|
|
|
|
|
score: 100,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Competitor(
|
|
|
|
|
|
|
|
rank: 2,
|
|
|
|
|
|
|
|
characterTheme: SparkyTheme(),
|
|
|
|
|
|
|
|
initials: 'DEF',
|
|
|
|
|
|
|
|
score: 200,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Competitor(
|
|
|
|
|
|
|
|
rank: 3,
|
|
|
|
|
|
|
|
characterTheme: AndroidTheme(),
|
|
|
|
|
|
|
|
initials: 'GHI',
|
|
|
|
|
|
|
|
score: 300,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Competitor(
|
|
|
|
|
|
|
|
rank: 4,
|
|
|
|
|
|
|
|
characterTheme: DinoTheme(),
|
|
|
|
|
|
|
|
initials: 'JKL',
|
|
|
|
|
|
|
|
score: 400,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit(
|
|
|
|
emit(
|
|
|
|
state.copyWith(
|
|
|
|
state.copyWith(
|
|
|
|
status: LeaderboardStatus.success,
|
|
|
|
status: LeaderboardStatus.success,
|
|
|
|