Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header Month Information Not Updating While Scrolling #25

Open
yagizdo opened this issue Feb 27, 2024 · 3 comments
Open

Header Month Information Not Updating While Scrolling #25

yagizdo opened this issue Feb 27, 2024 · 3 comments

Comments

@yagizdo
Copy link
Contributor

yagizdo commented Feb 27, 2024

I've encountered an issue where the month information in the header remains unchanged while scrolling. Within the header builder, I'm only displaying the month name, such as "February", for instance. However, when I scroll to March, for example, the displayed month doesn't update accordingly. It seems that the date value within the header builder remains static, causing the displayed month to stay fixed.

Is there a solution to this problem?

Calendar View :

import 'package:easy_date_timeline/easy_date_timeline.dart';
import 'package:flutter/material.dart';

import '../../../../../widgets/main_widgets/main_appbar.dart';
import '../../../../../widgets/main_widgets/main_layout.dart';
import '../widget/date_card.dart';
import '../widget/date_header.dart';
import '../widget/day_schedule_comp.dart';

class CalendarView extends StatelessWidget {
  const CalendarView({super.key});

  @override
  Widget build(BuildContext context) {
    return MainLayout(
      content: context.isLittlePhone
          ? smallPhoneLayout(context)
          : context.isMiddlePhone
              ? middlePhoneLayout(context)
              : bigPhoneLayout(context),
    );
  }

  Widget bigPhoneLayout(BuildContext context) {
    return _buildBody(context);
  }

  Widget middlePhoneLayout(BuildContext context) {
    return _buildBody(context);
  }

  Widget smallPhoneLayout(BuildContext context) {
    return _buildBody(context);
  }

  Widget _buildBody(BuildContext context) {
    return Column(children: [
      const MainAppBar(
        title: "Takvim",
        isDetail: true,
      ),
      Expanded(child: _buildContent(context)),
    ]);
  }

  Widget _buildContent(BuildContext context) {
    final EasyInfiniteDateTimelineController controller =
        EasyInfiniteDateTimelineController();
    return Padding(
      padding: EdgeInsets.only(
        top: context.screenWidth * 0.02,
        left: context.screenWidth * 0.04,
        right: context.screenWidth * 0.04,
      ),
      child: Column(
        children: [
          EasyInfiniteDateTimeLine(
            controller: controller,
            firstDate: DateTime(2024),
            focusDate: DateTime.now(),
            lastDate: DateTime(2099, 12, 31),
            showTimelineHeader: true,
            autoCenter: true,
            dayProps: EasyDayProps(
              height: context.screenWidth * 0.24,
            ),
            headerBuilder: (context, date) {
              return DateHeader(
                date: date,
              );
            },
            itemBuilder: (
              context,
              String dayNumber,
              String dayName,
              String monthName,
              DateTime fullDate,
              bool isSelected,
            ) {
              return DateCard(
                dayNumber: dayNumber,
                dayName: dayName,
                monthName: monthName,
                fullDate: fullDate,
                isSelected: isSelected,
              );
            },
            onDateChange: (selectedDate) {},
          ),
          const Expanded(child: DayScheduleComp()),
        ],
      ),
    );
  }
}

Date Header :

import 'package:flutter/material.dart';

import '../../../../../utils/app_constants.dart';
import '../../../../../utils/app_textstyles.dart';

class DateHeader extends StatelessWidget {
  const DateHeader({super.key, required this.date});

  final DateTime date;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.only(
        bottom: context.screenWidth * 0.02,
      ),
      child: Text(
        monthNameMap[date.month] ?? "",
        style: AppTextStyle.dateHeader(context),
      ),
    );
  }
}

@yagizdo
Copy link
Contributor Author

yagizdo commented Mar 8, 2024

@FadyFayezYounan Do you have any suggestions?

@FadyFayezYounan
Copy link
Owner

@yagizdo I will update the package now and take a look at this issue,

@yagizdo
Copy link
Contributor Author

yagizdo commented Mar 8, 2024

Thank you, I'm looking forward to it. If I can solve it, I will open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants