expo-calendar-kit 2.1.6 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,403 +1,265 @@
1
1
  import ExpoModulesCore
2
2
  import UIKit
3
- import EventKit
4
3
  import CalendarKit
4
+ import EventKit
5
5
 
6
- // MARK: - Event Models
7
- struct CalendarEvent {
8
- let id: String
9
- let title: String
10
- let startDate: Date
11
- let endDate: Date
12
- let color: UIColor?
13
- let backgroundColor: UIColor?
14
- let isAllDay: Bool
15
- let location: String?
16
- let notes: String?
17
- let userInfo: [String: Any]?
18
-
19
- init(from dict: [String: Any]) {
20
- self.id = dict["id"] as? String ?? UUID().uuidString
21
- self.title = dict["title"] as? String ?? ""
22
-
23
- // Handle date parsing
24
- if let startTimestamp = dict["startDate"] as? Double {
25
- self.startDate = Date(timeIntervalSince1970: startTimestamp / 1000)
26
- } else {
27
- self.startDate = Date()
6
+ // MARK: - MyEKWrapper (copied from CalendarApp, renamed to avoid conflicts)
7
+ final class MyEKWrapper: EventDescriptor {
8
+ public var dateInterval: DateInterval {
9
+ get {
10
+ DateInterval(start: ekEvent.startDate, end: ekEvent.endDate)
28
11
  }
29
12
 
30
- if let endTimestamp = dict["endDate"] as? Double {
31
- self.endDate = Date(timeIntervalSince1970: endTimestamp / 1000)
32
- } else {
33
- self.endDate = Date().addingTimeInterval(3600) // 1 hour later
13
+ set {
14
+ ekEvent.startDate = newValue.start
15
+ ekEvent.endDate = newValue.end
34
16
  }
35
-
36
- // Handle colors
37
- if let colorHex = dict["color"] as? String {
38
- self.color = UIColor(hex: colorHex)
39
- } else {
40
- self.color = nil
17
+ }
18
+
19
+ public var isAllDay: Bool {
20
+ get {
21
+ ekEvent.isAllDay
41
22
  }
42
-
43
- if let backgroundColorHex = dict["backgroundColor"] as? String {
44
- self.backgroundColor = UIColor(hex: backgroundColorHex)
45
- } else {
46
- self.backgroundColor = nil
23
+ set {
24
+ ekEvent.isAllDay = newValue
47
25
  }
48
-
49
- self.isAllDay = dict["isAllDay"] as? Bool ?? false
50
- self.location = dict["location"] as? String
51
- self.notes = dict["notes"] as? String
52
- self.userInfo = dict["userInfo"] as? [String: Any]
53
26
  }
54
27
 
55
- // Convert to EventKit EKEvent for use with CalendarKit
56
- func toEKEvent() -> EKEvent {
57
- let ekEvent = EKEvent(eventStore: EKEventStore())
58
- ekEvent.title = self.title
59
- ekEvent.startDate = self.startDate
60
- ekEvent.endDate = self.endDate
61
- ekEvent.isAllDay = self.isAllDay
62
- if let location = self.location {
63
- ekEvent.location = location
28
+ public var text: String {
29
+ get {
30
+ ekEvent.title
64
31
  }
65
- if let notes = self.notes {
66
- ekEvent.notes = notes
32
+
33
+ set {
34
+ ekEvent.title = newValue
67
35
  }
68
- // Store the original ID in the notes if notes is empty
69
- if ekEvent.notes?.isEmpty != false {
70
- ekEvent.notes = "ExpoCalendarKit_ID:\(self.id)"
36
+ }
37
+
38
+ public var attributedText: NSAttributedString?
39
+ public var lineBreakMode: NSLineBreakMode?
40
+
41
+ public var color: UIColor {
42
+ get {
43
+ UIColor(cgColor: ekEvent.calendar.cgColor)
71
44
  }
72
- return ekEvent
73
45
  }
74
46
 
75
- // Extract original ID from EKEvent
76
- static func extractOriginalId(from ekEvent: EKEvent) -> String? {
77
- if let notes = ekEvent.notes, notes.hasPrefix("ExpoCalendarKit_ID:") {
78
- return String(notes.dropFirst("ExpoCalendarKit_ID:".count))
47
+ public var backgroundColor = UIColor()
48
+ public var textColor = SystemColors.label
49
+ public var font = UIFont.boldSystemFont(ofSize: 12)
50
+ public weak var editedEvent: EventDescriptor? {
51
+ didSet {
52
+ updateColors()
79
53
  }
80
- return nil
81
54
  }
82
- }
83
-
84
- // MARK: - Main Calendar View
85
- public class ExpoCalendarKitView: UIView, DayViewDelegate, EventDataSource {
86
- private var dayView: DayView!
87
- private var events: [CalendarEvent] = []
88
- private var currentDate: Date = Date()
89
55
 
90
- // Style properties
91
- private var customCalendarStyle = ExpoCalendarStyle()
56
+ public private(set) var ekEvent: EKEvent
92
57
 
93
- // Event callbacks - using closures for callback
94
- var onEventPress: ((String) -> Void)?
95
- var onEventLongPress: ((String) -> Void)?
96
- var onTimePress: ((Double) -> Void)?
97
- var onTimeLongPress: ((Double) -> Void)?
98
- var onDateChanged: ((Double) -> Void)?
58
+ public init(eventKitEvent: EKEvent) {
59
+ self.ekEvent = eventKitEvent
60
+ applyStandardColors()
61
+ }
99
62
 
100
- public override init(frame: CGRect) {
101
- print("🔥 ExpoCalendarKitView init called with frame: \(frame)")
102
- super.init(frame: frame)
103
- setupCalendarView()
63
+ public func makeEditable() -> MyEKWrapper {
64
+ let cloned = MyEKWrapper(eventKitEvent: ekEvent)
65
+ cloned.editedEvent = self
66
+ return cloned
104
67
  }
105
68
 
106
- required public init?(coder: NSCoder) {
107
- super.init(coder: coder)
108
- setupCalendarView()
69
+ public func commitEditing() {
70
+ guard let edited = editedEvent else {return}
71
+ edited.dateInterval = dateInterval
109
72
  }
110
73
 
111
- private func setupCalendarView() {
112
- print("🔥 setupCalendarView called")
113
-
114
- dayView = DayView()
115
- dayView.delegate = self
116
- dayView.dataSource = self
117
- dayView.translatesAutoresizingMaskIntoConstraints = false
118
- addSubview(dayView)
119
-
120
- NSLayoutConstraint.activate([
121
- dayView.topAnchor.constraint(equalTo: topAnchor),
122
- dayView.leadingAnchor.constraint(equalTo: leadingAnchor),
123
- dayView.trailingAnchor.constraint(equalTo: trailingAnchor),
124
- dayView.bottomAnchor.constraint(equalTo: bottomAnchor)
125
- ])
126
-
127
- // Apply default style
128
- applyStyle()
129
-
130
- // Set initial date
131
- dayView.move(to: currentDate)
132
-
133
- print("🔥 CalendarKit DayView setup complete")
74
+ private func updateColors() {
75
+ (editedEvent != nil) ? applyEditingColors() : applyStandardColors()
134
76
  }
135
77
 
136
- // MARK: - Public Methods
137
- public func setEvents(_ eventDicts: [[String: Any]]) {
138
- print("🔥 setEvents called with \(eventDicts.count) events")
139
- self.events = eventDicts.map { CalendarEvent(from: $0) }
140
- print("🔥 Converted to \(self.events.count) CalendarEvent objects")
141
- for (index, event) in self.events.enumerated() {
142
- print("🔥 Event \(index): \(event.title) from \(event.startDate) to \(event.endDate)")
143
- }
144
- if let dayView = dayView {
145
- dayView.reloadData()
146
- }
78
+ /// Colors used when event is not in editing mode
79
+ private func applyStandardColors() {
80
+ backgroundColor = dynamicStandardBackgroundColor()
81
+ textColor = dynamicStandardTextColor()
147
82
  }
148
83
 
149
- public func setDate(_ timestamp: Double) {
150
- self.currentDate = Date(timeIntervalSince1970: timestamp / 1000)
151
- if let dayView = dayView {
152
- dayView.move(to: currentDate)
153
- }
84
+ /// Colors used in editing mode
85
+ private func applyEditingColors() {
86
+ backgroundColor = color.withAlphaComponent(0.95)
87
+ textColor = .white
154
88
  }
155
89
 
156
- public func updateStyle(_ styleDict: [String: Any]) {
157
- customCalendarStyle.update(from: styleDict)
158
- applyStyle()
90
+ /// Dynamic color that changes depending on the user interface style (dark / light)
91
+ private func dynamicStandardBackgroundColor() -> UIColor {
92
+ let light = backgroundColorForLightTheme(baseColor: color)
93
+ let dark = backgroundColorForDarkTheme(baseColor: color)
94
+ return dynamicColor(light: light, dark: dark)
159
95
  }
160
96
 
161
- public func scrollToCurrentTime() {
162
- if let dayView = dayView {
163
- dayView.scrollTo(hour24: Float(Calendar.current.component(.hour, from: Date())))
164
- }
97
+ /// Dynamic color that changes depending on the user interface style (dark / light)
98
+ private func dynamicStandardTextColor() -> UIColor {
99
+ let light = textColorForLightTheme(baseColor: color)
100
+ return dynamicColor(light: light, dark: color)
165
101
  }
166
102
 
167
- private func applyStyle() {
168
- guard let dayView = dayView else { return }
169
-
170
- var style = CalendarStyle()
171
-
172
- // Apply only the colors that are supported by CalendarKit
173
- if let headerBgColor = customCalendarStyle.headerBackgroundColor {
174
- style.header.backgroundColor = headerBgColor
175
- }
176
-
177
- if let timelineBgColor = customCalendarStyle.timelineBackgroundColor {
178
- style.timeline.backgroundColor = timelineBgColor
179
- }
180
-
181
- if let timeTextColor = customCalendarStyle.timeTextColor {
182
- style.timeline.timeColor = timeTextColor
183
- }
184
-
185
- if let separatorColor = customCalendarStyle.separatorColor {
186
- style.timeline.separatorColor = separatorColor
187
- }
188
-
189
- dayView.updateStyle(style)
103
+ private func textColorForLightTheme(baseColor: UIColor) -> UIColor {
104
+ var h: CGFloat = 0, s: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0
105
+ baseColor.getHue(&h, saturation: &s, brightness: &b, alpha: &a)
106
+ return UIColor(hue: h, saturation: s, brightness: b * 0.4, alpha: a)
190
107
  }
191
108
 
192
- // MARK: - EventDataSource
193
- public func eventsForDate(_ date: Date) -> [EventDescriptor] {
194
- let calendar = Calendar.current
109
+ private func backgroundColorForLightTheme(baseColor: UIColor) -> UIColor {
110
+ baseColor.withAlphaComponent(0.3)
111
+ }
112
+
113
+ private func backgroundColorForDarkTheme(baseColor: UIColor) -> UIColor {
114
+ var h: CGFloat = 0, s: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0
115
+ color.getHue(&h, saturation: &s, brightness: &b, alpha: &a)
116
+ return UIColor(hue: h, saturation: s, brightness: b * 0.4, alpha: a * 0.8)
117
+ }
118
+
119
+ private func dynamicColor(light: UIColor, dark: UIColor) -> UIColor {
120
+ if #available(iOS 13.0, *) {
121
+ return UIColor { traitCollection in
122
+ let interfaceStyle = traitCollection.userInterfaceStyle
123
+ switch interfaceStyle {
124
+ case .dark:
125
+ return dark
126
+ default:
127
+ return light
128
+ }
129
+ }
130
+ } else {
131
+ return light
132
+ }
133
+ }
134
+ }
135
+
136
+ // MARK: - Calendar View Controller (following CalendarApp pattern)
137
+ final class CalendarViewController: DayViewController {
138
+ private var eventStore = EKEventStore() // Not used but needed for EKEvent creation
139
+
140
+ override func viewDidLoad() {
141
+ super.viewDidLoad()
142
+ print("🔥 CalendarViewController viewDidLoad called")
143
+ // Don't request calendar access - we'll use hardcoded events
144
+ }
145
+
146
+ // MARK: - DayViewDataSource
147
+
148
+ // This is the main method - following CalendarApp pattern exactly
149
+ override func eventsForDate(_ date: Date) -> [EventDescriptor] {
195
150
  print("🔥 eventsForDate called for \(date)")
196
151
 
197
- // HARDCODED EVENTS FOR TESTING - Following CalendarKit docs exactly
198
- let today = Date()
152
+ let calendar = Calendar.current
199
153
 
200
154
  // Check if the requested date is today
201
- guard calendar.isDate(date, inSameDayAs: today) else {
155
+ guard calendar.isDate(date, inSameDayAs: Date()) else {
202
156
  print("🔥 Not today, returning empty events")
203
157
  return []
204
158
  }
205
159
 
206
- print("🔥 Creating hardcoded events for today")
160
+ print("🔥 Creating hardcoded events for today using CalendarApp pattern")
207
161
 
208
- // Create events using CalendarKit's Event class (EventDescriptor)
209
- var events = [Event]()
162
+ // Create hardcoded events using EKEvent (like CalendarApp)
163
+ var events: [MyEKWrapper] = []
210
164
 
211
165
  // Event 1: Meeting
212
- let meeting = Event()
213
- let meetingStart = calendar.date(bySettingHour: 10, minute: 0, second: 0, of: today) ?? today
214
- let meetingEnd = calendar.date(bySettingHour: 11, minute: 0, second: 0, of: today) ?? today
215
- meeting.dateInterval = DateInterval(start: meetingStart, end: meetingEnd)
216
- meeting.text = "🔥 HARDCODED Meeting\nConference Room A\n10:00 - 11:00"
217
- meeting.color = UIColor.white
218
- meeting.backgroundColor = UIColor.red
219
- events.append(meeting)
166
+ let meetingEvent = EKEvent(eventStore: eventStore)
167
+ meetingEvent.title = "🔥 HARDCODED Meeting"
168
+ meetingEvent.startDate = calendar.date(bySettingHour: 10, minute: 0, second: 0, of: Date()) ?? Date()
169
+ meetingEvent.endDate = calendar.date(bySettingHour: 11, minute: 0, second: 0, of: Date()) ?? Date()
170
+ meetingEvent.calendar = createMockCalendar(color: UIColor.red)
171
+ events.append(MyEKWrapper(eventKitEvent: meetingEvent))
220
172
 
221
173
  // Event 2: Lunch
222
- let lunch = Event()
223
- let lunchStart = calendar.date(bySettingHour: 12, minute: 0, second: 0, of: today) ?? today
224
- let lunchEnd = calendar.date(bySettingHour: 13, minute: 0, second: 0, of: today) ?? today
225
- lunch.dateInterval = DateInterval(start: lunchStart, end: lunchEnd)
226
- lunch.text = "🔥 HARDCODED Lunch\nCafeteria\n12:00 - 13:00"
227
- lunch.color = UIColor.white
228
- lunch.backgroundColor = UIColor.green
229
- events.append(lunch)
174
+ let lunchEvent = EKEvent(eventStore: eventStore)
175
+ lunchEvent.title = "🔥 HARDCODED Lunch"
176
+ lunchEvent.startDate = calendar.date(bySettingHour: 12, minute: 0, second: 0, of: Date()) ?? Date()
177
+ lunchEvent.endDate = calendar.date(bySettingHour: 13, minute: 0, second: 0, of: Date()) ?? Date()
178
+ lunchEvent.calendar = createMockCalendar(color: UIColor.green)
179
+ events.append(MyEKWrapper(eventKitEvent: lunchEvent))
230
180
 
231
181
  // Event 3: Review
232
- let review = Event()
233
- let reviewStart = calendar.date(bySettingHour: 14, minute: 0, second: 0, of: today) ?? today
234
- let reviewEnd = calendar.date(bySettingHour: 15, minute: 0, second: 0, of: today) ?? today
235
- review.dateInterval = DateInterval(start: reviewStart, end: reviewEnd)
236
- review.text = "🔥 HARDCODED Review\nMeeting Room B\n14:00 - 15:00"
237
- review.color = UIColor.white
238
- review.backgroundColor = UIColor.blue
239
- events.append(review)
240
-
241
- print("🔥 Returning \(events.count) hardcoded events for today")
182
+ let reviewEvent = EKEvent(eventStore: eventStore)
183
+ reviewEvent.title = "🔥 HARDCODED Review"
184
+ reviewEvent.startDate = calendar.date(bySettingHour: 14, minute: 0, second: 0, of: Date()) ?? Date()
185
+ reviewEvent.endDate = calendar.date(bySettingHour: 15, minute: 0, second: 0, of: Date()) ?? Date()
186
+ reviewEvent.calendar = createMockCalendar(color: UIColor.blue)
187
+ events.append(MyEKWrapper(eventKitEvent: reviewEvent))
188
+
189
+ print("🔥 Returning \(events.count) hardcoded events")
242
190
  return events
243
191
  }
244
192
 
245
- // MARK: - DayViewDelegate
246
- public func dayViewDidSelectEventView(_ eventView: EventView) {
247
- if let ekWrapper = eventView.descriptor as? EKWrapper {
248
- let eventId = CalendarEvent.extractOriginalId(from: ekWrapper.ekEvent) ?? ekWrapper.ekEvent.title ?? ""
249
- onEventPress?(eventId)
250
- }
193
+ private func createMockCalendar(color: UIColor) -> EKCalendar {
194
+ let calendar = EKCalendar(for: .event, eventStore: eventStore)
195
+ calendar.cgColor = color.cgColor
196
+ return calendar
251
197
  }
252
198
 
253
- public func dayViewDidLongPressEventView(_ eventView: EventView) {
254
- if let ekWrapper = eventView.descriptor as? EKWrapper {
255
- let eventId = CalendarEvent.extractOriginalId(from: ekWrapper.ekEvent) ?? ekWrapper.ekEvent.title ?? ""
256
- onEventLongPress?(eventId)
257
- }
258
- }
199
+ // MARK: - DayViewDelegate
259
200
 
260
- public func dayView(dayView: DayView, didTapTimelineAt date: Date) {
261
- onTimePress?(date.timeIntervalSince1970 * 1000)
201
+ override func dayViewDidSelectEventView(_ eventView: EventView) {
202
+ guard let ckEvent = eventView.descriptor as? MyEKWrapper else {
203
+ return
204
+ }
205
+ print("🔥 Event selected: \(ckEvent.ekEvent.title ?? "Unknown")")
262
206
  }
207
+ }
208
+
209
+ // MARK: - Expo View Wrapper
210
+ public class ExpoCalendarKitView: UIView {
211
+ private var calendarViewController: CalendarViewController!
263
212
 
264
- public func dayView(dayView: DayView, didLongPressTimelineAt date: Date) {
265
- onTimeLongPress?(date.timeIntervalSince1970 * 1000)
213
+ public override init(frame: CGRect) {
214
+ print("🔥 ExpoCalendarKitView init called with frame: \(frame)")
215
+ super.init(frame: frame)
216
+ setupCalendarViewController()
266
217
  }
267
218
 
268
- public func dayViewDidBeginDragging(dayView: DayView) {
269
- // Handle drag begin if needed
219
+ required public init?(coder: NSCoder) {
220
+ super.init(coder: coder)
221
+ setupCalendarViewController()
270
222
  }
271
223
 
272
- public func dayViewDidTransitionCancel(dayView: DayView) {
273
- // Handle transition cancel if needed
224
+ private func setupCalendarViewController() {
225
+ print("🔥 setupCalendarViewController called")
226
+
227
+ calendarViewController = CalendarViewController()
228
+ addSubview(calendarViewController.view)
229
+
230
+ calendarViewController.view.translatesAutoresizingMaskIntoConstraints = false
231
+ NSLayoutConstraint.activate([
232
+ calendarViewController.view.topAnchor.constraint(equalTo: topAnchor),
233
+ calendarViewController.view.leadingAnchor.constraint(equalTo: leadingAnchor),
234
+ calendarViewController.view.trailingAnchor.constraint(equalTo: trailingAnchor),
235
+ calendarViewController.view.bottomAnchor.constraint(equalTo: bottomAnchor)
236
+ ])
237
+
238
+ print("🔥 CalendarViewController setup complete")
274
239
  }
275
240
 
276
- public func dayView(dayView: DayView, willMoveTo date: Date) {
277
- currentDate = date
278
- onDateChanged?(date.timeIntervalSince1970 * 1000)
241
+ // MARK: - Public Methods (for React Native bridge)
242
+ public func setEvents(_ eventDicts: [[String: Any]]) {
243
+ print("🔥 setEvents called with \(eventDicts.count) events (ignored - using hardcoded)")
244
+ // For now, ignore and use hardcoded events
245
+ calendarViewController.reloadData()
279
246
  }
280
247
 
281
- public func dayView(dayView: DayView, didMoveTo date: Date) {
282
- currentDate = date
283
- onDateChanged?(date.timeIntervalSince1970 * 1000)
248
+ public func setDate(_ timestamp: Double) {
249
+ let date = Date(timeIntervalSince1970: timestamp / 1000)
250
+ print("🔥 setDate called with \(date)")
251
+ calendarViewController.move(to: date)
284
252
  }
285
253
 
286
- public func dayView(dayView: DayView, didUpdate event: EventDescriptor) {
287
- // Handle event update if needed
288
- }
289
- }
290
-
291
- // MARK: - Helper Extensions
292
- extension UIColor {
293
- convenience init?(hex: String) {
294
- var hexSanitized = hex.trimmingCharacters(in: .whitespacesAndNewlines)
295
- hexSanitized = hexSanitized.replacingOccurrences(of: "#", with: "")
296
-
297
- var rgb: UInt64 = 0
298
-
299
- guard Scanner(string: hexSanitized).scanHexInt64(&rgb) else { return nil }
300
-
301
- let red = CGFloat((rgb & 0xFF0000) >> 16) / 255.0
302
- let green = CGFloat((rgb & 0x00FF00) >> 8) / 255.0
303
- let blue = CGFloat(rgb & 0x0000FF) / 255.0
304
-
305
- self.init(red: red, green: green, blue: blue, alpha: 1.0)
254
+ public func updateStyle(_ styleDict: [String: Any]) {
255
+ print("🔥 updateStyle called")
256
+ // Apply custom style if needed
306
257
  }
307
- }
308
-
309
- // MARK: - Style Configuration
310
- struct ExpoCalendarStyle {
311
- var backgroundColor: UIColor?
312
- var headerBackgroundColor: UIColor?
313
- var headerTextColor: UIColor?
314
- var weekdayTextColor: UIColor?
315
- var timelineBackgroundColor: UIColor?
316
- var timeTextColor: UIColor?
317
- var eventBackgroundColor: UIColor?
318
- var eventTextColor: UIColor?
319
- var todayBackgroundColor: UIColor?
320
- var todayTextColor: UIColor?
321
- var separatorColor: UIColor?
322
- var hourLineColor: UIColor?
323
- var halfHourLineColor: UIColor?
324
- var quarterHourLineColor: UIColor?
325
- var timelineWidth: CGFloat?
326
- var hourHeight: CGFloat?
327
- var eventMargin: CGFloat?
328
- var eventCornerRadius: CGFloat?
329
258
 
330
- mutating func update(from dict: [String: Any]) {
331
- if let bgColorHex = dict["backgroundColor"] as? String {
332
- backgroundColor = UIColor(hex: bgColorHex)
333
- }
334
-
335
- if let headerBgColorHex = dict["headerBackgroundColor"] as? String {
336
- headerBackgroundColor = UIColor(hex: headerBgColorHex)
337
- }
338
-
339
- if let headerTextColorHex = dict["headerTextColor"] as? String {
340
- headerTextColor = UIColor(hex: headerTextColorHex)
341
- }
342
-
343
- if let weekdayTextColorHex = dict["weekdayTextColor"] as? String {
344
- weekdayTextColor = UIColor(hex: weekdayTextColorHex)
345
- }
346
-
347
- if let timelineBgColorHex = dict["timelineBackgroundColor"] as? String {
348
- timelineBackgroundColor = UIColor(hex: timelineBgColorHex)
349
- }
350
-
351
- if let timeTextColorHex = dict["timeTextColor"] as? String {
352
- timeTextColor = UIColor(hex: timeTextColorHex)
353
- }
354
-
355
- if let eventBgColorHex = dict["eventBackgroundColor"] as? String {
356
- eventBackgroundColor = UIColor(hex: eventBgColorHex)
357
- }
358
-
359
- if let eventTextColorHex = dict["eventTextColor"] as? String {
360
- eventTextColor = UIColor(hex: eventTextColorHex)
361
- }
362
-
363
- if let todayBgColorHex = dict["todayBackgroundColor"] as? String {
364
- todayBackgroundColor = UIColor(hex: todayBgColorHex)
365
- }
366
-
367
- if let todayTextColorHex = dict["todayTextColor"] as? String {
368
- todayTextColor = UIColor(hex: todayTextColorHex)
369
- }
370
-
371
- if let separatorColorHex = dict["separatorColor"] as? String {
372
- separatorColor = UIColor(hex: separatorColorHex)
373
- }
374
-
375
- if let hourLineColorHex = dict["hourLineColor"] as? String {
376
- hourLineColor = UIColor(hex: hourLineColorHex)
377
- }
378
-
379
- if let halfHourLineColorHex = dict["halfHourLineColor"] as? String {
380
- halfHourLineColor = UIColor(hex: halfHourLineColorHex)
381
- }
382
-
383
- if let quarterHourLineColorHex = dict["quarterHourLineColor"] as? String {
384
- quarterHourLineColor = UIColor(hex: quarterHourLineColorHex)
385
- }
386
-
387
- if let width = dict["timelineWidth"] as? NSNumber {
388
- timelineWidth = CGFloat(width.floatValue)
389
- }
390
-
391
- if let height = dict["hourHeight"] as? NSNumber {
392
- hourHeight = CGFloat(height.floatValue)
393
- }
394
-
395
- if let margin = dict["eventMargin"] as? NSNumber {
396
- eventMargin = CGFloat(margin.floatValue)
397
- }
398
-
399
- if let radius = dict["eventCornerRadius"] as? NSNumber {
400
- eventCornerRadius = CGFloat(radius.floatValue)
401
- }
259
+ public func scrollToCurrentTime() {
260
+ print("🔥 scrollToCurrentTime called")
261
+ // Scroll to current time - method name was wrong
262
+ let hour = Calendar.current.component(.hour, from: Date())
263
+ calendarViewController.scrollTo(hour24: Float(hour))
402
264
  }
403
- }
265
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-calendar-kit",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "Expo module wrapping the native Swift CalendarKit library for React Native apps",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",