Coder Social home page Coder Social logo

skyost / flutterweekview Goto Github PK

View Code? Open in Web Editor NEW
206.0 8.0 88.0 10.32 MB

Displays a highly customizable week view (or day view) which is able to display events, to be scrolled, to be zoomed-in & out and a lot more !

Home Page: https://pub.dev/packages/flutter_week_view

License: MIT License

Objective-C 0.02% Dart 69.89% Kotlin 0.09% Swift 0.83% HTML 1.00% CMake 12.21% C++ 15.03% C 0.93%
flutter package widget day week calendar view day-view week-view calendar-view

flutterweekview's Introduction

Flutter Week View

Likes Popularity Pub points

Displays a highly customizable week view (or day view) which is able to display events, to be scrolled, to be zoomed-in & out and a lot more !

Flutter Week View is highly inspired by Android Week View.

Getting Started

Getting started with Flutter Week View is very straight forward. You have the choice between two widgets : DayView and WeekView. Use the first one to display a single day and use the second one to display multiple days.

Example

If you want a real project example, you can check this one on Github.

Day View

Snippet :

// Let's get two dates :
DateTime now = DateTime.now();
DateTime date = DateTime(now.year, now.month, now.day);

// And here's our widget !
return DayView(
  date: now,
  events: [
    FlutterWeekViewEvent(
      title: 'An event 1',
      description: 'A description 1',
      start: date.subtract(Duration(hours: 1)),
      end: date.add(Duration(hours: 18, minutes: 30)),
    ),
    FlutterWeekViewEvent(
      title: 'An event 2',
      description: 'A description 2',
      start: date.add(Duration(hours: 19)),
      end: date.add(Duration(hours: 22)),
    ),
    FlutterWeekViewEvent(
      title: 'An event 3',
      description: 'A description 3',
      start: date.add(Duration(hours: 23, minutes: 30)),
      end: date.add(Duration(hours: 25, minutes: 30)),
    ),
    FlutterWeekViewEvent(
      title: 'An event 4',
      description: 'A description 4',
      start: date.add(Duration(hours: 20)),
      end: date.add(Duration(hours: 21)),
    ),
    FlutterWeekViewEvent(
      title: 'An event 5',
      description: 'A description 5',
      start: date.add(Duration(hours: 20)),
      end: date.add(Duration(hours: 21)),
    ),
  ],
  style: const DayViewStyle.fromDate(
    date: now,
    currentTimeCircleColor: Colors.pink,
  ),
);

Result :

Week view

Snippet :

// Let's get two dates :
DateTime now = DateTime.now();
DateTime date = DateTime(now.year, now.month, now.day);

// And here's our widget !
return WeekView(
  dates: [date.subtract(Duration(days: 1)), date, date.add(Duration(days: 1))],
  events: [
    FlutterWeekViewEvent(
      title: 'An event 1',
      description: 'A description 1',
      start: date.subtract(Duration(hours: 1)),
      end: date.add(Duration(hours: 18, minutes: 30)),
    ),
    FlutterWeekViewEvent(
      title: 'An event 2',
      description: 'A description 2',
      start: date.add(Duration(hours: 19)),
      end: date.add(Duration(hours: 22)),
    ),
    FlutterWeekViewEvent(
      title: 'An event 3',
      description: 'A description 3',
      start: date.add(Duration(hours: 23, minutes: 30)),
      end: date.add(Duration(hours: 25, minutes: 30)),
    ),
    FlutterWeekViewEvent(
      title: 'An event 4',
      description: 'A description 4',
      start: date.add(Duration(hours: 20)),
      end: date.add(Duration(hours: 21)),
    ),
    FlutterWeekViewEvent(
      title: 'An event 5',
      description: 'A description 5',
      start: date.add(Duration(hours: 20)),
      end: date.add(Duration(hours: 21)),
    ),
  ],
);

Result :

Options

Common options

Here are the options that are available for both DayView and WeekView :

  • events Events to display.
  • style Allows you to style your widget. A lot of different styles are available so don't hesitate to try them out !
  • hoursColumnStyle Same, it allows you to style the hours column on the left.
  • controller Controllers allow you to manually change the zoom settings.
  • inScrollableWidget Whether to put the widget in a scrollable widget (disable if you want to manage the scroll by yourself).
  • minimumTime The minimum hour and minute to display in a day.
  • maximumTime The maximum hour and minute to display in a day.
  • initialTime The initial hour and minute to put the widget on.
  • userZoomable Whether the user is able to (un)zoom the widget.
  • currentTimeIndicatorBuilder Allows you to change the default current time indicator (rule and circle).
  • onHoursColumnTappedDown Provides a tapped down callback for the hours column. Pretty useful if you want your users to add your own events at a specific time.
  • onBackgroundTappedDown Provides a similar callback as the above, but when the user clicks on the background (an empty region of the calendar).
  • onDayBarTappedDown Provides a tapped down callback for the day bar.
  • dragAndDropOptions Enables drag-and-drop of events.
  • resizeEventOptions Enables resizing events, by dragging the bottom of the event up/down.

Flutter day view

Here are the specific options of DayView :

  • date The widget date.
  • dayBarStyle The day bar style.

Flutter week view

Here are the specific options of WeekView :

  • dates The widget dates.
  • dayViewStyleBuilder The function that allows to build a Day View style according to the provided date.
  • dayBarStyleBuilder The function that allows to build a Day Bar style according to the provided date.

Please note that you can create a WeekView instance using a builder. All previous options are still available but you don't need to provide the dates list. However, you need to provide a DateCreator (and a date count if you can, if it's impossible for you to do it then scrollToCurrentTime will not scroll to the current date).

Contributions

You have a lot of options to contribute to this project ! You can :

flutterweekview's People

Contributors

bilibalaaaaaa avatar jayjah avatar luistrivelatto avatar maltekiessling avatar prabel avatar rodrigosa7 avatar skyost avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutterweekview's Issues

Creating WeekView with inScrollableWidget = false may throw ScrollController exception

Describe the bug
When creating a WeekView with inScrollableWidget = false and scrollToCurrentTime = true, the app throws the following exception:

════════ Exception caught by scheduler library ═════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
ScrollController not attached to any scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
Failed assertion: line 110 pos 12: '_positions.isNotEmpty'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=BUG.md

When the exception was thrown, this was the stack: 
#2      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:110:12)
#3      _WeekViewState.scrollToCurrentTime (package:flutter_week_view/src/week_view.dart:246:126)
#4      ZoomableHeadersWidgetState.scheduleScrollToCurrentTimeIfNeeded.<anonymous closure> (package:flutter_week_view/src/headers.dart:134:59)
#5      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1102:15)
#6      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1049:9)

If we set scrollToCurrentTime = false and initialTime = [later time in the day that doesn't appear initially on screen], no exception seems to be thrown, but the desired initialTime isn't shown on screen.

This issue doesn't trigger Flutter's "red screen of death", so it looks like almost everything works,
other than not showing the desired initialTime.

To Reproduce
Steps to reproduce the behavior (1) (exception thrown):

  1. Take the example code on the package.
  2. Replace _DemoWeekView with
class _DemoWeekView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    DateTime now = DateTime.now();
    DateTime date = DateTime(now.year, now.month, now.day);
    return WeekView(
      scrollToCurrentTime: true,
      inScrollableWidget: false,
      dates: [date],
    );
  }
}
  1. Run the app and click on Demo week view button. This should show the thrown exception on the console.

Steps to reproduce the behavior (2) (initial time not being shown on screen):

  1. Take the example code on the package.
  2. Replace _DemoWeekView with
class _DemoWeekView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    DateTime now = DateTime.now();
    DateTime date = DateTime(now.year, now.month, now.day);
    return WeekView(
      initialTime: HourMinute(hour: 20),
      scrollToCurrentTime: false,
      inScrollableWidget: false,
      dates: [date],
    );
  }
}
  1. Run the app and click on Demo week view button. This shouldn't throw an exception, but the screen initially doesn't show the 20:00 hour mark. A similar problem seems to happen in DayView, where no exception is thrown, but the desired initial time might now be shown correctly.

Expected behavior

  1. No exceptions should be thrown.
  2. DayView/WeekView should be rendered with the desired initial time appearing on screen.

Smartphone (please complete the following information):

  • Device: Galaxy A8
  • OS: Android 9

Improving performance by turning a SingleChildScrollView into a ListView

Is your feature request related to a problem? Please describe.
The current WeekView horizontal scrolling may be too expensive if there are too many dates because of the current system.

Currently the horizontal scrolling is managed by a SingleChildScrollView (see here) and DayViews with DayBars are in a Row (this allow to have an horizontal + vertical fixed header).

Describe the solution you'd like
Replacing the SingleChildScrollView by a ListView (whom out-of-viewport elements are not considered).

This can be done by swapping the role of vertical and horizontal scrolling.

Describe alternatives you've considered
Using a third party plugin, like horizontal_data_table or table_sticky_headers. But none really fits the needs of the plugin.

Additional context
None. Help is appreciated.

How to set the color of the event column? (not the FlutterWeekViewEvent)

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Need to remove FrameCallback when WeekView is disposed

I encounter this error:


════════ Exception caught by scheduler library ═════════════════════════════════
The following assertion was thrown during a scheduler callback:
setState() called after dispose(): _DayViewState#5c1ac(lifecycle state: defunct, not mounted)

It is caused by codes inside FrameCallback of WidgetsBinding.instance.addPostFrameCallback() are triggered even after WeekView is disposed

Detect click on daybar

I need to do action when clicking on the daybar where date is displayed.

I see onHoursColumnTappedDown and dayViewStyleBuilder to customize the DayViewStyle but I'm looking for something like "onDayBarTapped" or "onDatePressed".

Is there a way to do this ?

ScrollController not attached to any scroll views.

Stack trace:

flutter: ScrollController not attached to any scroll views.
flutter: 'package:flutter/src/widgets/scroll_controller.dart':
flutter: Failed assertion: line 112 pos 12: '_positions.isNotEmpty'
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2      ScrollController.position 
package:flutter/…/widgets/scroll_controller.dart:112
flutter: #3      ScrollController.offset 
package:flutter/…/widgets/scroll_controller.dart:120
flutter: #4      _WeekViewState.leftMostDisplayedDate 
package:flutter_week_view/…/widgets/week_view.dart:194
flutter: #5      _WeekViewState.currentDayViewStyle 
package:flutter_week_view/…/widgets/week_view.dart:187
flutter: #6      ZoomableHeadersWidgetState._calculateHourRowHeight 
package:flutter_week_view/…/widgets/zoomable_header_widget.dart:174
flutter: #7      ZoomableHeadersWidgetState.didUpdateWidget 
package:flutter_week_view/…/widgets/zoomable_header_widget.dart:108
flutter: #8      StatefulElement.update 
package:flutter/…/widgets/framework.dart:4734
flutter: #9      Element.updateChild 
package:flutter/…/widgets/framework.dart:3245
flutter: #10     ComponentElement.performRebuild 
package:flutter/…/widgets/framework.dart:4571
flutter: #11     StatefulElement.performRebuild 
package:flutter/…/widgets/framework.dart:4719
flutter: #12     Element.rebuild 
package:flutter/…/widgets/framework.dart:4262
flutter: #13     BuildOwner.buildScope 
package:flutter/…/widgets/framework.dart:2667
flutter: #14     WidgetsBinding.drawFrame 
package:flutter/…/widgets/binding.dart:866

leftMostDisplayedDate has been called before createWeekViewStack() so horizontalScrollController has not been attached to view yet.

12HR FORMAT

need to do more parsing to fit 12 hr format .

Is it possible to change the width of WeekView then rebuild the widget?

Is your feature request related to a problem? Please describe.
I want to add a button to change the width of the dayview in WeekView class. I found out that dayViewWidth property in WeekViewStyle is final, which I could not change once it initialized.

Is there any advice about this one?

Thanks

Merge with timetable package

Hello,

by browsing Flutter calendar packages I found out this one:
https://pub.dev/packages/timetable

Since it's more customizable (lack of this feature was the reason I dropped using Your one) it would be nice to contact with its author and maybe to team up.
The only disadvantage of JonasWanke's package is time_machine package usage (which is forbidden by its author, but I created issue for it).

DayView doesn't rebuild when changing content.

Describe the bug
The DayView widget doesn't rebuild after changing content via state.

Code snippet

Widget _buildDayView() {
    List<FlutterWeekViewEvent> meetings = selectedWeekDay.meetings.map((meeting) {
      print('Meeting: ${meeting.title}, date: ${meeting.startDate}');
      return FlutterWeekViewEvent(
        title: meeting.title,
        description: meeting.description,
        start: meeting.startDate,
        end: meeting.endDate,
      );
    }).toList();

    print('Meetingscount: ${meetings.length}');
    print('SelectedDate: ${selectedWeekDay.date}');

    var dayView = DayView(
      date: selectedWeekDay.date,
      events: meetings,
    );

    print('DayEvents: ${dayView.events}');

    return dayView;
}

Console

- I/flutter ( 8800): Meeting: Meeting 1 , date: 2020-02-17 10:00:00.000
- I/flutter ( 8800): Meeting: Meeting 2 , date: 2020-02-17 11:00:00.000
- I/flutter ( 8800): Meeting: Meeting 3 , date: 2020-02-17 13:00:00.000
- I/flutter ( 8800): Meetingscount: 3
- I/flutter ( 8800): SelectedDate: 2020-02-17 00:00:00.000Z
- I/flutter ( 8800): DayEvents: [Instance of 'FlutterWeekViewEvent', Instance of 'FlutterWeekViewEvent', Instance of 'FlutterWeekViewEvent']

After changing date via state:

- I/flutter ( 8800): Meeting: Meeting 4 , date: 2020-02-18 10:00:00.000
- I/flutter ( 8800): Meeting: Meeting 5 , date: 2020-02-18 13:00:00.000
- I/flutter ( 8800): Meetingscount: 2
- I/flutter ( 8800): SelectedDate: 2020-02-18 00:00:00.000Z
- I/flutter ( 8800): DayEvents: [Instance of 'FlutterWeekViewEvent', Instance of 'FlutterWeekViewEvent']

Expected behavior
DayView should rebuild its content.

Tablet (please complete the following information):

  • OS: Android
  • Version 9

Drag and drop feature request

Hi!

I'm a flutter developer from Hungary, and I'd like to use your FlutterWeekView widget in a project. I think this widget is awesome and the best free calendar widget in the internet :)

But i'd like to request a feature... It would be cool if drag and drop feature would be available in the future in order to events may be rearrangable easily.

Thank you very much your work and effort if you decide to develop this feature.

All regards,
Gábor Csillag

WeekView: Events that don't overlap the current day aren't displayed

It appears that events in WeekView aren't displayed unless at least some part of the event occurs during the current day.

To Reproduce
Steps to reproduce the behavior:

  1. Open the example app.
  2. Add an event not during the current day. Here's what I changed.
  3. Run the app and scroll to the day of the event.
  4. Observe that the event is not displayed.

Expected behavior
That all events occurring on the dates displayed by the WeekView will be displayed, regardless of whether they overlap the current date.

Thanks for making this library by the way! 🙂

currentTimeCircle 1 hour ahead of line

Describe the bug
Since version ^0.2.1+1 the currentTime line is on the correct time, but the circle is still one hour ahead.

To Reproduce
Steps to reproduce the behavior:

  1. Build DayView
  2. Look at currentTimeLine/Circle

Expected behavior
Circle should be on the same position like the line

Screenshots
IMG_C2B1A4049DED-1

Tablet (please complete the following information):

  • OS: Android
  • Version 9

Clarify how WeekViewStyle and DayViewStyleBuilder are combined together

Currently, WeekView has two styling params: style and dayViewStyleBuilder. But it is not clear how these two are combined together, opening room for some ambiguity: which one takes priority, when both have set the same param? Also, a couple of params of dayViewStyleBuilder are ignored in the WeekView context, and there are some params which are present in dayViewStyleBuilder but not in WeekViewStyle. Here's what I've compiled:

Params present only in WeekViewStyle

  • dayViewWidth
  • dayViewSeparatorWidth
  • dayViewSeparatorColor

These are ok, they only make sense in WeekView and there's no confusion.

Params present only in DayViewStyle

  • backgroundColor
  • backgroundRulesColor
  • currentTimeRuleColor
  • currentTimeRuleHeight
  • currentTimeCircleColor
  • currentTimeCircleRadius
  • currentTimeCirclePosition

I believe all these params apply to WeekView too, but can't be set through DayViewStyle. So this is somewhat confusing (since if the user wants to set these params, he needs to add a DayViewStyleBuilder, whereas other params can be set through WeekViewStyle).

Params present in both, but their value in DayViewStyleBuilder is never used, only the value from WeekViewStyle is used

  • hourRowHeight
  • dayBarHeight
  • hoursColumnWidth

These are overridden by WeekView to be 0 for each DayView. I think it's ok to ignore these values from DayViewStyleBuilder, since in the WeekView they only make sense in the group as a whole. But this should be indicated through docs/code (for example, by settings asserts to check that DayViewStyleBuilder doesn't try setting these 3 values).

Remaining params present in both

  • dateFormatter
  • timeFormatter
  • dayBarTextStyle
  • dayBarBackgroundColor
  • hoursColumnTextStyle
  • hoursColumnBackgroundColor

When these params are present in both style and dayViewStyleBuilder, the value from style is always given priority. I think it would be better to give priority to dayViewStyleBuilder, allowing for example to customize the dayBarTextStyle according to the current day, which is a feature wanted in #41.

Idea for clarifying WeekView's style
It seems to me that a good way to make things clearer would be to strip out from WeekViewStyle all the params written in the last list, leaving it like this:

WeekViewStyle(
  hourRowHeight,
  dayBarHeight,
  hoursColumnWidth,
  dayViewWidth,
  dayViewSeparatorWidth,
  dayViewSeparatorColor
)

Then the default (and only) way to customize style which is not WeekView-specific would be to set a DayViewStyleBuilder. Also, the 3 first params (hourRowHeight, etc), which would still be present in DayViewStyle, could be assert-checked that they are not set in DayViewStyleBuilder.

This would:

  • fix ambiguity of params present in both styles (no param can be set in both styles simultaneously)
  • allow to customize params which are DayView-specific according to the date (e.g. custom style for current day)
  • remove possible confusion from setting hourRowHeight, dayBarHeight and hoursColumnWidth in DayViewStyleBuilder (would throw an assertion failure)
  • make it so that, if new DayView-specific styling options are added which also make sense at WeekView level, they only need to be added in one place (currently, they should be added at both styles for consistency)

I understand this would not be a trivial change (plus it would be a breaking one), but I believe the API would be cleaner as a result. Thoughts? :)

Make event's "end" property optional

Is your feature request related to a problem? Please describe.
Not all events has ending time and for these ones I would like to avoid setting "end" property.

Describe the solution you'd like
Make this option obsolete and let event's height be dynamic to let show whole event's description if needed.

Describe alternatives you've considered
There is none, since I'm ready to take care about this one.

Timescala doesn't zoom with content

Describe the bug
When zooming on DayView, the time scala on the left side doesn't scoll too

To Reproduce
Steps to reproduce the behavior:

  1. Build DayView
  2. Try to zoom

Expected behavior
Timescala should zoom the same way then content.

Tablet:

  • OS: Android
  • Version 9

Detect on day changed in WeekView

I don't know if this alread exists, but would be helpfull if we have a onDayChanged or onVisibleDayChanged, something like this to make callback actions when user change the current day on week view by swiping action.

OnTap doesn't work reliably

When using different onTap() on different events, the execution of the method is random.
For example I have 3 different events and let it print 1 (for event 1), 2 (for event 2) or 3 (for event 3), I don't get a print of 1 every time I press it, but a variation of 1 or 2 or 3.

Require click on empty block of time same as event tap

DayView and WeekView should allow user to click on empty block of time. User can same way add the event by tapping on it.
Let me know whether you like this idea or not. I have check ios calendar app where they are allowing same.
Thank you

ADD ability to set custom subhour lines #UX

use case

In addition to the main gray *:00 hour lines, want to have a bit more faded lines showing at *:30 and maybe even lines with different styles shown at *:15 and *:45

Blocks doesn't change places after changing hourRowHeight

Hello

There is a problem when changing hourRowHeight, the blocks doesn't change to fit the time. So the time starts at 6 AM after changing the hight it still in the old place of the previous hight and that would be now 3 AM, I've tried to rebuild, and building after cleaning but it doesn't work.

This is before changing
This is before changing

This is after changing
This is after changing

Smartphone:

  • Device: S9+
  • OS: Android 10

Red indicator indicates wrong current time

To Reproduce
Steps to reproduce the behavior:

  1. Flutter run example
  2. Click on 'Demo Day View'
  3. Red indicator does not match current time on my OS/timezone
  4. See error

Using Android emulator on Mac OS.
Screen Shot 2020-02-02 at 12 39 42 PM

Improving performance by replacing the days row bar by a days bar list in WeekView

Is your feature request related to a problem? Please describe.
I would also like to replace the days bar row by a days bar list (see #7, that's almost the same problem).

Describe the solution you'd like
In this one, I don't really know how to proceed. Maybe using a synchronized listview (something like this or this) ?

Describe alternatives you've considered
Using a third party plugin, like horizontal_data_table or table_sticky_headers. But none really fits the needs of the plugin.

Additional context
None. Help is appreciated tho'.

ADD DayView: infinite scroll

when you scroll to the end of the day, it will continue scrolling into the next day and so forth

events with start times in Day+0 and end times in DAY+1 will show up as single events when scrolling past midnight

Need tap gesture on tap of time slot

Is your feature request related to a problem? Please describe.
When user want to add event, user always have to select date and time, it will be good to have gesture detector on time slot and hight light the same slot on tap on basis of bool and color.

Describe the solution you'd like
when user tap inside 1 hr - 2hrs box it will call on tap method with start datetime as parameter

Describe alternatives you've considered
No alternative

Current time ruler shown incorrectly when minimumTime/maximumTime are set

Describe the bug
If we set a value for minimumTime/maximumTime and the current time falls outside of that range, a current time ruler is incorrectly drawn at the top of the widget.

To Reproduce
Steps to reproduce the behavior:

  1. Create a widget with minimumTime/maximumTime set such that the current time is not included in the range. A ruler is drawn (sorry for no code, this is specific to the time you're reading this :p ).

Expected behavior
No ruler should be drawn.

Screenshots
(run with current time: 8AM)
day_view_minimum_maximum_time

Smartphone (please complete the following information):
Device: Galaxy A8
OS: Android 9

Scroll to specific time

Hello,

it will be a nice feature if DayViewController have a option to scroll the screen to a current time. I know we can scroll to currentTime when the widget build but i would like to do this in any other moment.

In version 0.2.1+6 i did this (i had fixed hourRowHeight, so it was easier to solve my problem):

class CalendarDayViewController extends DayViewController {
  /// Returns whether this widget should be zoomable.
  /// Calculates the top offset of a given hour and a given minute.
  double calculateTopOffset(int hour, [int minute = 0, double hourRowHeight]) =>
      (hour + (minute / 60)) * (hourRowHeight ?? 127);

  /// Scrolls to a given time if possible.
  void scrollToTime(int hour, int minute) {
    double topOffset = calculateTopOffset(hour, minute);
    verticalScrollController.animateTo(math.min(topOffset, verticalScrollController.position.maxScrollExtent), duration: Duration(milliseconds: 750), curve: Curves.easeInOut);
  }
}

But now, DayViewController doesn't have the verticalScrollController property, so i can't do this anymore.

What do you think?

CurrentTimeCirclePosition.left shows circle on top of hours column

Describe the bug
Setting currentTimeCirclePosition = CurrentTimeCirclePosition.left on the day view style shows the time circle on top of the hours column.

To Reproduce

  1. Take the example code.
  2. Set the demo day view style to
style: const DayViewStyle(
        currentTimeCircleColor: Colors.pink,
        currentTimeCirclePosition: CurrentTimeCirclePosition.left,
      ),

Expected behavior
Should be shown on the right of the hours column.

Screenshots
20200626_034351

Smartphone (please complete the following information):
Device: Galaxy A8
OS: Android 9

Add an option to change the widget orientation

French :

Salut,

ça serait bien de faire un système pour changer les emplacements, c'est-à-dire les heures seront en haut et scroller horizontalement et les jours scroller verticalement a gauche..

English :

Hey,

It would be good to create an option that would allow to change the widget orientation (i.e. hours at the top and scrolling vertically would change the day).

Alternative to background canvas painter

Hi :)

I'm using the version 0.2.1+6 in my app and i want to update to the package latest version but i was using the eventsColumnBackgroundPainter property in DayView and now this property doest not exists and now i don't find a alternative since the remove of the property.

Previously i created a inheritance with the EventsColumnBackgroundPainter class because i needed a padding left in content.

My code:

class CalendarDayViewBackgroundPainter extends EventsColumnBackgroundPainter {
  final double left;

  CalendarDayViewBackgroundPainter({
    backgroundColor,
    rulesColor,
    this.left = 0 // This is my change
  }) : super (
    backgroundColor: backgroundColor,
    rulesColor:rulesColor,
  );

  @override
  void paint(Canvas canvas, Size size) {
    if (backgroundColor != null) {
      canvas.drawRect(Rect.fromLTWH(0, 0, size.width, size.height), Paint()..color = backgroundColor);
    }

    if (rulesColor != null) {
      for (int hour = 1; hour < 24; hour++) {
        double topOffset = topOffsetCalculator(hour);
        Paint paint = Paint();
        paint.color = rulesColor;
        paint.strokeWidth = 1;
        canvas.drawLine(Offset(left, topOffset), Offset(size.width, topOffset), paint);
      }
    }
  }
}

Is there an alternative to help me?

Thank you.

Events not displayed dynamically in DayView

Describe the bug
I put my events in an array of FlutterWeekViewEvent. it's not displayed(painted) unless I purposely throw and exception that cause the whole page to be repainted not only the DayView

To Reproduce
this is the code I used to put events into day view:

List _listEvents = List();
try {
_lst?.forEach((e) {
_listEvents.add(
FlutterWeekViewEvent(
title: e.service?.productName ?? "No Product Name",
description: e.service?.productDescription ?? 'No description',
start: e.start,
end: e.start.add(Duration(hours: 1)),
),
);
});
} catch (e) {
print('processing event error $e');
}

return DayView(
  eventsColumnBackgroundPainter: _bkgpntr,
  date: _day,
  events: _listEvents,
  currentTimeCircleColor: Colors.pink,
);

}

Desktop (please complete the following information):
using chrome Browser

Additional context
The Dayview bar and current timeline are displayed correctly. only the events are not displayed

time range is not customize always 1 hour can we set to 15 minutes

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

ADD background events support

some Events can be marked as background:

  • event width can be set in % (see use cases below)
  • showing event start-end times and/or title and/or description can be set to hidden
  • background events will be always shown as the lowest in the stack and will not be detected for collisions with upper tier events
  • tapping on background events will not trigger anything, they are just background coloring

use case: generating a sunrise-sunset background

this feature can be used to generate a background for each day that shows the location of the sun in the sky using the events width (sun intensity is useful in some regions to plan out ones day). the app using this can generate these by making lots of 15..60min events with different widths

use case: timeboxes

this feature can be used to color different parts of the day with different color to denote timebox/timebudget/timeblock preference for the user. this also should not collide with real events

use case: weather

the amount of rain can also be shown the same way as sun position

Week view event that spans over multiple days is rendered incorrectly

Describe the bug
A week view event that spans over multiple days is only shown in the days of the start and end date of the event.

To Reproduce
Steps to reproduce the behavior:

  1. Create the following week view widget:
      WeekView(
        dates: [DateTime(2020, 1, 1), DateTime(2020, 1, 2), DateTime(2020, 1, 3)],
        style: const WeekViewStyle(
          hourRowHeight: 30.0,
          dayViewWidth: 90.0,
        ),
        events: [
          FlutterWeekViewEvent(
            title: 'An event 1',
            description: 'A description 1',
            start: DateTime(2020, 1, 1, 20),
            end: DateTime(2020, 1, 3, 6),
          ),
        ],
      ),
  1. Check the widget's UI to see that it is not rendered on 2020-01-02.

Expected behavior
There should be an event box covering the full day of 2020-01-02.

Screenshots
week_view_multi_day_event

Smartphone (please complete the following information):
Device: Galaxy A8
OS: Android 9

Event overflows calendar if start at the end of day

Describe the bug
As in topic. On my screen I see 10px height event container, which ofc cant show any info.

To Reproduce
Steps to reproduce the behavior:

  1. Set calendar's event to one starting with 23:55
  2. Scroll down to bottom of calendar

Expected behavior
There should be some space in widget itself to show even primary info and being high enough to let user click on it.

Screenshots
Save servers storage

Desktop (please complete the following information):

  • OS Arch Linux
  • Browser Brave

I'm ready to take care about this bug

WeekView.builder crashes when dateCount is null

Describe the bug
When using the WeekView.builder constructor, a dateCreator is required, but not a dateCount (which is in accordance to idiomatic builder constructors in Flutter). Indeed, the constructor allows that, with the assertion assert(dateCount == null || dateCount >= 0). However this causes a crash when dateCount == null and a WeekViewController isn't passed, since a WeekViewController is then instanced using dateCount, but WeekViewController itself doesn't allow for a null dateCount: assert(dayViewsCount != null && dayViewsCount > 0).

To Reproduce
Steps to reproduce the behavior:

  1. Take the example code on the package.
  2. Replace _DemoWeekView with
class _DemoWeekView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return WeekView.builder(
      dateCreator: (index) => DateTime(2020, 1, 1 + index),
      events: [],
    );
  }
}
  1. Run the app and click on the Demo week view button. This should show the following error:
'package:flutter_week_view/src/controller.dart': Failed assertion: line 160 pos 16: 'dayViewsCount != null && dayViewsCount > 0': is not true.

Expected behavior
No errors should be thrown, and the controllers should be managed seamlessly until dateCreator returns null for a given index.

Smartphone (please complete the following information):

  • Device: Galaxy A8
  • OS: Android 9

Be able to configure the initial scroll position of WeekView

I need to launch WeekView and immediately jump to a selected event. Something may be initialDate and we can calculate scroll position out from it instead of only scrolling to current time.

@override
  void scrollToCurrentTime() {
    super.scrollToCurrentTime();

    int index = 0;
    if (widget.dateCount != null) {
      for (; index < widget.dateCount; index++) {
        if (Utils.sameDay(widget.dateCreator(index))) {
          break;
        }
      }
    }

    double topOffset = calculateTopOffset(HourMinute.now());
    double leftOffset = dayViewWidth * index;

    widget.controller.verticalScrollController.jumpTo(math.min<double>(topOffset, widget.controller.verticalScrollController.position.maxScrollExtent));
    widget.controller.horizontalScrollController.jumpTo(math.min<double>(leftOffset, widget.controller.horizontalScrollController.position.maxScrollExtent));
  }

Limit hours in a day

Hi Skyost,

Great widget, that you have made!

I'm trying to implement it to plan business days. It would be great if it's possible to limit the hours in a day, e.g. from 9.00 to 17.00. That would make the schedule more concise.

Implementation could be as a start/end paramater. eg:
dayStartHour: double
dayEndHour: double

Another implementation could be to limit the hours to the times in which there are actually events... so to trim off the empty hours at the beginning and end of the day schedule. Eg:
trimEmptyHours: bool

Well, either way, thanks for your widget!

Mark

EventTextBuilder doesn't work

Description:

I'm trying to use the EventTextBuilder attribute of FlutterWeekViewEvent class but i'm having problem with they parameters. His declaration expected 4 parameters but he is calling with 5.

expected:

typedef EventTextBuilder = Widget Function(BuildContext context, DayView dayView, double height, double width);

actual call:

child: (eventTextBuilder ?? DefaultBuilders.defaultEventTextBuilder)(

Am i doing this in the wrong way? I made a fork of the repository and change the Function declaration to expected 5 parameters and its working.

My code

FlutterWeekViewEvent(title: "",
     start: start,
     end: end,
     description: "",
     textStyle: themeData.textTheme.body2,
     padding: EdgeInsets.only(left: 27, top: 13),
     margin: EdgeInsets.only(left: 16, right: 28, top: 1, bottom: 1),
     onTap: onTap,
     onLongPress: onLongPress,
     eventTextBuilder: (BuildContext context, DayView dayView, double height, double width) {
     return Container(); 
});

Console:


════════ Exception caught by widgets library ═══════════════════════════════════
The following NoSuchMethodError was thrown building DayView(dirty, state: _DayViewState#129c3):
Closure call with mismatched arguments: function 'new CloseScheduleWeekViewEvent.<anonymous closure>'
Receiver: Closure: (BuildContext, DayView, double, double) => Column
Tried calling: new CloseScheduleWeekViewEvent.<anonymous closure>(Instance of 'CloseScheduleWeekViewEvent', Instance of 'StatefulElement', Instance of 'DayView', 213.0, 334.42857142857144)
Found: new CloseScheduleWeekViewEvent.<anonymous closure>(BuildContext, DayView, double, double) => Column

The relevant error-causing widget was
    DayView 
lib\…\appointment\appointment_timeline.dart:44
When the exception was thrown, this was the stack
#0      Object.noSuchMethod  (dart:core-patch/object_patch.dart:53:5)
#1      FlutterWeekViewEvent.build 
package:flutter_week_view/src/event.dart:78
#2      _EventDrawProperties.createWidget 
package:flutter_week_view/src/day_view.dart:439
#3      _DayViewState.createMainWidget.<anonymous closure> 
package:flutter_week_view/src/day_view.dart:156
#4      MappedIterator.moveNext  (dart:_internal/iterable.dart:395:18)
...

This title of event won't show when the event's duration is short.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.