richardtop / CalendarKit

📅 Calendar for Apple platforms in Swift
https://www.youtube.com/watch?v=cJ63-_z1qg8
MIT License
2.49k stars 334 forks source link

currentTimeIndicator #301

Closed akki147 closed 3 years ago

akki147 commented 3 years ago

I am using this library as child to my accordance but the time indicator show the correct time but the place where it shows, is wrong? can you please help me out to get over from this issue.

richardtop commented 3 years ago

Please attach screenshots and the sample code.

akki147 commented 3 years ago

Simulator Screen Shot - iPhone 8 - 2021-04-02 at 15 47 50 take a glance and you will find three errors :

  1. Current time shown wrong place
  2. events also start time is different and the place time is different
  3. you can place your event view across the view bounds
akki147 commented 3 years ago

@IBAction func changeViewTap(_ sender: UIButton) { sender.isHighlighted = false sender.isSelected = !sender.isSelected if sender.isSelected { self.btnChangevw.backgroundColor = .clear tblView.isHidden = sender.isSelected timeLineVw.isHidden = !sender.isSelected let controller = CustomCalendarExampleController() controller.view.frame = self.timeLineVw.bounds addChild(controller) self.timeLineVw.addSubview(controller.view) controller.didMove(toParent: self) }else { tblView.isHidden = sender.isSelected timeLineVw.isHidden = !sender.isSelected }

}
richardtop commented 3 years ago

Please, share all the integration code you are using with the CK.

akki147 commented 3 years ago

I hadn't done think except showing the calendar kit. this is the only code I had done.

akki147 commented 3 years ago

Date instance you Are using is not giving the correct Date and Time Screen Shot 2021-04-06 at 3 31 18 PM on debug I found issue on this function

akki147 commented 3 years ago

Please Describe me what is provisioned time and timeline time and date offset hereafter I can place current time indicator on the correct place

richardtop commented 3 years ago
  1. Provisioned date: the date which has been passed to the dateToY function, but stripped of of any time component (i.e. the date should start at exactly midnight in the current time zone)
  2. TimelineDate - the date (stripped of of any time components as well) of the Timeline the code is running.
  3. DayOffset - If one of those two dates is earlier or later than another, a day offset is applied, i.e. the whole length of the timeline should be added or subtracted. This is needed to handle multi-day events.
akki147 commented 3 years ago

what is dateOnly function for why we passed calendar and style.verticaldifference is static so it is dependent constant or independent constant?

akki147 commented 3 years ago

Problem Solved:----->

public func dateToY(_ date: Date) -> CGFloat { //let provisionedDate = date.dateOnly(calendar: calendar) let provisionedDate = date.toLocalTime() print("provisionedDate=====(provisionedDate)") let timelineDate = date.toLocalTime() // let timelineDate = self.date.toLocalTime() print("timelineDate=====(timelineDate)") // Calendar(identifier: .gregorian) var dayOffset: CGFloat = 0 if provisionedDate > timelineDate { // Event ending the next day dayOffset += 1 } else if provisionedDate < timelineDate { // Event starting the previous day dayOffset -= 1 } print("dayOffset( dayOffset)") let fullTimelineHeight = 23 style.verticalDiff //100 24 = 2400 full height of calendar // let hour = component(component: .hour, from: date.toLocalTime()) let hour = Calendar.current.component(.hour, from: Date()) print("hour--> (hour), (date)") //let minute = component(component: .minute, from: date.toLocalTime()) let minute = Calendar.current.component(.minute, from: Date()) let hourY = CGFloat(hour) style.verticalDiff + style.verticalInset let minuteY = CGFloat(minute) style.verticalDiff / 60 print("hourY, minuteY( hourY), ( minuteY)") print("hourY + minuteY + CGFloat(fullTimelineHeight) dayOffset---->(hourY + minuteY + CGFloat(fullTimelineHeight) dayOffset)") return hourY + minuteY + CGFloat(fullTimelineHeight) * dayOffset }

toLocal is the function to change the date in local of any timezone

richardtop commented 3 years ago

Issue confirmed, fixed in 1.0.0. Please, update the library version you're using.