Skip to content

Commit

Permalink
Add createEventAtTouch for TimelineStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
rakuyoMo committed Jun 10, 2024
1 parent 48a1748 commit 5b711ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Sources/KVKCalendar/Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ public struct TimelineStyle {
public var scale: Scale? = Scale(min: 1, max: 6)
public var useDefaultCorderHeader = false
public var eventPreviewSize: CGSize? = CGSize(width: 150, height: 150)

/// Takes effect when `style.event.states` does not contain `.move`. `true`: create a new event at the long press; `false`: create at the start time.
public var createEventAtTouch = false

public var allLeftOffset: CGFloat {
widthTime + offsetTimeX + offsetLineLeft
}
Expand Down Expand Up @@ -889,6 +891,7 @@ extension TimelineStyle: Equatable {
&& compare(\.timeDividerColor)
&& compare(\.timeDividerFont)
&& compare(\.scale)
&& compare(\.createEventAtTouch)
}

}
Expand Down
2 changes: 1 addition & 1 deletion Sources/KVKCalendar/Timeline+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ extension TimelineView {
eventPreviewSize = getEventPreviewSize()
}
var point = gesture.location(in: scrollView)
if !style.event.states.contains(.move) {
if style.timeline.createEventAtTouch && !style.event.states.contains(.move) {
let offset = eventPreviewYOffset - style.timeline.offsetEvent - 6
showChangingMinute(pointY: point.y, offset: offset)
}
Expand Down

0 comments on commit 5b711ec

Please sign in to comment.