Skip to content

Commit

Permalink
Simplify if/guard-let syntax for Swift 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtop committed Mar 20, 2023
1 parent 9b6f7e4 commit ef23d0f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Sources/Header/DaySelector/DaySelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public final class DaySelector: UIView {
items.filter{$0.selected == true}.first?.date as Date?
}
set(newDate) {
if let newDate = newDate {
if let newDate {
selectedIndex = calendar.dateComponents([.day], from: startDate, to: newDate).day!
}
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/Timeline/TimelinePagerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr
}

private func updateTimeline(_ timeline: TimelineView) {
guard let dataSource = dataSource else {return}
guard let dataSource else {return}
let date = timeline.date.dateOnly(calendar: calendar)
let events = dataSource.eventsForDate(date)

Expand Down Expand Up @@ -222,7 +222,7 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr
eventView.updateWithDescriptor(event: event)
addSubview(eventView)
// layout algo
if let currentTimeline = currentTimeline {
if let currentTimeline {

for handle in eventView.eventResizeHandles {
let panGestureRecognizer = handle.panGestureRecognizer
Expand Down Expand Up @@ -323,7 +323,7 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr
}

private func accentDateForEditedEventView(eventHeight: Double = 0) {
if let currentTimeline = currentTimeline {
if let currentTimeline {
let timeline = currentTimeline.timeline
let converted = timeline.convert(CGPoint.zero, from: editedEventView)
let date = timeline.yToDate(converted.y + eventHeight)
Expand All @@ -333,14 +333,14 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr
}

private func commitEditing() {
if let currentTimeline = currentTimeline {
if let currentTimeline {
let timeline = currentTimeline.timeline
timeline.accentedDate = nil
setNeedsDisplay()

// TODO: Animate cancellation

if let editedEventView = editedEventView,
if let editedEventView,
let descriptor = editedEventView.descriptor {
update(descriptor: descriptor, with: editedEventView)

Expand Down Expand Up @@ -409,7 +409,7 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr
}

private func update(descriptor: EventDescriptor, with eventView: EventView) {
if let currentTimeline = currentTimeline {
if let currentTimeline {
let timeline = currentTimeline.timeline
let eventFrame = eventView.frame
let converted = convert(eventFrame, to: timeline)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Timeline/TimelineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public final class TimelineView: UIView {
var accentedHour = -1
var accentedMinute = -1

if let accentedDate = accentedDate {
if let accentedDate {
accentedHour = eventEditingSnappingBehavior.accentedHour(for: accentedDate)
accentedMinute = eventEditingSnappingBehavior.accentedMinute(for: accentedDate)
}
Expand Down

0 comments on commit ef23d0f

Please sign in to comment.