This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
510 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:bloc/bloc.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
|
||
part 'home_event.dart'; | ||
part 'home_state.dart'; | ||
|
||
class HomeBloc extends Bloc<HomeEvent, HomeState> { | ||
HomeBloc() : super(const HomeState()) { | ||
on<FromWelcomeToQuestion>(_onFromWelcomeToQuestion); | ||
on<AskQuestion>(_onQuestion); | ||
} | ||
|
||
Future<void> _onFromWelcomeToQuestion( | ||
FromWelcomeToQuestion event, | ||
Emitter<HomeState> emit, | ||
) async { | ||
emit(state.copyWith(status: Status.welcomeToAskQuestion)); | ||
} | ||
|
||
Future<void> _onQuestion( | ||
AskQuestion event, | ||
Emitter<HomeState> emit, | ||
) async { | ||
emit(state.copyWith(status: Status.askQuestion)); | ||
} | ||
} |
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,16 @@ | ||
part of 'home_bloc.dart'; | ||
|
||
abstract class HomeEvent extends Equatable { | ||
const HomeEvent(); | ||
|
||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
class FromWelcomeToQuestion extends HomeEvent { | ||
const FromWelcomeToQuestion(); | ||
} | ||
|
||
class AskQuestion extends HomeEvent { | ||
const AskQuestion(); | ||
} |
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,27 @@ | ||
part of 'home_bloc.dart'; | ||
|
||
enum Status { welcome, welcomeToAskQuestion, askQuestion } | ||
|
||
class HomeState extends Equatable { | ||
const HomeState({ | ||
this.status = Status.welcome, | ||
}); | ||
|
||
final Status status; | ||
|
||
bool get isWelcomeVisible => | ||
status == Status.welcome || status == Status.welcomeToAskQuestion; | ||
bool get isQuestionVisible => | ||
status == Status.welcomeToAskQuestion || status == Status.askQuestion; | ||
|
||
HomeState copyWith({ | ||
Status? status, | ||
}) { | ||
return HomeState( | ||
status: status ?? this.status, | ||
); | ||
} | ||
|
||
@override | ||
List<Object> get props => [status]; | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export 'bloc/home_bloc.dart'; | ||
export 'view/home_page.dart'; | ||
export 'widgets/widgets.dart'; |
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,43 @@ | ||
import 'package:app_ui/app_ui.dart'; | ||
import 'package:dash_ai_search/home/home.dart'; | ||
import 'package:dash_ai_search/l10n/l10n.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
class QuestionView extends StatelessWidget { | ||
const QuestionView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
final l10n = context.l10n; | ||
|
||
final state = context.watch<HomeBloc>().state; | ||
final isAnimating = state.status == Status.welcomeToAskQuestion; | ||
|
||
return AnimatedOpacity( | ||
opacity: isAnimating ? 1 : 0, | ||
duration: const Duration(milliseconds: 500), | ||
child: Center( | ||
child: SingleChildScrollView( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text( | ||
l10n.questionScreenTitle, | ||
textAlign: TextAlign.center, | ||
style: theme.textTheme.displayLarge, | ||
), | ||
const SizedBox(height: 40), | ||
QuestionInputTextField( | ||
icon: vertexIcons.stars.image(), | ||
hint: l10n.questionHint, | ||
actionText: l10n.ask, | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export 'background.dart'; | ||
export 'logo.dart'; | ||
export 'question_view.dart'; | ||
export 'welcome_view.dart'; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Oops, something went wrong.