LCOV - code coverage report
Current view: top level - lib/exercises/categories/reading/note_reading - note_reading_page.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 60 0
Test Date: 2025-05-10 20:26:13 Functions: - 0 0

            Line data    Source code
       1              : import 'package:amadeus_proto/constants.dart';
       2              : import 'package:amadeus_proto/exercises/exercise_question.dart';
       3              : import 'package:amadeus_proto/exercises/load_json.dart';
       4              : import 'package:amadeus_proto/exercises/providers/single_choice_provider.dart';
       5              : import 'package:amadeus_proto/exercises/types/single_choice.dart';
       6              : import 'package:amadeus_proto/exercises/widget/animation_dialog_wrapper.dart';
       7              : import 'package:amadeus_proto/exercises/widget/exercise_header.dart';
       8              : import 'package:amadeus_proto/exercises/widget/exercises_end_dialog.dart';
       9              : import 'package:amadeus_proto/api/models/exercise_info.dart';
      10              : import 'package:amadeus_proto/widget/progress_bar.dart';
      11              : import 'package:flutter/material.dart';
      12              : import 'package:provider/provider.dart';
      13              : 
      14              : class ReadingExercise extends StatefulWidget {
      15            0 :   const ReadingExercise({super.key, required this.info});
      16              : 
      17              :   final ExerciseInfo info;
      18              : 
      19            0 :   @override
      20            0 :   State<ReadingExercise> createState() => _ReadingExerciseState();
      21              : }
      22              : 
      23              : class _ReadingExerciseState extends State<ReadingExercise> {
      24              :   final String filepath = "assets/FigmaDesign/Asset/Partition/reading.xml";
      25              : 
      26            0 :   @override
      27              :   void initState() {
      28            0 :     super.initState();
      29            0 :     WidgetsBinding.instance.addPostFrameCallback((_) {
      30            0 :       context.read<SingleChoiceProvider>().reset();
      31              :     });
      32              :   }
      33              : 
      34              :   /// The implementation of [ReadingExercise.build]
      35              :   ///
      36              :   /// The build is composed by a FutureBuilder that will wait for the data
      37              :   /// from the [loadJsonData] asynchronous function to collect the data
      38              :   /// from the specific JSON file
      39              :   ///
      40              :   /// This widget display an reading exercise with a header [ExerciseHeader],
      41              :   /// a description [ExerciseDescription], an image that correspond to the
      42              :   /// actual question, and finally a [SingleChoiceExercise] with multiples
      43              :   /// choices.
      44              :   /// All those is data, is initialize by the corresponding JSON file and is
      45              :   /// load by the corresponding [ExerciseProvider], in this case, the provider
      46              :   /// is [SingleChoiceProvider]
      47            0 :   @override
      48              :   Widget build(BuildContext context) {
      49            0 :     final SingleChoiceProvider reading = context.watch<SingleChoiceProvider>();
      50              : 
      51            0 :     WidgetsBinding.instance.addPostFrameCallback((_) {
      52            0 :       if (!reading.isInitialized) {
      53            0 :         reading.initializeData(widget.info.exerciseData);
      54            0 :         reading.exerciseInfo = widget.info;
      55              :       }
      56            0 :       if (!reading.displayDialog && reading.checkEndGame()) {
      57            0 :         reading.displayDialog = true;
      58            0 :         Future.delayed(Duration.zero, () {
      59            0 :           if (!context.mounted) return;
      60            0 :           showGeneralDialog(
      61              :               context: context,
      62              :               transitionDuration: const Duration(milliseconds: fastAnimation),
      63            0 :               pageBuilder: (context, animation1, animation2) {
      64            0 :                 return ExerciseEndDialog<SingleChoiceProvider>(
      65            0 :                   leavingExerciseCallback: () {
      66            0 :                     Navigator.of(context).pop();
      67            0 :                     Navigator.of(context).pop();
      68              :                   },
      69            0 :                   resetExerciseCallback: () {
      70            0 :                     Navigator.of(context).pop();
      71            0 :                     Future.delayed(const Duration(milliseconds: fastAnimation),
      72            0 :                         () {
      73            0 :                       if (mounted) {
      74            0 :                         reading.reset();
      75              :                       }
      76              :                     });
      77              :                   },
      78            0 :                   exerciseTitle: widget.info.exerciseData!["title"],
      79            0 :                   exerciseCategory: widget.info.exerciseData!["category"],
      80              :                 );
      81              :               },
      82              :               transitionBuilder:
      83            0 :                   (context, animation, secondaryAnimation, child) {
      84            0 :                 return ScaleTransition(
      85              :                   scale: animation,
      86            0 :                   child: AnimatedDialogWrapper(
      87              :                     animation: animation,
      88              :                     child: child,
      89              :                   ),
      90              :                 );
      91              :               });
      92              :         });
      93              :       }
      94              :     });
      95              : 
      96            0 :     return Scaffold(
      97              :       // backgroundColor: Colors.white,
      98            0 :       body: SafeArea(
      99            0 :         child: Column(children: [
     100            0 :           if (reading.isInitialized)
     101            0 :             const ExerciseHeader<SingleChoiceProvider>(),
     102            0 :           const SizedBox(
     103              :             height: 10,
     104              :           ),
     105            0 :           if (reading.isInitialized)
     106            0 :             ProgressBar(
     107            0 :                 totalAmount: reading.questions.length,
     108            0 :                 progressAmount: reading.progress,
     109              :                 width: 300,
     110              :                 height: 15),
     111            0 :           const SizedBox(
     112              :             height: 10,
     113              :           ),
     114            0 :           if (reading.isInitialized)
     115            0 :             const ExerciseQuestion<SingleChoiceProvider>(),
     116            0 :           if (reading.isInitialized)
     117            0 :             Container(
     118              :                 width: 350,
     119            0 :                 decoration: BoxDecoration(
     120            0 :                     color: Colors.grey.withOpacity(0.1),
     121            0 :                     border: Border.all(
     122              :                       width: 0.3,
     123            0 :                       color: Colors.grey.shade500,
     124              :                     ),
     125            0 :                     borderRadius: BorderRadius.circular(smallBorderRadius)),
     126            0 :                 child: Center(
     127            0 :                   child: Image(
     128            0 :                     image: AssetImage(reading.questions[reading.answer]),
     129              :                     width: imageAssetWidth,
     130              :                     height: imageAssetHeight,
     131              :                   ),
     132              :                 )),
     133            0 :           const SizedBox(
     134              :             height: 35,
     135              :           ),
     136            0 :           if (reading.isInitialized)
     137            0 :             const Expanded(
     138              :               child: SingleChoiceExercise<SingleChoiceProvider>(),
     139              :             ),
     140              :         ]),
     141              :       ),
     142              :     );
     143              :   }
     144              : }
        

Generated by: LCOV version 2.3-1