Open simbo64 opened 4 years ago
Does anyone have a solution to this issue?
I have a possible solution in my experimental branch: exp1
https://github.com/workingDog/RKCalendar
until SwiftUI implements it.
let me know if it works.
(note it does not yet work for weekly view)
It works great. Thank you!
what files were edited and/or needed in order to achieve this?
Note somehow this experimental code ended up in the master branch. In the master branch,
I added ScrollableView in RKScroll,
and modified RKViewController as follows:
added
@State private var contentOffset = CGPoint.zero line: 19
todayVScrollPos() and todayHScrollPos() lines: 166 and 176
added at lines 100 for verticalView, and 119 for horizontalView:
.onAppear(perform: { self.contentOffset = self.todayHScrollPos() })
Let me know if this works.
I forgot the important bit, I replaced ScrollView(.vertical) with ScrollableView(self.$contentOffset) at lines: 87 and 105
@workingDog forgive me. I am new to swift. I am using the original RKManager files in the Raffikian repository. If I add those few lines to those files from their repository will it still work? Or do I need to download your files in order to achieve this
You need to download my repo. I thought you were asking about what I did to implement this feature in my repo. My answer should have mentioned this, sorry.
https://github.com/workingDog/RKCalendar
Just download the master branch.
okay last issue and I promise im done lol. I've got it working! however, your's uses a done button. is there a way to revert that back to onClick of a date to close the calendar?
no problems ask away.
First the done button is really for when you use it on macos. To remove it comment the lines (25 to 30) with the "Button(action: onDone) ..." in RKViewController.
Then to close when clicking on a date, in RKMonth --> func dateTapped(date: Date) add "self.isPresented = false" at the end of the cases you want.
Let me know if this works.
@workingDog I've been playing with this problem for several days now. So the app I am working on populates a database from Jan 1, 2020 -> 400 days in the future. Through testing, I know those days are populated. When I launch the calendar to select a day, it starts at the current day, but does not let me see into the past and it also has me limited to 11 months into the future. If I select, say July 1, 2020, when I relaunch the calendar I can only see from July 1 to the previous end date. Any ideas?
@workingDog after rebuilding, I have the correct date range, but now going into the calendar doesn't focus on the selected date. it only goes to the current date 4/6/2020
I'm glad you got the range working. As for the focus date, the current behaviour is to start at the current date. I'll investigate on starting on the selected date.
In the mean time you could try this:
replace Date() with rkManager.selectedDate in RKViewController -> todayVScrollPos() lines 167 and 168 and also in RKViewController -> todayHScrollPos() lines 177 and 178
There maybe some unexpected side effects.
@workingDog I solved this. Adding rkmManager.selectedDate where you said to works. You just have to assure that rkManager.selected is instantiated before called to RKViewController for the first time. Thank you so much!
I suspect this is something to do with Lists in SwiftUI, but if you give the start date to the RKManager as a date in the past, the calendar starts at that date. I suspect most users desired behaviour would be the calendar always starts on the current date and then the user scrolls up or down to the section they want?