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

Commit

Permalink
Merge branch 'main' of https://github.com/VGVentures/dash_ai_search i…
Browse files Browse the repository at this point in the history
…nto feat/input-theme
  • Loading branch information
omartinma committed Dec 11, 2023
2 parents fc53c7a + 20fbff9 commit fbe90cd
Show file tree
Hide file tree
Showing 22 changed files with 396 additions and 474 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_app_staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
flutter-version: "3.16.2"
channel: "stable"
- run: flutter packages get
- run: flutter build web -t lib/main_development.dart --dart-define SHARING_ENABLED=true
- run: flutter build web -t lib/main_production.dart --dart-define SHARING_ENABLED=true --dart-define="AI_API_URL=${{ secrets.AI_API_URL }}"
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ app.*.map.json
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/dev/ci/**/Gemfile.lock
!.vscode/extensions.json
!.vscode/launch.json
!.idea/codeStyles/
!.idea/dictionaries/
!.idea/runConfigurations/
Expand Down
32 changes: 0 additions & 32 deletions .vscode/launch.json

This file was deleted.

72 changes: 24 additions & 48 deletions lib/home/bloc/home_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,31 @@ part 'home_state.dart';

class HomeBloc extends Bloc<HomeEvent, HomeState> {
HomeBloc(this._questionsRepository) : super(const HomeState()) {
on<FromWelcomeToQuestion>(_onFromWelcomeToQuestion);
on<AskQuestion>(_onQuestion);
on<QueryUpdated>(_queryUpdated);
on<QuestionAsked>(_questionAsked);
on<QuestionAskedAgain>(_questionAskedAgain);
on<Results>(_onResults);
on<SeeSourceAnswersRequested>(_onSeeSourceAnswersRequested);
on<SeeResultsSourceAnswers>(_onSeeSourceAnswers);
on<AddAnswerFeedback>(_onAddAnswerFeedback);
on<NavigateSourceAnswers>(_navigateSourceAnswers);
on<BackToAiSummaryTapped>(_onBackToAiSummaryTapped);
on<HomeNavigated>(_onHomeNavigated);
on<HomeQueryUpdated>(_onHomeQueryUpdated);
on<HomeQuestionAsked>(_onHomeQuestionAsked);
on<HomeQuestionAskedAgain>(_onHomeQuestionAskedAgain);
on<HomeSeeSourceAnswersRequested>(_onHomeSeeSourceAnswersRequested);
on<HomeAnswerFeedbackAdded>(_onHomeAnswerFeedbackAdded);
on<HomeSourceAnswersNavigated>(_onHomeSourceAnswersNavigated);
on<HomeBackToAiSummaryTapped>(_onHomeBackToAiSummaryTapped);
}

final QuestionsRepository _questionsRepository;

void _onFromWelcomeToQuestion(
FromWelcomeToQuestion event,
void _onHomeNavigated(
HomeNavigated event,
Emitter<HomeState> emit,
) {
emit(state.copyWith(status: Status.welcomeToAskQuestion));
emit(state.copyWith(status: event.status));
}

void _onQuestion(
AskQuestion event,
Emitter<HomeState> emit,
) {
emit(state.copyWith(status: Status.askQuestion));
}

void _queryUpdated(QueryUpdated event, Emitter<HomeState> emit) {
void _onHomeQueryUpdated(HomeQueryUpdated event, Emitter<HomeState> emit) {
emit(state.copyWith(query: event.query));
}

Future<void> _questionAsked(
QuestionAsked event,
Future<void> _onHomeQuestionAsked(
HomeQuestionAsked event,
Emitter<HomeState> emit,
) async {
emit(
Expand All @@ -56,8 +46,8 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
await _emitVertexResponse(emit);
}

Future<void> _questionAskedAgain(
QuestionAskedAgain event,
Future<void> _onHomeQuestionAskedAgain(
HomeQuestionAskedAgain event,
Emitter<HomeState> emit,
) async {
emit(
Expand All @@ -79,15 +69,8 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
);
}

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

void _onSeeSourceAnswersRequested(
SeeSourceAnswersRequested event,
void _onHomeSeeSourceAnswersRequested(
HomeSeeSourceAnswersRequested event,
Emitter<HomeState> emit,
) {
final indexParsed = event.index != null ? _getIndex(event.index!) : 0;
Expand All @@ -99,15 +82,8 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
);
}

void _onSeeSourceAnswers(
SeeResultsSourceAnswers event,
Emitter<HomeState> emit,
) {
emit(state.copyWith(status: Status.seeSourceAnswers));
}

void _onAddAnswerFeedback(
AddAnswerFeedback event,
void _onHomeAnswerFeedbackAdded(
HomeAnswerFeedbackAdded event,
Emitter<HomeState> emit,
) {
emit(
Expand All @@ -120,8 +96,8 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
);
}

FutureOr<void> _navigateSourceAnswers(
NavigateSourceAnswers event,
FutureOr<void> _onHomeSourceAnswersNavigated(
HomeSourceAnswersNavigated event,
Emitter<HomeState> emit,
) {
final indexParsed = _getIndex(event.index);
Expand All @@ -132,8 +108,8 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
);
}

void _onBackToAiSummaryTapped(
BackToAiSummaryTapped event,
void _onHomeBackToAiSummaryTapped(
HomeBackToAiSummaryTapped event,
Emitter<HomeState> emit,
) {
emit(state.copyWith(status: Status.sourceAnswersBackToResults));
Expand Down
57 changes: 28 additions & 29 deletions lib/home/bloc/home_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,73 @@ part of 'home_bloc.dart';

abstract class HomeEvent extends Equatable {
const HomeEvent();

@override
List<Object> get props => [];
}

class FromWelcomeToQuestion extends HomeEvent {
const FromWelcomeToQuestion();
}
class HomeNavigated extends HomeEvent {
const HomeNavigated(this.status);

final Status status;

class AskQuestion extends HomeEvent {
const AskQuestion();
@override
List<Object> get props => [status];
}

class QueryUpdated extends HomeEvent {
const QueryUpdated({required this.query});
class HomeQueryUpdated extends HomeEvent {
const HomeQueryUpdated({required this.query});

final String query;
@override
List<Object> get props => [query];
}

class QuestionAsked extends HomeEvent {
const QuestionAsked(this.submittedQuery);
class HomeQuestionAsked extends HomeEvent {
const HomeQuestionAsked(this.submittedQuery);

final String submittedQuery;

@override
List<Object> get props => [submittedQuery];
}

class QuestionAskedAgain extends HomeEvent {
const QuestionAskedAgain(this.submittedQuery);
class HomeQuestionAskedAgain extends HomeEvent {
const HomeQuestionAskedAgain(this.submittedQuery);

final String submittedQuery;

@override
List<Object> get props => [submittedQuery];
}

class Results extends HomeEvent {
const Results();
}

class SeeSourceAnswersRequested extends HomeEvent {
const SeeSourceAnswersRequested(this.index);
class HomeSeeSourceAnswersRequested extends HomeEvent {
const HomeSeeSourceAnswersRequested(this.index);

final String? index;
}

class SeeResultsSourceAnswers extends HomeEvent {
const SeeResultsSourceAnswers();
@override
List<Object?> get props => [index];
}

class AddAnswerFeedback extends HomeEvent {
const AddAnswerFeedback(this.answerFeedback);
class HomeAnswerFeedbackAdded extends HomeEvent {
const HomeAnswerFeedbackAdded(this.answerFeedback);

final AnswerFeedback answerFeedback;

@override
List<Object> get props => [answerFeedback];
}

class NavigateSourceAnswers extends HomeEvent {
const NavigateSourceAnswers(this.index);
class HomeSourceAnswersNavigated extends HomeEvent {
const HomeSourceAnswersNavigated(this.index);

final String index;

@override
List<Object?> get props => [index];
}

class BackToAiSummaryTapped extends HomeEvent {
const BackToAiSummaryTapped();
class HomeBackToAiSummaryTapped extends HomeEvent {
const HomeBackToAiSummaryTapped();

@override
List<Object?> get props => [];
}
2 changes: 1 addition & 1 deletion lib/home/widgets/question_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class QuestionViewState extends State<QuestionView>
duration: const Duration(milliseconds: 1500),
)..addStatusListener((status) {
if (status == AnimationStatus.completed) {
context.read<HomeBloc>().add(const AskQuestion());
context.read<HomeBloc>().add(const HomeNavigated(Status.askQuestion));
}
});

Expand Down
22 changes: 13 additions & 9 deletions lib/home/widgets/results_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class BlueContainerState extends State<BlueContainer>
duration: _cardEnterDuration,
)..addStatusListener((status) {
if (status == AnimationStatus.completed) {
context.read<HomeBloc>().add(const Results());
context.read<HomeBloc>().add(const HomeNavigated(Status.results));
}
});

Expand All @@ -215,12 +215,16 @@ class BlueContainerState extends State<BlueContainer>

if (status == AnimationStatus.completed &&
state.status == Status.resultsToSourceAnswers) {
context.read<HomeBloc>().add(const SeeResultsSourceAnswers());
context.read<HomeBloc>().add(
const HomeNavigated(
Status.seeSourceAnswers,
),
);
}

if (status == AnimationStatus.dismissed &&
state.status == Status.sourceAnswersBackToResults) {
context.read<HomeBloc>().add(const Results());
context.read<HomeBloc>().add(const HomeNavigated(Status.results));
}
});
}
Expand Down Expand Up @@ -416,14 +420,14 @@ class _AiResponseState extends State<_AiResponse>
FeedbackButtons(
onLike: () {
context.read<HomeBloc>().add(
const AddAnswerFeedback(
const HomeAnswerFeedbackAdded(
AnswerFeedback.good,
),
);
},
onDislike: () {
context.read<HomeBloc>().add(
const AddAnswerFeedback(
const HomeAnswerFeedbackAdded(
AnswerFeedback.bad,
),
);
Expand Down Expand Up @@ -514,13 +518,13 @@ class _SummaryViewState extends State<SummaryView>
Status.seeSourceAnswers;
if (isOnSeeSourceAnswers) {
context.read<HomeBloc>().add(
NavigateSourceAnswers(
HomeSourceAnswersNavigated(
element.text,
),
);
} else {
context.read<HomeBloc>().add(
SeeSourceAnswersRequested(
HomeSeeSourceAnswersRequested(
element.text,
),
);
Expand Down Expand Up @@ -697,7 +701,7 @@ class _BackToAnswerButtonState extends State<BackToAnswerButton>
label: l10n.backToAIAnswer,
icon: vertexIcons.arrowBack.image(color: VertexColors.white),
onPressed: () {
context.read<HomeBloc>().add(const BackToAiSummaryTapped());
context.read<HomeBloc>().add(const HomeBackToAiSummaryTapped());
},
),
),
Expand Down Expand Up @@ -760,7 +764,7 @@ class _SeeSourceAnswersButtonState extends State<SeeSourceAnswersButton>
),
onPressed: () => context
.read<HomeBloc>()
.add(const SeeSourceAnswersRequested(null)),
.add(const HomeSeeSourceAnswersRequested(null)),
),
),
);
Expand Down
6 changes: 3 additions & 3 deletions lib/home/widgets/search_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class SearchBox extends StatelessWidget {
hint: l10n.questionHint,
actionText: l10n.ask,
onTextUpdated: (String query) =>
context.read<HomeBloc>().add(QueryUpdated(query: query)),
context.read<HomeBloc>().add(HomeQueryUpdated(query: query)),
onActionPressed: () {
if (askAgain) {
context.read<HomeBloc>().add(QuestionAskedAgain(searchQuery));
context.read<HomeBloc>().add(HomeQuestionAskedAgain(searchQuery));
} else {
context.read<HomeBloc>().add(QuestionAsked(searchQuery));
context.read<HomeBloc>().add(HomeQuestionAsked(searchQuery));
}
},
text: searchQuery.isEmpty ? null : searchQuery,
Expand Down
Loading

0 comments on commit fbe90cd

Please sign in to comment.