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

Clarify how WeekViewStyle and DayViewStyleBuilder are combined together #43

Closed
luistrivelatto opened this issue Jul 4, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@luistrivelatto
Copy link
Contributor

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? :)

@luistrivelatto luistrivelatto added the enhancement New feature or request label Jul 4, 2020
@luistrivelatto luistrivelatto changed the title Clarify how WeekViewStyle and dayViewStyleBuilder are combined together Clarify how WeekViewStyle and DayViewStyleBuilder are combined together Jul 4, 2020
@Skyost Skyost pinned this issue Jul 4, 2020
@Skyost
Copy link
Owner

Skyost commented Jul 4, 2020

I agree with you. The current system allows to separate the style part from the code part, but it may be a bit messy. Here's what we need to do :

@luistrivelatto
Copy link
Contributor Author

Removing the WeekViewStyle and adding the params to WeekView should work indeed. But I liked your idea of isolating the style (height/width/colors) from other more behaviour-ish parameters, so I'd be favorable to keeping the class, but just reducing the intersection with DayViewStyle params. It would also keep consistency with patterns in Flutter widgets (such as the 'decoration' param in Container). What do you think?

@Skyost
Copy link
Owner

Skyost commented Jul 5, 2020

What do you think?

I agree. I just thought about it briefly to be honest 😄

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

No branches or pull requests

2 participants