-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Feat: Add weeknumbers to Calendar #21311
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
Open
timunie
wants to merge
14
commits into
AvaloniaUI:master
Choose a base branch
from
timunie:feat/CalendarWeekNumbers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
27853b0
Add basic Weeknumber support
timunie ccbe94a
Add weeknumber header and also add a sample to ControlCatalog
timunie b1de1ec
Improve styling
timunie 43c2fe9
Make sure to use ISOWeek calculation where requiered.
timunie 64feeb4
Improvements to Weeknumber behavior
timunie 4171178
fix simple style
timunie 4b51251
Merge branch 'master' into feat/CalendarWeekNumbers
timunie 49d4f91
fix test
timunie 6c1866c
Merge branch 'master' into feat/CalendarWeekNumbers
timunie 8ada34e
address some review points
timunie b1bca1e
Merge remote-tracking branch 'AvaloniaUI/master' into feat/CalendarWe…
timunie 73ebd42
Merge remote-tracking branch 'origin/feat/CalendarWeekNumbers' into f…
timunie 68e9bda
Follow review feedback
timunie 40a12c6
fix: Forgot to rename the properties in the sample code
timunie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| namespace Avalonia.Controls.Primitives | ||
| { | ||
| /// <summary> | ||
| /// Displays a week number in the month view of a <see cref="Calendar"/>. | ||
| /// Apply styles targeting <see cref="CalendarWeekNumberLabel"/> to customise | ||
| /// the appearance — for example <c>FontWeight="Bold"</c>. | ||
| /// Use the <c>:header</c> pseudo-class to target the column header cell (row 0). | ||
| /// </summary> | ||
| public sealed class CalendarWeekNumberLabel : ContentControl | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets a value indicating whether this label is the column header cell | ||
| /// (placed in row 0 of the month grid, above the week-number data cells). | ||
| /// Themes can target this with the <c>:header</c> pseudo-class. | ||
| /// </summary> | ||
| public bool IsHeader | ||
| { | ||
| get => field; | ||
| internal set | ||
| { | ||
| if (field == value) return; | ||
| field = value; | ||
| PseudoClasses.Set(":header", value); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| namespace Avalonia.Controls | ||
| { | ||
| /// <summary> | ||
| /// Defines the rule that determines the first week of the calendar year for week-number display. | ||
| /// </summary> | ||
| public enum CalendarWeekNumberRule | ||
| { | ||
| /// <summary> | ||
| /// The first week of the year starts on the first day of the year and ends before the | ||
| /// following designated first day of the week. Equivalent to | ||
| /// <see cref="System.Globalization.CalendarWeekRule.FirstDay"/>. | ||
| /// </summary> | ||
| FirstDay = 0, | ||
|
|
||
| /// <summary> | ||
| /// The first week of the year begins on the first occurrence of the designated first day | ||
| /// of the week on or after the first day of the year. Equivalent to | ||
| /// <see cref="System.Globalization.CalendarWeekRule.FirstFullWeek"/>. | ||
| /// </summary> | ||
| FirstFullWeek = 1, | ||
|
|
||
| /// <summary> | ||
| /// The first week of the year is the first week with four or more days before the | ||
| /// designated first day of the week. Equivalent to | ||
| /// <see cref="System.Globalization.CalendarWeekRule.FirstFourDayWeek"/>. | ||
| /// </summary> | ||
| FirstFourDayWeek = 2, | ||
|
|
||
| /// <summary> | ||
| /// Uses ISO 8601 week numbering: the first week of the year must contain at least four days, | ||
| /// and Monday is treated as the first day of the week, regardless of | ||
| /// <see cref="Calendar.FirstDayOfWeek"/>. This is the most common rule in European locales | ||
| /// and professional calendar applications. | ||
| /// </summary> | ||
| Iso = 3, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO an entire new primitive probably isn't needed for this concept. It can be done with text and light-weight styling resources alone.
That in turn allows room for future expansion in this area. For example -- we might want to make it interactive as a button in some way, the calendar might get a week ONLY view, etc.
I'm also not a fan of the legacy term "Label" being used for new controls. That just isn't done in modern XAML.