Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

feat: results animation #29

Merged
merged 13 commits into from
Nov 29, 2023
16 changes: 16 additions & 0 deletions lib/home/bloc/home_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
on<AskQuestion>(_onQuestion);
on<QueryUpdated>(_queryUpdated);
on<QuestionAsked>(_questionAsked);
on<Results>(_onResults);
on<SeeSourceAnswersRequested>(_onSeeSourceAnswersRequested);
on<SeeResultsSourceAnswers>(_onSeeSourceAnswers);
}

final QuestionsRepository _questionsRepository;
Expand Down Expand Up @@ -51,9 +53,23 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
);
}

void _onResults(
Results event,
Emitter<HomeState> emit,
) {
emit(state.copyWith(status: Status.results));
}

void _onSeeSourceAnswersRequested(
SeeSourceAnswersRequested event,
Emitter<HomeState> emit,
) {
emit(state.copyWith(status: Status.resultsToSourceAnswers));
}

void _onSeeSourceAnswers(
SeeResultsSourceAnswers event,
Emitter<HomeState> emit,
) {
emit(state.copyWith(status: Status.seeSourceAnswers));
}
Expand Down
8 changes: 8 additions & 0 deletions lib/home/bloc/home_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ class QuestionAsked extends HomeEvent {
const QuestionAsked();
}

class Results extends HomeEvent {
const Results();
}

class SeeSourceAnswersRequested extends HomeEvent {
const SeeSourceAnswersRequested();
}

class SeeResultsSourceAnswers extends HomeEvent {
const SeeResultsSourceAnswers();
}
8 changes: 7 additions & 1 deletion lib/home/bloc/home_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ enum Status {
thinking,
thinkingToResults,
results,
resultsToSourceAnswers,
seeSourceAnswers,
sourceAnswersBackToResults,
}

class HomeState extends Equatable {
Expand All @@ -31,7 +33,10 @@ class HomeState extends Equatable {
status == Status.thinking ||
status == Status.thinkingToResults;
bool get isResultsVisible =>
status == Status.thinkingToResults || status == Status.results;
status == Status.thinkingToResults ||
status == Status.results ||
status == Status.resultsToSourceAnswers ||
status == Status.seeSourceAnswers;
bool get isSeeSourceAnswersVisible => status == Status.seeSourceAnswers;
bool get isDashVisible => [
Status.welcome,
Expand All @@ -40,6 +45,7 @@ class HomeState extends Equatable {
Status.askQuestionToThinking,
Status.thinkingToResults,
Status.results,
Status.resultsToSourceAnswers,
].contains(status);

HomeState copyWith({
Expand Down
1 change: 0 additions & 1 deletion lib/home/view/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class HomeView extends StatelessWidget {
if (state.isQuestionVisible) const QuestionView(),
if (state.isThinkingVisible) const ThinkingView(),
if (state.isResultsVisible) const ResultsView(),
if (state.isSeeSourceAnswersVisible) const SeeSourceAnswers(),
if (state.isDashVisible)
const Positioned(
bottom: 50,
Expand Down
3 changes: 2 additions & 1 deletion lib/home/widgets/dash_animation_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class _DashAnimationContainerState extends State<DashAnimationContainer> {
Widget build(BuildContext context) {
return BlocListener<HomeBloc, HomeState>(
listener: (context, state) {
if (state.status == Status.askQuestionToThinking) {
if (state.status == Status.askQuestionToThinking ||
state.status == Status.resultsToSourceAnswers) {
_state.value = DashAnimationPhase.dashOut;
} else if (state.status == Status.thinkingToResults) {
_state.value = DashAnimationPhase.dashIn;
Expand Down
Loading
Loading