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

startHour in WeekView Causing Incorrect Display of Quarter Hours #387

Closed
MDeLuise opened this issue Jul 5, 2024 · 4 comments · Fixed by #404
Closed

startHour in WeekView Causing Incorrect Display of Quarter Hours #387

MDeLuise opened this issue Jul 5, 2024 · 4 comments · Fixed by #404
Labels
bug Something isn't working priority:1 Bug/Enhancement with highest priority.

Comments

@MDeLuise
Copy link

MDeLuise commented Jul 5, 2024

Hi all

Description

I am experiencing an issue with the WeekView widget where the quarter hours are not displayed correctly when the startHour property is set.

Code

Here is the relevant portion of my code:

WeekView(
  controller: widget.env.eventController,
  onPageChange: (date, page) async => _fetchEvents(date),
  showLiveTimeLineInAllDays: true,
  minDay: DateTime(2024),
  heightPerMinute: 1.3,
  showHalfHours: true,
  showQuarterHours: true,
  eventArranger: const SideEventArranger(),
  onEventTap: (events, date) => print(events),
  onEventDoubleTap: (events, date) => print(events),
  onDateLongPress: (date) => print(date),
  startDay: WeekDays.monday,
  //startHour: 7,
  hourIndicatorSettings: HourIndicatorSettings(),
  endHour: 20,
  showVerticalLines: true,
  fullDayHeaderTitle: 'All day',
  fullDayHeaderTextConfig: const FullDayHeaderTextConfig(
    textAlign: TextAlign.center,
    textOverflow: TextOverflow.ellipsis,
    maxLines: 2,
  ),
  keepScrollOffset: true,
)

Problem

The quarter-hour indicators are displayed correctly when the startHour property is not set. However, when I set startHour: 7, the quarter hours are not displayed correctly. They appear to start from 12:15 instead of 7:00.

Visualization

I have attached an image to illustrate the issue:
Screenshot 2024-07-05 at 18 37 57

Steps to Reproduce

  1. Use the WeekView widget.
  2. Set the startHour property to any value (e.g., startHour: 7).
  3. Enable showQuarterHours: true.

Expected Behavior

The quarter-hour indicators should start displaying from the set startHour (e.g., 7:00) and not from 12:15.

Environment

  • Flutter version: 3.19.2
  • calendar_view version: 1.2.0
@DonnyDevIT
Copy link

DonnyDevIT commented Jul 30, 2024

Same to me. for now I fixed by this until release fix:

Widget _timeLineBuilder(BuildContext context, DateTime date) {
    if (date.minute == 15 || date.minute == 45) {
      date = date.add(Duration(hours: startHour));
      return Stack(
        clipBehavior: Clip.none,
        children: [
          Positioned.fill(
            top: -8,
            right: 8,
            child: Text(
              "${date.hour}:${date.minute}",
              textAlign: TextAlign.right,
              style: TextStyle(
                color: Theme.of(context).colorScheme.onSurface.withAlpha(50),
                fontStyle: FontStyle.italic,
                fontSize: 12,
              ),
            ),
          ),
        ],
      );
    } else if (date.minute == 30) {
      return Stack(
        clipBehavior: Clip.none,
        children: [
          Positioned.fill(
            top: -8,
            right: 8,
            child: Text(
              "${date.hour}:${date.minute}",
              textAlign: TextAlign.right,
              style: TextStyle(
                color: Theme.of(context).colorScheme.onSurface.withAlpha(50),
                fontStyle: FontStyle.italic,
                fontSize: 12,
              ),
            ),
          ),
        ],
      );
    }

    final hour = ((date.hour - 1) % 12) + 1;
    return Stack(
      clipBehavior: Clip.none,
      children: [
        Positioned.fill(
          top: -8,
          right: 8,
          child: Text(
            "$hour ${date.hour ~/ 12 == 0 ? "am" : "pm"}",
            textAlign: TextAlign.right,
          ),
        ),
      ],
    );
  }

@MDeLuise
Copy link
Author

Really thanks, I'll try that

@DonnyDevIT
Copy link

Any updates to when this will be fixed?

@ParthBaraiya ParthBaraiya added bug Something isn't working priority:1 Bug/Enhancement with highest priority. labels Sep 13, 2024
PRBaraiya added a commit that referenced this issue Sep 16, 2024
🐛 Fixes issue in quarter hours when startHour is provided. #387
@DonnyDevIT
Copy link

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:1 Bug/Enhancement with highest priority.
Projects
None yet
3 participants