9 changed files with 236 additions and 95 deletions
-
38lib/core/routers/hero_dialog_route.dart
-
42lib/core/widgets/answer_box/answer_box.dart
-
42lib/core/widgets/answer_box/answer_box_show.dart
-
81lib/core/widgets/answer_box/styles/picture_box.dart
-
2lib/features/level/presentation/bloc/level_bloc.dart
-
49lib/features/question/presentation/bloc/question_bloc.dart
-
3lib/features/question/presentation/bloc/question_event.dart
-
53lib/features/question/presentation/ui/screens/answer_screen.dart
-
21lib/features/question/presentation/ui/screens/question_screen.dart
@ -0,0 +1,38 @@ |
|||||
|
import 'package:flutter/material.dart'; |
||||
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_colors.dart'; |
||||
|
|
||||
|
class HeroDialogRoute<T> extends PageRoute<T> { |
||||
|
HeroDialogRoute({ |
||||
|
required WidgetBuilder builder, |
||||
|
super.settings, |
||||
|
super.fullscreenDialog, |
||||
|
}) : _builder = builder; |
||||
|
|
||||
|
final WidgetBuilder _builder; |
||||
|
|
||||
|
@override |
||||
|
bool get opaque => false; |
||||
|
|
||||
|
@override |
||||
|
bool get fullscreenDialog => false; |
||||
|
|
||||
|
@override |
||||
|
bool get barrierDismissible => false; |
||||
|
|
||||
|
@override |
||||
|
Duration get transitionDuration => const Duration(milliseconds: 300); // Adjust as needed |
||||
|
|
||||
|
@override |
||||
|
bool get maintainState => true; |
||||
|
|
||||
|
@override |
||||
|
Color get barrierColor => MyColors.transparent; // Or your desired barrier color |
||||
|
|
||||
|
@override |
||||
|
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) { |
||||
|
return _builder(context); |
||||
|
} |
||||
|
|
||||
|
@override |
||||
|
String get barrierLabel => ''; |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
import 'package:flutter/material.dart'; |
||||
|
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/widgets/answer_box/styles/picture_box.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/widgets/answer_box/styles/text_box.dart'; |
||||
|
import 'package:hadi_hoda_flutter/features/question/domain/entity/answer_entity.dart'; |
||||
|
|
||||
|
class AnswerBoxShow extends StatelessWidget { |
||||
|
const AnswerBoxShow({ |
||||
|
super.key, |
||||
|
required this.answer, |
||||
|
required this.index, |
||||
|
this.correct, |
||||
|
}); |
||||
|
|
||||
|
final AnswerEntity answer; |
||||
|
final int index; |
||||
|
final bool? correct; |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
return Stack( |
||||
|
alignment: Alignment.bottomCenter, |
||||
|
clipBehavior: Clip.none, |
||||
|
children: [ |
||||
|
AnswerPictureBox( |
||||
|
selected: correct ?? false, |
||||
|
index: index, |
||||
|
image: answer.image ?? '', |
||||
|
correctAnswer: index, |
||||
|
), |
||||
|
Positioned( |
||||
|
left: 0, |
||||
|
right: 0, |
||||
|
bottom: -MySpaces.s26, |
||||
|
child: AnswerTextBox( |
||||
|
text: answer.title ?? '', |
||||
|
), |
||||
|
), |
||||
|
], |
||||
|
); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
import 'package:flutter/material.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/utils/context_provider.dart'; |
||||
|
import 'package:hadi_hoda_flutter/core/widgets/answer_box/answer_box_show.dart'; |
||||
|
import 'package:hadi_hoda_flutter/features/question/domain/entity/answer_entity.dart'; |
||||
|
|
||||
|
class AnswerScreen extends StatefulWidget { |
||||
|
const AnswerScreen({super.key, required this.answerEntity, this.correct}); |
||||
|
|
||||
|
final AnswerEntity answerEntity; |
||||
|
final bool? correct; |
||||
|
|
||||
|
@override |
||||
|
State<AnswerScreen> createState() => _AnswerScreenState(); |
||||
|
} |
||||
|
|
||||
|
class _AnswerScreenState extends State<AnswerScreen> { |
||||
|
@override |
||||
|
void initState() { |
||||
|
super.initState(); |
||||
|
back(); |
||||
|
} |
||||
|
|
||||
|
Future<void> back() async { |
||||
|
await Future.delayed(Duration(seconds: 2), () { |
||||
|
if (ContextProvider.context.mounted) { |
||||
|
Navigator.pop(ContextProvider.context); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
return Center( |
||||
|
child: Hero( |
||||
|
tag: 'Hero_answer_${widget.answerEntity.id}', |
||||
|
createRectTween: (begin, end) => MaterialRectArcTween(begin: begin, end: end), |
||||
|
flightShuttleBuilder: (flightContext, animation, flightDirection, |
||||
|
fromHeroContext, toHeroContext) => toHeroContext.widget, |
||||
|
child: Transform.scale( |
||||
|
scale: 2, |
||||
|
child: Material( |
||||
|
type: MaterialType.transparency, |
||||
|
child: AnswerBoxShow( |
||||
|
answer: widget.answerEntity, |
||||
|
index: widget.answerEntity.order ?? 0, |
||||
|
correct: widget.correct, |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
); |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue