Browse Source

add Gif

pull/51/head
AmirrezaChegini 4 hours ago
parent
commit
de2aed70e4
  1. 4
      lib/core/widgets/answer_box/answer_box.dart
  2. 2
      lib/core/widgets/answer_box/answer_box_show.dart
  3. 20
      lib/core/widgets/answer_box/styles/picture_box.dart
  4. 2
      lib/features/question/presentation/ui/screens/question_screen.dart
  5. 8
      pubspec.lock
  6. 3
      pubspec.yaml

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

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gif/gif.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_assets.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart';
import 'package:hadi_hoda_flutter/core/utils/set_platform_size.dart';
@ -15,6 +16,7 @@ class AnswerBox extends StatefulWidget {
required this.index,
this.onTap,
this.onNotifTap,
this.autostart = Autostart.no,
});
final AnswerEntity answer;
@ -22,6 +24,7 @@ class AnswerBox extends StatefulWidget {
final void Function(bool isCorrect, int correctAnswer)? onTap;
final int index;
final Function(AnswerEntity answer)? onNotifTap;
final Autostart autostart;
@override
State<AnswerBox> createState() => _AnswerBoxState();
@ -56,6 +59,7 @@ class _AnswerBoxState extends State<AnswerBox> {
index: widget.index,
image: widget.answer.image ?? '',
correctAnswer: widget.correctAnswer,
autostart: widget.autostart,
onTap: () {
widget.onNotifTap?.call(widget.answer);
},

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

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:gif/gif.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_assets.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart';
import 'package:hadi_hoda_flutter/core/utils/set_platform_size.dart';
@ -33,6 +34,7 @@ class AnswerBoxShow extends StatelessWidget {
selected: false,
index: index,
image: answer.image ?? '',
autostart: Autostart.once,
correctAnswer: 0,
),
Positioned(

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

@ -1,10 +1,12 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:gif/gif.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_assets.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_colors.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_text_style.dart';
import 'package:hadi_hoda_flutter/core/utils/screen_size.dart';
import 'package:hadi_hoda_flutter/core/utils/set_platform_size.dart';
import 'package:hadi_hoda_flutter/core/widgets/images/my_image.dart';
@ -16,6 +18,7 @@ class AnswerPictureBox extends StatelessWidget {
required this.index,
required this.correctAnswer,
this.onTap,
this.autostart = Autostart.no,
});
final bool selected;
@ -23,6 +26,7 @@ class AnswerPictureBox extends StatelessWidget {
final int index;
final int correctAnswer;
final VoidCallback? onTap;
final Autostart autostart;
@override
Widget build(BuildContext context) {
@ -41,16 +45,24 @@ class AnswerPictureBox extends StatelessWidget {
switchInCurve: Curves.linear,
switchOutCurve: Curves.linear,
child: selected && (index != correctAnswer) ?
Image.file(
Gif(
key: Key('1'),
File(image),
width: context.widthScreen,
height: context.heightScreen,
image: FileImage(File(image)),
fps: 30,
autostart: autostart,
fit: BoxFit.cover,
color: MyColors.black,
colorBlendMode: BlendMode.color,
) :
Image.file(
Gif(
key: Key('2'),
File(image),
width: context.widthScreen,
height: context.heightScreen,
image: FileImage(File(image)),
fps: 30,
autostart: autostart,
fit: BoxFit.cover,
),
transitionBuilder: (child, animation) =>

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

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gif/gif.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_assets.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_colors.dart';
import 'package:hadi_hoda_flutter/common_ui/resources/my_spaces.dart';
@ -102,6 +103,7 @@ class _QuestionScreenState extends State<QuestionScreen> with TickerProviderStat
correctAnswer: 0,
index: 0,
image: state.currentQuestion?.image ?? '',
autostart: Autostart.once,
),
),
),

8
pubspec.lock

@ -333,6 +333,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "8.2.0"
gif:
dependency: "direct main"
description:
name: gif
sha256: ade95694f1471da737922806818ffade2814d1d7f8d10af38ebcf36ace012bc0
url: "https://pub.dev"
source: hosted
version: "2.3.0"
glob:
dependency: transitive
description:

3
pubspec.yaml

@ -1,7 +1,7 @@
name: hadi_hoda_flutter
description: "A new Flutter project."
publish_to: 'none'
version: 0.1.8+1
version: 0.1.9+1
environment:
sdk: ^3.9.2
@ -20,6 +20,7 @@ dependencies:
flutter_localizations:
sdk: flutter
get_it: ^8.2.0
gif: ^2.3.0
go_router: ^16.1.0
hive: ^2.2.3
intl: ^0.20.2

Loading…
Cancel
Save