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

Add dynamic height options #24

Merged
merged 8 commits into from
Feb 13, 2019

Conversation

Bwaim
Copy link

@Bwaim Bwaim commented Jan 9, 2019

This PR contains :

  • A simplification of the header height management
  • A new option to have dynamic hour height based on the available height
  • A change of the hour precision to make the new option works better
  • Add of a new example to demonstrate the new option in a ConstraintLayout

I could adapt it if you accept previous PR as it has cross impact

@thellmund
Copy link
Owner

Could you elaborate on the effects that your changes have? All I can observe is the increased height of all-day event chips.

@Bwaim
Copy link
Author

Bwaim commented Jan 10, 2019

The first commit (e3a9765) has no visual impact. It's just an harmonization of the use of headerHeight to facilitate the positionning. It has also some minor corrections like the size of the all day event chip which was not using the existing parameter allDayEventHeight.

The third commit(ac772f0) just increase the precision of the postionning of hour separator has it was needed for the option.

The new option dynamicHourHeight allow to fit all hours in a specified height if you want to have all your calendar in the same page. It allows to not have to define a specific height for the component. I added an example to play with it dynamically (Basic Example (inside constraint layout)) :
image
image

@Bwaim
Copy link
Author

Bwaim commented Jan 10, 2019

i added a fix for the position of the day label (5a88afe) and a new parameter headerMarginBottom.
The header is composed like this :
image

@thellmund
Copy link
Owner

There is an issue when scrolling horizontally between days, where all-day event chips don’t disappear correctly.

screenshot_1547660584

@@ -39,6 +39,7 @@
int headerRowBackgroundColor = Color.WHITE;
int headerRowPadding = 10;
int todayHeaderTextColor = Color.rgb(39, 137, 228);
int headerMarginBottom = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, headerRowPadding is used to determine the padding below the all-day event chips. By introducing this new attribute, we make yet another breaking change for users of this library.

Copy link
Author

@Bwaim Bwaim Jan 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it's a breaking change. The thing is that actually, the header is not well computed, i mean the user can't have a control to change the 3 spaces available correctly.
For example, the headerMarginBottomactually couldn't be controlled, i just added the possibility to the user to change it.
How would you want to compute the header spaces ? i'll think about how to change it without impact or less impact.

Copy link
Author

@Bwaim Bwaim Jan 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, the day label was not well placed and there will be impact on existing project. So what do you think is the best ?
Edit : The vertical position of the day label is computed as this :
val y = drawingConfig.headerTextHeight + config.headerRowPadding

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s a lot happening in this pull request already, so I think it’d be best to leave it as it is for now. Feel free to pick up the topic in a separate pull request, if you like.

library/src/main/res/values/attrs.xml Outdated Show resolved Hide resolved
sample/src/main/AndroidManifest.xml Outdated Show resolved Hide resolved
sample/src/main/res/values/strings.xml Outdated Show resolved Hide resolved
headerHeight += config.headerRowBottomLineWidth;
}
if (hasEventInHeader) {
headerHeight += config.allDayEventHeight;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking back to my refactoring, allDayEventHeight is something that I wanted to deprecate, but forgot to do. The reason is that while the event chip might become taller, the event text size stays the same, resulting in a waste of space (just take a look at the screenshot you posted above).

There are a couple options for how to continue:

  1. Continue to calculate the chip height based on the text size and officially deprecate allDayEventHeight.
  2. Adjust the text size of all-day events to fit the height of the chip (allDayEventHeight).
  3. Introduce an allDayEventTextSize, which is applied to all-day event chips. If not specified, it would fall back to the eventTextSize, so it would not be a breaking change.

What’s your take on this, @Bwaim?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your propositions 1 and 3 are good. As you said, we should try to reduce the header size to the minimum.
Added to the deprecation of allDayEventHeight, maybe we could add a new parameter maxAllDayEventHeight to prevent the chip to be too big. What do you think about it ?

I think the proposition 2 is not good because if the event label is very long, we will have a problem to decide the text size to use.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s try idea 3. It gives the most control and wouldn’t change anything for users of this library.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In last commit, i implemented your propositions 1 and 3, do you prefer i just let proposition 3 and revert the deprecation of allDayEventHeight ? Should i remove the maxAllDayEventHeight parameter i added ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think maxAllDayEventHeight is necessary – the height of the chip will be determined by allDayEventTextSize. You can remove the former.

The deprecation of allDayEventHeight is fine.

@Bwaim Bwaim force-pushed the add_dynamic_height_options branch 3 times, most recently from 3a67798 to 52cad28 Compare January 17, 2019 16:48
@Bwaim
Copy link
Author

Bwaim commented Jan 17, 2019

I commited a new version taking into account the remarks.
Just 2 remarks are not changed yet :

  • The use of headerRowPadding
  • The use of allDayEventHeight

- Write the day label correctly, using the baseline
- Use the allDayEventHeight parameter for the size of all day event chip
- Correct computation of the day label height
- Fix the bug of the all day event chip displayed in the upper left corner
- Rename the parameter dynamicHourHeight to showCompleteDay
- Rename the example to "Basic Example (showing complete day)"
- Correct the indentation of activity_constraint.xml
@Bwaim
Copy link
Author

Bwaim commented Jan 18, 2019

I commited a new version taking into account the remark concerning the use of allDayEventHeight.
I wait your opinion about how you want to compute the header height.

- Remove the parameter allDayEventHeight
- Add a parameter allDayEventTextSize
- Add a parameter maxAllDayEventHeight
- Calculate the chip height based on the text size and maxAllDayEventHeight
@thellmund
Copy link
Owner

@Bwaim Sorry for the delay. I’m having exams soon, so I’m not sure when I’ll find the time. But I won’t forget about your two pull requests 😉

@Bwaim
Copy link
Author

Bwaim commented Feb 1, 2019

@thellmund No problem, exams first, good luck !

@thellmund
Copy link
Owner

@Bwaim Looked at your latest changes as a bit of studying procrastination 😉I noticed two small issues:

  1. The text weight of the all-day events is off. It should be bold, but is normal.
  2. There’s no longer the padding below all-day event chips. Please add that back.

Besides that, the rest seems fine. Just these two things, and then we can merge this thing 👌

@thellmund
Copy link
Owner

@Bwaim Nevermind, I will merge this commit and resolve the issues 😊

@thellmund thellmund merged commit 807303e into thellmund:develop Feb 13, 2019
@Bwaim
Copy link
Author

Bwaim commented Feb 14, 2019

2. There’s no longer the padding below all-day event chips. Please add that back.

@thellmund As explained in my comment of the 10 January, the padding below all-day event chips is now controlled with the parameter headerRowPadding

@Bwaim Bwaim deleted the add_dynamic_height_options branch February 14, 2019 14:06
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

Successfully merging this pull request may close these issues.

None yet

2 participants