It appears that I made a dumb error on the initializer for the CalendarView where I subtract 1 from the end of the month rather than adding a day. init(date: Date, selectedActivity: Activity?) { self.date = date self.selectedActivity = selectedActivity let endOfMonthAdjustment = Calendar.current.date(byAdding: .day, value: 1, to: date.endOfMonth)! let predicate = #Predicate {$0.date >= date.startOfMonth && $0.date < endOfMonthAdjustment} _workouts = Query(filter: predicate, sort: \Workout.date) }
I just reviewed both videos tonight. I was trying to learn EventKit when I discovered your two videos. Your implementation of displaying how many activities have been recorded on a specific date seems to implement my use case in a much simpler manner. I hope I can replicate your process instead.
Thank you Stewart. I've enjoyed this set of videos and have learned a lot from all of them. New to Swift, but have been programming databases for 45 years. Nw to the visual front end and you have explained many of the small nuances that have been annoying me. Keep up the great work.
Thank you old man. We are tremendously fortunate to catch up with your stuff before your health seriously impedes your productivity. Keep outputting and stay consistent.
@@OrtoInScatola These are unfair accusations. I have never been rude to anyone. I’m just stating facts. I hope people in your capacity wouldn’t take my words out of context.
In English, calling someone an old man is not the best introduction but not to worry. I may be old, but I am experienced and in good shape. Lots of life left in me yet.
@@StewartLynch Accept my humble apologies, Sir. I don’t mean insult or any of that sort. I’m truly not familiar with taboos of your Western culture, and my comment was purely spontaneous.
Very good starting point for something I need for an app I am working on. I just need to make this scrollable to go to different months and to be able to click on a date to select a date instead of having the picker which seems redundant
Stewart great video, I really liked it a lot. I've implemented this is an app I have been redoing for SwiftData. There is one problem that I would love to see an updated video on, only because I've been trying to figure it out for a couple days and nothing works. That is that on an iPad the overlay for the counts doesn't stay on the circle its shifted over to the right quite a bit. First thought was try checking the device and orientation and that hasn't produced anything that works. Could you give us a look at how this could be solved. Anyway, love the video and all the effort you put into showing us these skills, I learn a lot every time.,
Steward how would make the calendar clickable for example an event tracking app where i want to tap on 3 of the days and mark them yellow to symbolize an event (i.e tapping them turns them yellow)
You could add an onTapGesture to items in the ForEach loop that captures the day and create an event for that day if there isn't one. This will then allow you to change the color of the calendar day. if there is one, you could delete it and that would remove the color
I have updated the code from the previous viddo to handle the first day of the week to follow the locale. I talk about this and show the update within the first couple of minues of this video. Did you not see that part?
any way to add this logic of highlighting the days with the counts with the out of the box date picker (.datePickerStyle(.graphical) ) and/or I can't seem to figure out how to make this calendar scrollable between months --
Making it scrollable will be tough because I only load one month at a time. You might want to modify it to load 3 months at a time. The current, previous and next and change that up each time the current month changes. I have not tested it, but in theory, it should work. I am not sure what you mean in the other question re "highlighting the days"
Thanks @@StewartLynch -- highlighting the days -> What I meant here is I am using the date picker in .graphical mode and wanted to do the same concept of adding the circle count with that calendar. This give e the ability to use the same calendar for also adding new activity with the same calendar. Hope that makes sense. I ll add some months to the original code and see how that works
Thank you for the video! But I didn't really get the counts dictionary logic: it isn't related to month or year so I feel like it counts workouts on 22th October and 22th November together in my code How was it supposed to work? I am confused :0
That is because there is a predicate for the workouts query that limits the workouts top the current month only. let predicate = #Predicate {$0.date >= date.startOfMonth && $0.date < endOfMonthAdjustment}
There's another problem, it's about weekdays naming. You're taking first letters of day names, which is fine for English (SMTWTFS), and works fine for some other locales (for example, for Russian: ПВСЧПСВ, although it's more common to use two letters in Russian: Пн, Вт, Ср, etc.) There's a problem with Chinese, because names for Chinese weekdays are 週一,週二,週三 and so on. 週 means "week", and 一二三 are just numbers, and I think you already see what's the problem here.
At that point, you're not talking about full localization. After all, if you're going to localize just part of a calendar, you might as well localize everything. And, IMO, that should only be done post launch. i.e. see if there is a real demand for the app first, before commiting to expensive localization efforts.
Stewart! thank you so much for this video! I had a question regarding the pros and cons of this custom calendar tallies view vs. this video? what are your pros and cons to these methods? UIcalendarView th-cam.com/video/d8KYAeBDQAQ/w-d-xo.html it seems like the UICalendarView is fairly simplistic, but struggles with customization long term.But prodomenitly works for UIKit. to implement this into SwiftUI seems a little difficult. However, this Custom Calendar Tallies seems to be better for customization is is already for SwiftUI. just more coding for customization. thanks in advance :)
Great video. I have pick up a few points from these video for my calendar. Just one thing when using Picker do not use “” for label put the title as this will not read in Voice Over and then use modifier .labelHidden.
It appears that I made a dumb error on the initializer for the CalendarView where I subtract 1 from the end of the month rather than adding a day.
init(date: Date, selectedActivity: Activity?) {
self.date = date
self.selectedActivity = selectedActivity
let endOfMonthAdjustment = Calendar.current.date(byAdding: .day, value: 1, to: date.endOfMonth)!
let predicate = #Predicate {$0.date >= date.startOfMonth && $0.date < endOfMonthAdjustment}
_workouts = Query(filter: predicate, sort: \Workout.date)
}
Thanks Stewart
I like the way you organize the folders, sample preview, and ModalType enum; the code structure is so neat.
I just reviewed both videos tonight. I was trying to learn EventKit when I discovered your two videos. Your implementation of displaying how many activities have been recorded on a specific date seems to implement my use case in a much simpler manner. I hope I can replicate your process instead.
Thank you Stewart. I've enjoyed this set of videos and have learned a lot from all of them. New to Swift, but have been programming databases for 45 years. Nw to the visual front end and you have explained many of the small nuances that have been annoying me. Keep up the great work.
Great to hear!
Great set of videos. I already have a couple of uses for this calendar view with counts.
Thank you, Stewart! Excellent! Great fun! I learned some good techniques!
Excellent work again Stewart. Thanks.
Very welcome
Thank you old man. We are tremendously fortunate to catch up with your stuff before your health seriously impedes your productivity. Keep outputting and stay consistent.
can you be any more rude???
@@OrtoInScatola These are unfair accusations. I have never been rude to anyone. I’m just stating facts. I hope people in your capacity wouldn’t take my words out of context.
In English, calling someone an old man is not the best introduction but not to worry. I may be old, but I am experienced and in good shape. Lots of life left in me yet.
@@StewartLynch Accept my humble apologies, Sir. I don’t mean insult or any of that sort. I’m truly not familiar with taboos of your Western culture, and my comment was purely spontaneous.
No worries at all George. In the west we just don’t like to admit we are getting old. Thanks for clarification
Very good starting point for something I need for an app I am working on. I just need to make this scrollable to go to different months and to be able to click on a date to select a date instead of having the picker which seems redundant
Share your code when you have it.
Hi, have you figured out a way how to swipe though months?
Unfortunately, I have not had the time to explore this yet.
Stewart great video, I really liked it a lot. I've implemented this is an app I have been redoing for SwiftData. There is one problem that I would love to see an updated video on, only because I've been trying to figure it out for a couple days and nothing works. That is that on an iPad the overlay for the counts doesn't stay on the circle its shifted over to the right quite a bit.
First thought was try checking the device and orientation and that hasn't produced anything that works. Could you give us a look at how this could be solved.
Anyway, love the video and all the effort you put into showing us these skills, I learn a lot every time.,
It looks like I put the overlay in the wrong place. Move the overlay of the count up so that it is overlaying the Circle.
Steward how would make the calendar clickable for example an event tracking app where i want to tap on 3 of the days and mark them yellow to symbolize an event (i.e tapping them turns them yellow)
You could add an onTapGesture to items in the ForEach loop that captures the day and create an event for that day if there isn't one. This will then allow you to change the color of the calendar day. if there is one, you could delete it and that would remove the color
@@StewartLynch Wow thank you, your channel is really important to young developers nobody else goes this indepth on topics
Yes, we call the weekend, the weekend because it's the end of the week 😛
Hello Stewart, and how to do Monday first day of the week?
I have updated the code from the previous viddo to handle the first day of the week to follow the locale. I talk about this and show the update within the first couple of minues of this video. Did you not see that part?
@@StewartLynch Oh, I missed that, thank you
any way to add this logic of highlighting the days with the counts with the out of the box date picker (.datePickerStyle(.graphical) ) and/or I can't seem to figure out how to make this calendar scrollable between months --
Making it scrollable will be tough because I only load one month at a time. You might want to modify it to load 3 months at a time. The current, previous and next and change that up each time the current month changes. I have not tested it, but in theory, it should work. I am not sure what you mean in the other question re "highlighting the days"
Thanks @@StewartLynch -- highlighting the days -> What I meant here is I am using the date picker in .graphical mode and wanted to do the same concept of adding the circle count with that calendar. This give e the ability to use the same calendar for also adding new activity with the same calendar. Hope that makes sense. I ll add some months to the original code and see how that works
Thank you for the video! But I didn't really get the counts dictionary logic: it isn't related to month or year so I feel like it counts workouts on 22th October and 22th November together in my code
How was it supposed to work? I am confused :0
That is because there is a predicate for the workouts query that limits the workouts top the current month only.
let predicate = #Predicate {$0.date >= date.startOfMonth && $0.date < endOfMonthAdjustment}
Great work
thank you
There's another problem, it's about weekdays naming. You're taking first letters of day names, which is fine for English (SMTWTFS), and works fine for some other locales (for example, for Russian: ПВСЧПСВ, although it's more common to use two letters in Russian: Пн, Вт, Ср, etc.) There's a problem with Chinese, because names for Chinese weekdays are 週一,週二,週三 and so on. 週 means "week", and 一二三 are just numbers, and I think you already see what's the problem here.
At that point, you're not talking about full localization.
After all, if you're going to localize just part of a calendar, you might as well localize everything.
And, IMO, that should only be done post launch.
i.e. see if there is a real demand for the app first, before commiting to expensive localization efforts.
@@w0mblemania I'd argue that "dateFormatter.setLocalizedDateFormatFromTemplate("EEEEE")" will do exactly that, what Mr. Lynch tries to achieve.
if you add `calendar.locale = Locale(identifier: "zh-CN")` to the 'capitlisedFirstLettersOfWeekday` I would also remove taking the `first` letter too.
Shalom, are you from Israel?
?? No. I am Canadian,
Stewart! thank you so much for this video!
I had a question regarding the pros and cons of this custom calendar tallies view vs. this video? what are your pros and cons to these methods? UIcalendarView th-cam.com/video/d8KYAeBDQAQ/w-d-xo.html
it seems like the UICalendarView is fairly simplistic, but struggles with customization long term.But prodomenitly works for UIKit. to implement this into SwiftUI seems a little difficult. However, this Custom Calendar Tallies seems to be better for customization is is already for SwiftUI. just more coding for customization. thanks in advance :)
Great video. I have pick up a few points from these video for my calendar. Just one thing when using Picker do not use “” for label put the title as this will not read in Voice Over and then use modifier .labelHidden.
Good point!