Skip to content

Commit

Permalink
Merge pull request #352 from rakuyoMo/feature/add-event-without-move
Browse files Browse the repository at this point in the history
  • Loading branch information
kvyatkovskys authored Jun 14, 2024
2 parents 983d4c5 + 5b711ec commit 9bbbcb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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
5 changes: 5 additions & 0 deletions Sources/KVKCalendar/Timeline+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,12 @@ extension TimelineView {
eventPreviewSize = getEventPreviewSize()
}
var point = gesture.location(in: scrollView)
if style.timeline.createEventAtTouch && !style.event.states.contains(.move) {
let offset = eventPreviewYOffset - style.timeline.offsetEvent - 6
showChangingMinute(pointY: point.y, offset: offset)
}
point.y = (point.y - eventPreviewYOffset) - style.timeline.offsetEvent - 6

let time = movingMinuteLabel.time
var newEvent = Event(ID: Event.idForNewEvent)
newEvent.title = TextEvent(timeline: style.event.textForNewEvent)
Expand Down

0 comments on commit 9bbbcb7

Please sign in to comment.