LCOV - code coverage report
Current view: top level - lib/pages/home/widgets/streak widgets - streak_calendar_preview.dart Coverage Total Hit
Test: lcov.info Lines: 0.0 % 29 0
Test Date: 2025-05-10 20:26:13 Functions: - 0 0

            Line data    Source code
       1              : import 'dart:math';
       2              : import 'package:amadeus_proto/api/models/profile.dart';
       3              : import 'package:amadeus_proto/pages/home/widgets/streak%20widgets/streak_container.dart';
       4              : import 'package:flutter/material.dart';
       5              : 
       6              : class StreakCalendarPreview extends StatelessWidget {
       7            0 :   const StreakCalendarPreview({
       8              :     super.key, required this.user,
       9              : 
      10              :   });
      11              : 
      12              :   final Profile user;
      13              : 
      14            0 :   @override
      15              :   Widget build(BuildContext context) {
      16            0 :     final DateTime now = DateTime.now();
      17              : 
      18            0 :     final List<DateTime> daysInMonth = List.generate(
      19              :       // Number of days in the current month
      20            0 :       DateTime(now.year, now.month + 1, 0).day,
      21            0 :       (index) => DateTime(now.year, now.month, index + 1),
      22              :     );
      23              : 
      24              :     // Start two days before the current day, 1 if it's the 2nd and at the current day if it's the 1st
      25              :     final int startIndex =
      26            0 :         now.day - 3 >= 0 ? now.day - 3 : max(now.day - 2, now.day - 1);
      27              : 
      28            0 :     final List<DateTime> streakedDays = user.streakDays;
      29              : 
      30            0 :     return LayoutBuilder(
      31            0 :       builder: (context, constraints) => Center(
      32            0 :         child: SizedBox(
      33            0 :           height: constraints.maxWidth / 6,
      34            0 :           child: ListView.builder(
      35              :             scrollDirection: Axis.horizontal,
      36            0 :             itemCount: daysInMonth.length,
      37            0 :             controller: ScrollController(
      38            0 :               initialScrollOffset: startIndex * (constraints.maxWidth / 6),
      39              :             ),
      40            0 :             itemBuilder: (context, index) {
      41            0 :               DateTime day = daysInMonth[index];
      42            0 :               return SizedBox(
      43            0 :                 width: MediaQuery.of(context).size.width / 6,
      44            0 :                 child: Padding(
      45              :                   padding: const EdgeInsets.all(1.5),
      46            0 :                   child: StreakContainer(
      47              :                     size: 40,
      48            0 :                     streaked: streakedDays.any((streakedDay) =>
      49            0 :                         streakedDay.year == day.year &&
      50            0 :                         streakedDay.month == day.month &&
      51            0 :                         streakedDay.day == day.day),
      52            0 :                     nonStreakWidget: Center(
      53            0 :                       child: Text(
      54            0 :                         "${day.day}",
      55              :                         style: const TextStyle(
      56              :                           color: Colors.white,
      57              :                           fontWeight: FontWeight.bold,
      58              :                           height: 1.1,
      59              :                           fontSize: 20,
      60              :                         ),
      61              :                       ),
      62              :                     ),
      63              :                   ),
      64              :                 ),
      65              :               );
      66              :             },
      67              :           ),
      68              :         ),
      69              :       ),
      70              :     );
      71              :   }
      72              : }
        

Generated by: LCOV version 2.3-1