Browse Source

مشکلات انیمیشن هادی و هدی

pull/60/head
AmirrezaChegini 1 week ago
parent
commit
5514e8510c
  1. 2
      lib/core/widgets/answer_box/answer_box_show.dart
  2. 4
      lib/core/widgets/answer_box/styles/picture_box.dart
  3. 4
      lib/features/question/presentation/bloc/question_bloc.dart
  4. 67
      lib/features/question/presentation/ui/screens/question_screen.dart

2
lib/core/widgets/answer_box/answer_box_show.dart

@ -34,7 +34,7 @@ class AnswerBoxShow extends StatelessWidget {
selected: false, selected: false,
index: index, index: index,
image: answer.image ?? '', image: answer.image ?? '',
autostart: Autostart.once,
autostart: Autostart.loop,
correctAnswer: 0, correctAnswer: 0,
), ),
Positioned( Positioned(

4
lib/core/widgets/answer_box/styles/picture_box.dart

@ -52,7 +52,7 @@ class AnswerPictureBox extends StatelessWidget {
width: context.widthScreen, width: context.widthScreen,
height: context.heightScreen, height: context.heightScreen,
image: FileImage(File(image)), image: FileImage(File(image)),
fps: 30,
fps: 25,
autostart: autostart, autostart: autostart,
fit: BoxFit.cover, fit: BoxFit.cover,
color: MyColors.black, color: MyColors.black,
@ -63,7 +63,7 @@ class AnswerPictureBox extends StatelessWidget {
width: context.widthScreen, width: context.widthScreen,
height: context.heightScreen, height: context.heightScreen,
image: FileImage(File(image)), image: FileImage(File(image)),
fps: 30,
fps: 25,
autostart: autostart, autostart: autostart,
fit: BoxFit.cover, fit: BoxFit.cover,
), ),

4
lib/features/question/presentation/bloc/question_bloc.dart

@ -45,6 +45,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
_backgroundAudioService.dispose(); _backgroundAudioService.dispose();
answerAnimationController.dispose(); answerAnimationController.dispose();
imageAnimationController.dispose(); imageAnimationController.dispose();
scrollController.dispose();
return super.close(); return super.close();
} }
@ -76,6 +77,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
final AudioService _effectAudioService; final AudioService _effectAudioService;
late final AnimationController answerAnimationController; late final AnimationController answerAnimationController;
late final AnimationController imageAnimationController; late final AnimationController imageAnimationController;
final ScrollController scrollController = ScrollController();
/// ------------Functions------------ /// ------------Functions------------
// void startScrollTitle({Duration? audioDuration}) { // void startScrollTitle({Duration? audioDuration}) {
@ -192,6 +194,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
} }
Future<void> getNextLevelEvent({required BuildContext context}) async { Future<void> getNextLevelEvent({required BuildContext context}) async {
_backgroundAudioService.dispose();
await _getNextLevelUseCase(QuestionParams()).then((value) => value.fold( await _getNextLevelUseCase(QuestionParams()).then((value) => value.fold(
(data) { (data) {
context.pushNamed( context.pushNamed(
@ -293,6 +296,7 @@ class QuestionBloc extends Bloc<QuestionEvent, QuestionState> {
answerAnimationController.reverse(); answerAnimationController.reverse();
await Future.delayed(const Duration(seconds: 1)); await Future.delayed(const Duration(seconds: 1));
imageAnimationController.forward(); imageAnimationController.forward();
scrollController.jumpTo(0);
await playQuestionAudio(); await playQuestionAudio();
imageAnimationController.reverse(); imageAnimationController.reverse();
answerAnimationController.forward().then((value) { answerAnimationController.forward().then((value) {

67
lib/features/question/presentation/ui/screens/question_screen.dart

@ -91,28 +91,30 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat
} }
Widget _questionImage(BuildContext context) { Widget _questionImage(BuildContext context) {
return Column(
children: [
const Spacer(),
BlocBuilder<QuestionBloc, QuestionState>(
builder: (context, state) => FadeAnimDelayed(
duration: const Duration(seconds: 1),
child: FadeAnimController(
key: Key('${state.currentQuestion?.image}'),
controller: context.read<QuestionBloc>().imageAnimationController,
child: AnswerPictureBox(
return FadeAnimDelayed(
duration: const Duration(seconds: 1),
child: FadeAnimController(
controller: context.read<QuestionBloc>().imageAnimationController,
child: Column(
children: [
10.0.gapHeight,
_titles(context),
const Spacer(),
BlocBuilder<QuestionBloc, QuestionState>(
builder: (context, state) => AnswerPictureBox(
key: Key('${state.currentQuestion?.image}'),
selected: false, selected: false,
showIndex: false, showIndex: false,
correctAnswer: 0, correctAnswer: 0,
index: 0, index: 0,
image: state.currentQuestion?.image ?? '', image: state.currentQuestion?.image ?? '',
autostart: Autostart.once,
autostart: Autostart.loop,
), ),
), ),
),
const Spacer(),
],
), ),
const Spacer(),
],
),
); );
} }
@ -132,30 +134,33 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat
Widget _titles(BuildContext context) { Widget _titles(BuildContext context) {
return BlocBuilder<QuestionBloc, QuestionState>( return BlocBuilder<QuestionBloc, QuestionState>(
buildWhen: (previous, current) => buildWhen: (previous, current) =>
previous.currentQuestion?.id != current.currentQuestion?.id,
builder: (context, state) => FadeAnimController(
controller: context.read<QuestionBloc>().answerAnimationController,
child: Text(
state.currentQuestion?.title ?? '',
textAlign: TextAlign.center,
style: MYTextStyle.titr1.copyWith(
shadows: [
BoxShadow(
offset: const Offset(0, 2),
color: MyColors.black.withValues(alpha: 0.25),
),
],
previous.currentQuestion?.id != current.currentQuestion?.id,
builder: (context, state) =>
Text(
state.currentQuestion?.title ?? '',
textAlign: TextAlign.center,
style: MYTextStyle.titr1.copyWith(
shadows: [
BoxShadow(
offset: const Offset(0, 2),
color: MyColors.black.withValues(alpha: 0.25),
),
],
),
), ),
),
),
); );
} }
Widget _answers(BuildContext context) { Widget _answers(BuildContext context) {
return ListView( return ListView(
controller: context.read<QuestionBloc>().scrollController,
padding: const EdgeInsets.only(top: 10),
children: [ children: [
_titles(context),
30.0.gapHeight,
FadeAnimController(
controller: context.read<QuestionBloc>().answerAnimationController,
child: _titles(context),
),
50.0.gapHeight,
BlocBuilder<QuestionBloc, QuestionState>( BlocBuilder<QuestionBloc, QuestionState>(
buildWhen: (previous, current) => buildWhen: (previous, current) =>
previous.currentQuestion?.id != current.currentQuestion?.id, previous.currentQuestion?.id != current.currentQuestion?.id,

Loading…
Cancel
Save