-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/leaderboard/stre…
…ak-team
- Loading branch information
Showing
27 changed files
with
306 additions
and
370 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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 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 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 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 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:bloc/bloc.dart'; | ||
import 'package:board_info_repository/board_info_repository.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
part 'welcome_event.dart'; | ||
part 'welcome_state.dart'; | ||
|
||
class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> { | ||
WelcomeBloc({ | ||
required BoardInfoRepository boardInfoRepository, | ||
}) : _boardInfoRepository = boardInfoRepository, | ||
super(const WelcomeState.initial()) { | ||
on<WelcomeDataRequested>(_onDataRequested); | ||
} | ||
|
||
final BoardInfoRepository _boardInfoRepository; | ||
|
||
Future<void> _onDataRequested( | ||
WelcomeDataRequested event, | ||
Emitter<WelcomeState> emit, | ||
) async { | ||
try { | ||
final [solved, total] = await Future.wait([ | ||
_boardInfoRepository.getSolvedWordsCount(), | ||
_boardInfoRepository.getTotalWordsCount(), | ||
]); | ||
|
||
emit( | ||
state.copyWith( | ||
solvedWords: solved, | ||
totalWords: total, | ||
), | ||
); | ||
} catch (error, stackTrace) { | ||
addError(error, stackTrace); | ||
} | ||
} | ||
} |
This file contains 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,13 @@ | ||
part of 'welcome_bloc.dart'; | ||
|
||
sealed class WelcomeEvent extends Equatable { | ||
const WelcomeEvent(); | ||
|
||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
/// Requests the data needed to welcome the user. | ||
class WelcomeDataRequested extends WelcomeEvent { | ||
const WelcomeDataRequested(); | ||
} |
This file contains 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,45 @@ | ||
part of 'welcome_bloc.dart'; | ||
|
||
class WelcomeState extends Equatable { | ||
const WelcomeState({ | ||
required this.solvedWords, | ||
required this.totalWords, | ||
}); | ||
|
||
/// Creates a [WelcomeState] with the initial status. | ||
const WelcomeState.initial({ | ||
this.solvedWords = fallbackSolvedWords, | ||
this.totalWords = fallbackTotalWords, | ||
}); | ||
|
||
@visibleForTesting | ||
static const fallbackTotalWords = 66666; | ||
|
||
@visibleForTesting | ||
static const fallbackSolvedWords = 0; | ||
|
||
/// The current solved words in the challenge. | ||
/// | ||
/// If the loading of the solved words is yet to be done or fails this will | ||
/// default to [fallbackSolvedWords]. | ||
final int solvedWords; | ||
|
||
/// The total words to complete the challenge. | ||
/// | ||
/// If the loading of the total words is yet to be done or fails this will | ||
/// default to [fallbackTotalWords]. | ||
final int totalWords; | ||
|
||
WelcomeState copyWith({ | ||
int? solvedWords, | ||
int? totalWords, | ||
}) { | ||
return WelcomeState( | ||
solvedWords: solvedWords ?? this.solvedWords, | ||
totalWords: totalWords ?? this.totalWords, | ||
); | ||
} | ||
|
||
@override | ||
List<Object> get props => [solvedWords, totalWords]; | ||
} |
Oops, something went wrong.