From 861003584578a7cf00a49d43bd7515ef7c500612 Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Fri, 7 Jun 2024 10:31:17 +0800 Subject: [PATCH 1/2] Allows hiding the label on the current timeline --- Sources/KVKCalendar/Style.swift | 7 +++++++ Sources/KVKCalendar/TimelineView.swift | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/KVKCalendar/Style.swift b/Sources/KVKCalendar/Style.swift index 1440b7f3..1aedb610 100644 --- a/Sources/KVKCalendar/Style.swift +++ b/Sources/KVKCalendar/Style.swift @@ -168,6 +168,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) @@ -225,6 +226,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 @@ -857,6 +863,7 @@ extension TimelineStyle: Equatable { && compare(\.widthEventViewer) && compare(\.showLineHourMode) && compare(\.scrollLineHourMode) + && compare(\.lineHourStyle) && compare(\.currentLineHourFont) && compare(\.currentLineHourColor) && compare(\.currentLineHourDotSize) diff --git a/Sources/KVKCalendar/TimelineView.swift b/Sources/KVKCalendar/TimelineView.swift index 29585275..247e7829 100644 --- a/Sources/KVKCalendar/TimelineView.swift +++ b/Sources/KVKCalendar/TimelineView.swift @@ -160,7 +160,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) } @@ -188,7 +188,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) } From c6e47cd5bc574a8f4a9f323414813310d9b7bcb5 Mon Sep 17 00:00:00 2001 From: Rakuyo Date: Fri, 7 Jun 2024 11:09:11 +0800 Subject: [PATCH 2/2] Fix the issue that timeLabel is not hidden --- Sources/KVKCalendar/CurrentLineView.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sources/KVKCalendar/CurrentLineView.swift b/Sources/KVKCalendar/CurrentLineView.swift index 963a1a67..4d1f12bb 100644 --- a/Sources/KVKCalendar/CurrentLineView.swift +++ b/Sources/KVKCalendar/CurrentLineView.swift @@ -81,7 +81,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)