Closed workingDog closed 5 years ago
new update
Hi Raffi,
I was in need of a time selection in my app, so I added the functionality to RKCalendar.
https://github.com/workingDog/RKCalendar https://github.com/workingDog/RKCalendar
Could you have a look at it with the view to a merge if this function is agreeable.
Ringo
On Oct 22, 2019, at 1:41, RaffiKian notifications@github.com wrote:
Merged #2 https://github.com/RaffiKian/RKCalendar/pull/2 into master.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AAZ6GDHWXIHRIJ2JJGQLEMTQPXLUNA5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOUK7MI5I#event-2730411125, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ6GDDYOB5L7N7YUGVTS6LQPXLUNANCNFSM4IKPWLUA.
Hello Raffi,
I would like to incorporate your calendar code in a project that I am working on to learn SwiftUI. Since I am still somewhat in the learning stage, I'm not exactly sure how to do this. Would it be possible to point me in the right direction? I'm doing things a little differently than your examples. I'm don't want to use a sheet. I want the calendar to be in a list at the top half of a screen and have the selected date display a list of items for that particular day in the bottom half of the screen. I'm pretty sure that I can handle that part of it. I just wanted to be sure that I am displaying the correct months since it needs to be able to view both previous and future months. Any guidance you could give would be greatly appreciated. You can email me at lburris@mac.com if you'd like to help.
Many thanks, Larry Burris
Hi Larry,
To show RKViewController without a sheet, just use it on its own as in the example below. The RKViewController months are already in a List, so there is no need for another one. To show the months/days you want to display simply adjust, minimumDate and maximumDate. For example:
struct ContentView2: View {
@State var isPresented = false // not relevant for this example
var rkManager1 = RKManager(calendar: Calendar.current,
minimumDate: Date().addingTimeInterval(-60*60*24*182), // ~6 months before today
maximumDate: Date().addingTimeInterval(60*60*24*182), // ~6 months after today
mode: 0)
var body: some View {
Group {
VStack {
RKViewController(isPresented: self.$isPresented, rkManager: rkManager1)
}
List {
Text("item1")
Text("item2")
Text("item3")
Text("item4")
Text("item5")
Text("item6")
}
}
}
}
Thanks so much for getting back to me. I believe that I have a handle on it now. I wasn’t expecting it to be this easy!!
On Nov 3, 2019, at 7:33 AM, workingDog notifications@github.com wrote:
Hi Larry,
To show RKViewController without a sheet, just use it on its own as in the example below. The RKViewController months are already in a List, so there is no need for another one. To show the months/days you want to display simply adjust, minimumDate and maximumDate. For example:
struct ContentView2: View { @State var isPresented = false // not relevant for this example var rkManager1 = RKManager(calendar: Calendar.current, minimumDate: Date().addingTimeInterval(-606024182), // ~6 months before today maximumDate: Date().addingTimeInterval(606024182), // ~6 months after today mode: 0) var body: some View { Group { VStack { RKViewController(isPresented: self.$isPresented, rkManager: rkManager1) } List { Text("item1") Text("item2") Text("item3") Text("item4") Text("item5") Text("item6") } } } } — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AA6EP22I6KDENLXBVGZHFDLQR3AKBA5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC5RP2Y#issuecomment-549132267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6EP2YZFIM6B3V2FCBSOUTQR3AKBANCNFSM4IKPWLUA.
Raffi,
Please excuse my ignorance, but I’ve looked at your code and I’m not seeing exactly how you are detecting the date selection. I see the code that references the manager for the selected date but I’m not seeing what triggers it. I’m sure that it’s going to be something staring me right in the face but I’m just not seeing it at 4 AM. I have successfully incorporated the calendar into my code. I’m always going to be displaying full months from October till June so it was easy to calculate the date information. I just need to detect the date selection and my problems will be solved.
I thank you again for your help! Your calendar rocks!
~ Larry
On Nov 3, 2019, at 7:33 AM, workingDog notifications@github.com wrote:
Hi Larry,
To show RKViewController without a sheet, just use it on its own as in the example below. The RKViewController months are already in a List, so there is no need for another one. To show the months/days you want to display simply adjust, minimumDate and maximumDate. For example:
struct ContentView2: View { @State var isPresented = false // not relevant for this example var rkManager1 = RKManager(calendar: Calendar.current, minimumDate: Date().addingTimeInterval(-606024182), // ~6 months before today maximumDate: Date().addingTimeInterval(606024182), // ~6 months after today mode: 0) var body: some View { Group { VStack { RKViewController(isPresented: self.$isPresented, rkManager: rkManager1) } List { Text("item1") Text("item2") Text("item3") Text("item4") Text("item5") Text("item6") } } } } — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AA6EP22I6KDENLXBVGZHFDLQR3AKBA5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC5RP2Y#issuecomment-549132267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6EP2YZFIM6B3V2FCBSOUTQR3AKBANCNFSM4IKPWLUA.
Hi Larry,
In RKMonth a TapGesture is attached to a RKCell, so when a tap event is detected, .onTapGesture { self.dateTapped(date: column) is called.
In dateTapped() the rkManager.selectedDate is updated.
Now rkManager is an observedObject, which means you don't "detect" where the date selection is done. You simply use rkManager.selectedDate, and by magic the value is updated for you wherever you have it in your code and the views will be updated as well.
Ringo
Great!! Thanks for the help!!
On Nov 4, 2019, at 9:14 PM, workingDog notifications@github.com wrote:
Hi Larry,
In RKMonth a TapGesture is attached to a RKCell, so when a tap event is detected, .onTapGesture { self.dateTapped(date: column) is called.
In dateTapped() the rkManager.selectedDate is updated.
Now rkManager.selectedDate is an observableObject, which means you don't "detect" where the date selection is done. You simply use rkManager.selectedDate, and by magic the value is updated for you wherever you have it in your code and the views will be updated as well.
Ringo
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AA6EP22NKORW7HHTHAA7ZMTQSDJG5A5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDBLUFA#issuecomment-549632532, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6EP2ZOT4JISJJJ3YDGTATQSDJG5ANCNFSM4IKPWLUA.
Hello,
I appreciate you getting back to me last month! I have everything working exactly as I want with one small exception. Instead of displaying the calendars in a list, would it be possible to to display one calendar at a time inside a drag gesture going left/right? Since I am using the calendar in the top half of a screen, it’s impossible to display a single month without some overlap of another month because not all months have the same number of rows in them. My plan is to split the screen to the max size of a single calendar and let the user select the calendar by dragging from left/right. Since each calendar is the same width, this seems to be the best solution for me.
Would it be possible to add that option to your calendar code? Or maybe provide a previous/next button to allow the user to select one month at a time within the constraints of the number of months in the list?
Any guidance you could give would be greatly appreciated!
Many thanks, Larry
On Nov 3, 2019, at 7:56 PM, Lawrence Burris lburris@mac.com wrote:
Thanks so much for getting back to me. I believe that I have a handle on it now. I wasn’t expecting it to be this easy!!
On Nov 3, 2019, at 7:33 AM, workingDog <notifications@github.com mailto:notifications@github.com> wrote:
Hi Larry,
To show RKViewController without a sheet, just use it on its own as in the example below. The RKViewController months are already in a List, so there is no need for another one. To show the months/days you want to display simply adjust, minimumDate and maximumDate. For example:
struct ContentView2: View { @State var isPresented = false // not relevant for this example var rkManager1 = RKManager(calendar: Calendar.current, minimumDate: Date().addingTimeInterval(-606024182), // ~6 months before today maximumDate: Date().addingTimeInterval(606024182), // ~6 months after today mode: 0) var body: some View { Group { VStack { RKViewController(isPresented: self.$isPresented, rkManager: rkManager1) } List { Text("item1") Text("item2") Text("item3") Text("item4") Text("item5") Text("item6") } } } } — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AA6EP22I6KDENLXBVGZHFDLQR3AKBA5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC5RP2Y#issuecomment-549132267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6EP2YZFIM6B3V2FCBSOUTQR3AKBANCNFSM4IKPWLUA.
Hi Larry,
I guess you are asking for a horizontal scrolling of the calendar, then this is one way you could start.
In RKManager add: @Published var isVertical = true (or false)
In RKViewController:
replace:
// RKWeekdayHeader(rkManager: self.rkManager).padding(.top, 15) // Divider() // List { // ForEach(0..<numberOfMonths()) { index in // RKMonth(isPresented: self.$isPresented, rkManager: self.rkManager, monthOffset: index) // } // Divider() // }
with:
rkManager.isVertical ?
AnyView(Group {
RKWeekdayHeader(rkManager: self.rkManager)
Divider()
List {
ForEach(0..<numberOfMonths()) { index in
RKMonth(isPresented: self.$isPresented, rkManager: self.rkManager, monthOffset: index)
}
Divider()
}
})
:
AnyView(ScrollView (.horizontal) {
HStack {
ForEach(0..<numberOfMonths()) { index in
VStack {
RKWeekdayHeader(rkManager: self.rkManager)
RKMonth(isPresented: self.$isPresented, rkManager: self.rkManager, monthOffset: index)
}
Divider()
}
}
})
I will not put this in my code for the moment because it is not polished enough.
Hope it helps.
Ringo
On Jan 6, 2020, at 16:24, lburris57 notifications@github.com wrote:
Hello,
I appreciate you getting back to me last month! I have everything working exactly as I want with one small exception. Instead of displaying the calendars in a list, would it be possible to to display one calendar at a time inside a drag gesture going left/right? Since I am using the calendar in the top half of a screen, it’s impossible to display a single month without some overlap of another month because not all months have the same number of rows in them. My plan is to split the screen to the max size of a single calendar and let the user select the calendar by dragging from left/right. Since each calendar is the same width, this seems to be the best solution for me.
Would it be possible to add that option to your calendar code? Or maybe provide a previous/next button to allow the user to select one month at a time within the constraints of the number of months in the list?
Any guidance you could give would be greatly appreciated!
Many thanks, Larry
On Nov 3, 2019, at 7:56 PM, Lawrence Burris lburris@mac.com wrote:
Thanks so much for getting back to me. I believe that I have a handle on it now. I wasn’t expecting it to be this easy!!
On Nov 3, 2019, at 7:33 AM, workingDog <notifications@github.com mailto:notifications@github.com> wrote:
Hi Larry,
To show RKViewController without a sheet, just use it on its own as in the example below. The RKViewController months are already in a List, so there is no need for another one. To show the months/days you want to display simply adjust, minimumDate and maximumDate. For example:
struct ContentView2: View { @State var isPresented = false // not relevant for this example var rkManager1 = RKManager(calendar: Calendar.current, minimumDate: Date().addingTimeInterval(-606024182), // ~6 months before today maximumDate: Date().addingTimeInterval(606024182), // ~6 months after today mode: 0) var body: some View { Group { VStack { RKViewController(isPresented: self.$isPresented, rkManager: rkManager1) } List { Text("item1") Text("item2") Text("item3") Text("item4") Text("item5") Text("item6") } } } } — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AA6EP22I6KDENLXBVGZHFDLQR3AKBA5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC5RP2Y#issuecomment-549132267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6EP2YZFIM6B3V2FCBSOUTQR3AKBANCNFSM4IKPWLUA.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AAZ6GDH4BF5ZFVNGJDYDDK3Q4LMDVA5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIEURZQ#issuecomment-571033830, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ6GDA7MMDOHHJ3R2ZLMPLQ4LMDVANCNFSM4IKPWLUA.
it looks a bit better if you use:
AnyView(ScrollView (.horizontal) {
HStack {
ForEach(0..<numberOfMonths()) { index in
VStack {
RKWeekdayHeader(rkManager: self.rkManager)
Divider()
RKMonth(isPresented: self.$isPresented, rkManager: self.rkManager, monthOffset: index)
Spacer()
}
Divider()
}
}
})
I can’t thank you enough for the help! I’ll try this and let you know! Your calendar code is awesome!
On Jan 7, 2020, at 3:28 AM, workingDog notifications@github.com wrote:
it looks a bit better if you use:
AnyView(ScrollView (.horizontal) { HStack { ForEach(0..<numberOfMonths()) { index in VStack { RKWeekdayHeader(rkManager: self.rkManager) Divider() RKMonth(isPresented: self.$isPresented, rkManager: self.rkManager, monthOffset: index) Spacer() } Divider() } } })
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AA6EP2ZJU637R2XU47N4HYTQ4Q4JHA5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIIDBYQ#issuecomment-571486434, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6EP2ZVMVDU6P5ECFZF2VDQ4Q4JHANCNFSM4IKPWLUA.
Hi Larry,
I've updated my calendar code to include an horizontal view and a few other bits, see the examples. https://github.com/workingDog/RKCalendar Let me know if this works.
Hi Ringo,
I am having issues with the code compiling. It complains that it can’t find the files located in the ClockPicker directory although they are clearly there. I simply cloned the file from GitHub and tried to build and run it. I’m not quite sure what the problem might be.
I want to thank you very much for taking the time and effort to add these capabilities!
Larry
On Jan 9, 2020, at 1:09 AM, workingDog notifications@github.com wrote:
Hi Larry,
I've updated my calendar code to include an horizontal view and a few other bits, see the examples. https://github.com/workingDog/RKCalendar https://github.com/workingDog/RKCalendar Let me know if this works.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AA6EP2ZBQEIM4ZXZMDJXCOLQ425TFA5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIPDPRY#issuecomment-572405703, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6EP25KG7ZGY6UDU6GVDIDQ425TFANCNFSM4IKPWLUA.
Hi Ringo,
It turns out that all I had to do was to remove the ClockPicker directory and everything works fine. However, I have the same problem in the fact that the calendars overlap in the screen instead of showing a single calendar per screen. I think that I have solved my problem in a different way.
I changed the code to only display a single calendar at a time and I added Previous and Next buttons which will allow the user to display one calendar view at a time in either direction. Of course, I need to write the code to make that happen and to only display the buttons when it makes sense but I believe that this is the functionality that would work best for me.
I can show you my solution along with the code once I have completed it if you are interested. There’s a screen shot below...
Again, I can’t thank you enough for taking the time and effort to help me with my project!!
Larry
On Jan 9, 2020, at 1:09 AM, workingDog notifications@github.com wrote:
Hi Larry,
I've updated my calendar code to include an horizontal view and a few other bits, see the examples. https://github.com/workingDog/RKCalendar https://github.com/workingDog/RKCalendar Let me know if this works.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AA6EP2ZBQEIM4ZXZMDJXCOLQ425TFA5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIPDPRY#issuecomment-572405703, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6EP25KG7ZGY6UDU6GVDIDQ425TFANCNFSM4IKPWLUA.
Hi Larry,
I'm glad you got the code working, maybe for some reason the ClockPicker was included in the code update.
As I understand SwiftUI ScrollView does not yet have the capability to do paging that allows one "page" to be display at one time. Maybe the next version of SwiftUI will have that feature.
I would be interested in your code once you have it working.
I could not see the screenshot.
Ringo
Hi Larry,
I've added a number of things to the code, including a paging function to display one month at a time, both for vertical and horizontal scrolling.
Let me know if this works for you.
Ringo
Hi Ringo,
Might be a few days. Crushed one of my fingers in a hinged adjustable bed yesterday morning. Hand in a soft cast. No one ever accused me of being graceful!
I will check it out soon. Thanks again for all your help.
Larry
Sent from my iPhone
On Jan 11, 2020, at 3:11 AM, workingDog notifications@github.com wrote:
Hi Larry,
I've added a number of things to the code, including a paging function to display one month at a time, both for vertical and horizontal scrolling.
Let me know if this works for you.
Ringo
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Hey Ringo,
That’s EXACTLY what I was looking for! Thanks for all your help!
Larry
On Jan 11, 2020, at 3:09 AM, workingDog notifications@github.com wrote:
Hi Larry,
I've added a number of things to the code, including a paging function to display one month at a time, both for vertical and horizontal scrolling.
Let me know if this works for you.
Ringo
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RaffiKian/RKCalendar/pull/2?email_source=notifications&email_token=AA6EP22LQNHUVQNRQMMH46TQ5F5EFA5CNFSM4IKPWLUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIV4KPI#issuecomment-573293885, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6EP2ZVTQFFNZPLC7K3MF3Q5F5EFANCNFSM4IKPWLUA.
compatibility with xCode beta 5 added selectedDates: [Date] to RKManager added a new mode=3 for the selectedDates some other bits