29 changed files with 610 additions and 149 deletions
-
3android/app/src/main/AndroidManifest.xml
-
12lib/core/services/audio_service.dart
-
161lib/core/widgets/animations/smart_gif.dart
-
7lib/core/widgets/answer_box/styles/image_box.dart
-
335lib/core/widgets/answer_box/styles/picture_box.dart
-
3lib/core/widgets/images/my_image.dart
-
25lib/features/download/data/datasource/download_datasource.dart
-
58lib/features/intro/presentation/bloc/intro_bloc.dart
-
32lib/features/intro/presentation/ui/intro_page.dart
-
9lib/features/language/presentation/ui/language_page.dart
-
7lib/features/level/data/datasource/level_datasource.dart
-
36lib/features/level/presentation/bloc/level_bloc.dart
-
4lib/features/level/presentation/ui/level_page.dart
-
6lib/features/question/domain/entity/question_entity.dart
-
19lib/features/question/presentation/bloc/question_bloc.dart
-
4lib/features/question/presentation/ui/question_page.dart
-
14lib/features/question/presentation/ui/screens/question_screen.dart
-
3lib/l10n/app_ar.arb
-
3lib/l10n/app_de.arb
-
3lib/l10n/app_fr.arb
-
2lib/l10n/app_localizations_ar.dart
-
2lib/l10n/app_localizations_de.dart
-
2lib/l10n/app_localizations_fr.dart
-
2lib/l10n/app_localizations_ru.dart
-
2lib/l10n/app_localizations_tr.dart
-
1lib/l10n/app_ru.arb
-
1lib/l10n/app_tr.arb
-
2lib/main.dart
-
1pubspec.yaml
@ -0,0 +1,161 @@ |
|||
import 'dart:io'; |
|||
import 'package:flutter/material.dart'; |
|||
import 'package:gif/gif.dart'; |
|||
import 'package:image/image.dart' as img; |
|||
|
|||
|
|||
class SmartGif extends StatefulWidget { |
|||
final String gifPath; |
|||
final Autostart autoStart; |
|||
final BoxFit fit; |
|||
final int? cacheWidth; |
|||
final Color? color; |
|||
final BlendMode? colorBlendMode; |
|||
|
|||
const SmartGif({ |
|||
super.key, |
|||
required this.gifPath, |
|||
required this.autoStart, |
|||
this.fit = BoxFit.cover, |
|||
this.cacheWidth, |
|||
this.color, |
|||
this.colorBlendMode, |
|||
}); |
|||
|
|||
@override |
|||
State<SmartGif> createState() => SmartGifState(); |
|||
} |
|||
|
|||
class SmartGifState extends State<SmartGif> |
|||
with SingleTickerProviderStateMixin { |
|||
late GifController _gifController; |
|||
// bool _isPlaying = false; |
|||
// ImageProvider? _gifProvider; |
|||
|
|||
@override |
|||
void initState() { |
|||
super.initState(); |
|||
// _provideGif(); |
|||
_gifController = GifController(vsync: this); |
|||
// _isPlaying = widget.autoStart; |
|||
debugPrint("SmartGif initState: gifPath=${widget.gifPath}, autoStart=${widget.autoStart}"); |
|||
|
|||
// if (_isPlaying) { |
|||
// debugPrint("SmartGif: starting animation in initState"); |
|||
// _gifController.repeat( |
|||
// min: 0, |
|||
// max: 1, |
|||
// period: const Duration(milliseconds: 1000), // Default speed |
|||
// ); |
|||
// } else { |
|||
// _gifController.value = 0; |
|||
// } |
|||
} |
|||
|
|||
// void _provideGif() async { |
|||
// final file = ; |
|||
// final bytes = await file.readAsBytes(); |
|||
// final gif = img.decodeGif(bytes); |
|||
// |
|||
// // resize frames |
|||
// final resized = img.copyResize(gif!, width: 300); |
|||
// |
|||
// // save temp file |
|||
// final newFile = File('${widget.gifPath}-resized.gif')..writeAsBytesSync(img.encodeGif(resized)); |
|||
// if(mounted) { |
|||
// setState(() { |
|||
// _gifProvider = FileImage(newFile); |
|||
// }); |
|||
// } |
|||
// } |
|||
|
|||
// @override |
|||
// void didUpdateWidget(covariant SmartGif oldWidget) { |
|||
// super.didUpdateWidget(oldWidget); |
|||
// |
|||
// if (oldWidget.gifPath != widget.gifPath) { |
|||
// _isPlaying = widget.autoStart; |
|||
// if (_isPlaying) { |
|||
// _gifController.repeat(); |
|||
// } else { |
|||
// _gifController.stop(); |
|||
// _gifController.value = 0; |
|||
// } |
|||
// } else if (oldWidget.autoStart != widget.autoStart) { |
|||
// if (widget.autoStart) { |
|||
// start(); |
|||
// } else { |
|||
// stop(); |
|||
// } |
|||
// } |
|||
// } |
|||
|
|||
@override |
|||
void dispose() { |
|||
_gifController.stop(); |
|||
_gifController.dispose(); |
|||
super.dispose(); |
|||
} |
|||
|
|||
// void start() { |
|||
// if (!mounted) return; |
|||
// setState(() { |
|||
// // _isPlaying = true; |
|||
// _gifController.repeat(); |
|||
// }); |
|||
// } |
|||
|
|||
// void stop() { |
|||
// if (!mounted) return; |
|||
// setState(() { |
|||
// // _isPlaying = false; |
|||
// _gifController.stop(); |
|||
// _gifController.value = 0; // Show first frame |
|||
// }); |
|||
// } |
|||
// |
|||
// void restart() { |
|||
// if (!mounted) return; |
|||
// setState(() { |
|||
// // _isPlaying = true; |
|||
// _gifController.value = 0; |
|||
// _gifController.repeat(); |
|||
// }); |
|||
// } |
|||
|
|||
@override |
|||
Widget build(BuildContext context) { |
|||
// bool showPreview = !_isPlaying; |
|||
// bool hasPreview = |
|||
// widget.previewPath != null && File(widget.previewPath!).existsSync(); |
|||
// |
|||
// if (showPreview && hasPreview) { |
|||
// return Image.file( |
|||
// File(widget.previewPath!), |
|||
// fit: widget.fit, |
|||
// cacheWidth: widget.cacheWidth, |
|||
// color: widget.color, |
|||
// colorBlendMode: widget.colorBlendMode, |
|||
// gaplessPlayback: true, |
|||
// ); |
|||
// } |
|||
// |
|||
// debugPrint("SmartGif build: _isPlaying=$_isPlaying, hasPreview=$hasPreview"); |
|||
|
|||
// 🔴 PLAY/STOPPED GIF (using controller for frame control) |
|||
// final ImageProvider imageProvider = FileImage(File(widget.gifPath)); |
|||
// final ImageProvider finalProvider = widget.cacheWidth != null |
|||
// ? ResizeImage(imageProvider, width: widget.cacheWidth) |
|||
// : imageProvider; |
|||
return RepaintBoundary( |
|||
child: Gif( |
|||
image: FileImage(File(widget.gifPath)), |
|||
controller: _gifController, |
|||
autostart: widget.autoStart, |
|||
fit: widget.fit, |
|||
color: widget.color, |
|||
colorBlendMode: widget.colorBlendMode, |
|||
), |
|||
); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue