Skip to content

Commit

Permalink
Merge pull request #360 from rakuyoMo/feature/current-timeline-withou…
Browse files Browse the repository at this point in the history
…t-time-label
  • Loading branch information
kvyatkovskys authored Jun 7, 2024
2 parents fccf12f + c6e47cd commit 983d4c5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion Sources/KVKCalendar/CurrentLineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ extension CurrentLineView: CalendarSettingProtocol {

timeLabel.textColor = style.timeline.currentLineHourColor
timeLabel.font = style.timeline.currentLineHourFont


switch style.timeline.lineHourStyle {
case .withTime:
timeLabel.isHidden = false
case .onlyLine:
timeLabel.isHidden = true
}

timeLabel.frame = CGRect(x: 0, y: 0,
width: style.timeline.currentLineHourWidth,
height: frame.height)
Expand Down
7 changes: 7 additions & 0 deletions Sources/KVKCalendar/Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public struct TimelineStyle {
public var widthEventViewer: CGFloat? = nil
public var showLineHourMode: CurrentLineHourShowMode = .today
public var scrollLineHourMode: CurrentLineHourScrollMode = .today
public var lineHourStyle: CurrentLineHourStyle = .withTime
public var currentLineHourFont: UIFont = .systemFont(ofSize: 12)
public var currentLineHourColor: UIColor = .red
public var currentLineHourDotSize: CGSize = CGSize(width: 5, height: 5)
Expand Down Expand Up @@ -228,6 +229,11 @@ public struct TimelineStyle {
case vertical, horizontal
}

public enum CurrentLineHourStyle: Equatable {
case withTime
case onlyLine
}

public enum CurrentLineHourShowMode: Equatable {
case always, today, forDate(Date), never

Expand Down Expand Up @@ -862,6 +868,7 @@ extension TimelineStyle: Equatable {
&& compare(\.widthEventViewer)
&& compare(\.showLineHourMode)
&& compare(\.scrollLineHourMode)
&& compare(\.lineHourStyle)
&& compare(\.currentLineHourFont)
&& compare(\.currentLineHourColor)
&& compare(\.currentLineHourDotSize)
Expand Down
4 changes: 2 additions & 2 deletions Sources/KVKCalendar/TimelineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ final class TimelineView: UIView, EventDateProtocol, CalendarTimer {
self.currentLineView.valueHash = nextDate.kvkMinute.hashValue
self.currentLineView.date = nextDate

if self.isDisplayedTimes {
if self.isDisplayedTimes && style.timeline.lineHourStyle == .withTime {
if let timeNext = self.getTimelineLabel(hour: nextDate.kvkHour + 1) {
timeNext.isHidden = self.currentLineView.frame.intersects(timeNext.frame)
}
Expand Down Expand Up @@ -196,7 +196,7 @@ final class TimelineView: UIView, EventDateProtocol, CalendarTimer {
scrollView.addSubview(currentLineView)
movingCurrentLineHour()

if isDisplayedTimes {
if isDisplayedTimes && style.timeline.lineHourStyle == .withTime {
if let timeNext = getTimelineLabel(hour: date.kvkHour + 1) {
timeNext.isHidden = currentLineView.frame.intersects(timeNext.frame)
}
Expand Down

0 comments on commit 983d4c5

Please sign in to comment.