expo-calendar-kit 2.1.6 → 2.1.7
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.
- package/ios/ExpoCalendarKitView.swift +190 -330
- package/package.json +1 -1
|
@@ -1,403 +1,263 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
import UIKit
|
|
3
|
-
import EventKit
|
|
4
3
|
import CalendarKit
|
|
4
|
+
import EventKit
|
|
5
5
|
|
|
6
|
-
// MARK: -
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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: - EKWrapper (copied from CalendarApp)
|
|
7
|
+
final class EKWrapper: EventDescriptor {
|
|
8
|
+
public var dateInterval: DateInterval {
|
|
9
|
+
get {
|
|
10
|
+
DateInterval(start: ekEvent.startDate, end: ekEvent.endDate)
|
|
28
11
|
}
|
|
29
12
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
self.color = nil
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public var isAllDay: Bool {
|
|
20
|
+
get {
|
|
21
|
+
ekEvent.isAllDay
|
|
41
22
|
}
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
66
|
-
|
|
32
|
+
|
|
33
|
+
set {
|
|
34
|
+
ekEvent.title = newValue
|
|
67
35
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
91
|
-
private var customCalendarStyle = ExpoCalendarStyle()
|
|
56
|
+
public private(set) var ekEvent: EKEvent
|
|
92
57
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
63
|
+
public func makeEditable() -> Self {
|
|
64
|
+
let cloned = Self(eventKitEvent: ekEvent)
|
|
65
|
+
cloned.editedEvent = self
|
|
66
|
+
return cloned
|
|
104
67
|
}
|
|
105
68
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
69
|
+
public func commitEditing() {
|
|
70
|
+
guard let edited = editedEvent else {return}
|
|
71
|
+
edited.dateInterval = dateInterval
|
|
109
72
|
}
|
|
110
73
|
|
|
111
|
-
private func
|
|
112
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
|
209
|
-
var events = [
|
|
162
|
+
// Create hardcoded events using EKEvent (like CalendarApp)
|
|
163
|
+
var events: [EKWrapper] = []
|
|
210
164
|
|
|
211
165
|
// Event 1: Meeting
|
|
212
|
-
let
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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(EKWrapper(eventKitEvent: meetingEvent))
|
|
220
172
|
|
|
221
173
|
// Event 2: Lunch
|
|
222
|
-
let
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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(EKWrapper(eventKitEvent: lunchEvent))
|
|
230
180
|
|
|
231
181
|
// Event 3: Review
|
|
232
|
-
let
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
events.
|
|
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(EKWrapper(eventKitEvent: reviewEvent))
|
|
188
|
+
|
|
189
|
+
print("🔥 Returning \(events.count) hardcoded events")
|
|
242
190
|
return events
|
|
243
191
|
}
|
|
244
192
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
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
|
-
|
|
261
|
-
|
|
201
|
+
override func dayViewDidSelectEventView(_ eventView: EventView) {
|
|
202
|
+
guard let ckEvent = eventView.descriptor as? EKWrapper 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
|
|
265
|
-
|
|
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
|
|
269
|
-
|
|
219
|
+
required public init?(coder: NSCoder) {
|
|
220
|
+
super.init(coder: coder)
|
|
221
|
+
setupCalendarViewController()
|
|
270
222
|
}
|
|
271
223
|
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
|
282
|
-
|
|
283
|
-
|
|
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
|
|
287
|
-
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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
|
+
calendarViewController.scrollToFirstEvent()
|
|
402
262
|
}
|
|
403
|
-
}
|
|
263
|
+
}
|