jasudev / AxisContribution

A library that expresses a github contribution calendar through an array of dates. Supports iOS and macOS.
MIT License
109 stars 23 forks source link

Bug: Code in the main branch doesn't show today's data #14

Open Maples7 opened 3 months ago

Maples7 commented 3 months ago

When there's data like Date(): ACData(date: Date(), count: 5), It's blank for today's grid.

Also, the first week doesn't show correctly. While today is Tuesday, it shouldn't show the complete week with 7 days. There should be only 3 grids instead of 7, under the situation that Sunday is the first weekday.

Reproduce: When the preview code is like this:

struct ACGridStack_Previews: PreviewProvider {
    static var previews: some View {
        AxisContribution(
            constant: .init(),
            source: [
                Date(): ACData(date: Date(), count: 5)
            ]
        )
        .padding()
    }
}

This is the result:

image
Maples7 commented 3 months ago

It seems https://github.com/jasudev/AxisContribution/pull/6 bring this bug in.

Maples7 commented 3 months ago

This PR #13 is to fix this bug.

racechao commented 3 months ago

use Date().startOfDay as the key

struct AxisContribution_Previews: PreviewProvider {
    static var previews: some View {
        AxisContribution(constant: .init(), source: [Date().startOfDay: ACData(date: Date(), count: 5)])
            .preferredColorScheme(.dark)
    }
}