Skip to content

Commit

Permalink
Replace CGFloat with Double
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtop committed Mar 18, 2023
1 parent f342170 commit f290d25
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class CustomCalendarExampleController: DayViewController {

private func generateEventNearDate(_ date: Date) -> EventDescriptor {
let duration = (60...220).randomElement()!
let startDate = Calendar.current.date(byAdding: .minute, value: -Int(CGFloat(duration) / 2), to: date)!
let startDate = Calendar.current.date(byAdding: .minute, value: -Int(Double(duration) / 2), to: date)!
let event = Event()

event.dateInterval = DateInterval(start: startDate, duration: TimeInterval(duration * 60))
Expand Down
8 changes: 4 additions & 4 deletions Sources/CalendarStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public struct TimelineStyle {
public var eventsWillOverlap: Bool = false
public var minimumEventDurationInMinutesWhileEditing: Int = 30
public var splitMinuteInterval: Int = 15
public var verticalDiff: CGFloat = 50
public var verticalInset: CGFloat = 10
public var leadingInset: CGFloat = 53
public var eventGap: CGFloat = 0
public var verticalDiff: Double = 50
public var verticalInset: Double = 10
public var leadingInset: Double = 53
public var eventGap: Double = 0
public init() {}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/DayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class DayView: UIView, TimelinePagerViewDelegate {
timelinePagerView.timelineScrollOffset
}

private static let headerVisibleHeight: CGFloat = 88
public var headerHeight: CGFloat = headerVisibleHeight
private static let headerVisibleHeight: Double = 88
public var headerHeight: Double = headerVisibleHeight

public var autoScrollToFirstEvent: Bool {
get {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Extensions/View+StackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension UIStackView {
convenience init(axis: NSLayoutConstraint.Axis = .vertical,
distribution: UIStackView.Distribution = .fill,
alignment: UIStackView.Alignment = .fill,
spacing: CGFloat = 0,
spacing: Double = 0,
subviews: [UIView] = []) {
self.init(arrangedSubviews: subviews)
self.axis = axis
Expand Down
6 changes: 3 additions & 3 deletions Sources/Header/DayHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public final class DayHeaderView: UIView, DaySelectorDelegate, DayViewStateUpdat

private var currentWeekdayIndex = -1

private var daySymbolsViewHeight: CGFloat = 20
private var pagingScrollViewHeight: CGFloat = 40
private var swipeLabelViewHeight: CGFloat = 20
private var daySymbolsViewHeight: Double = 20
private var pagingScrollViewHeight: Double = 40
private var swipeLabelViewHeight: Double = 20

private let daySymbolsView: DaySymbolsView
private var pagingViewController = UIPageViewController(transitionStyle: .scroll,
Expand Down
4 changes: 2 additions & 2 deletions Sources/Header/DaySelector/DayDateCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public final class DayDateCell: UIView, DaySelectorItemProtocol {
private let dateLabel = DateLabel()
private let dayLabel = UILabel()

private var regularSizeClassFontSize: CGFloat = 16
private var regularSizeClassFontSize: Double = 16

public var date = Date() {
didSet {
Expand Down Expand Up @@ -92,7 +92,7 @@ public final class DayDateCell: UIView, DaySelectorItemProtocol {
super.layoutSubviews()
dayLabel.sizeToFit()
dayLabel.center.y = center.y
let interItemSpacing: CGFloat = selected ? 5 : 3
let interItemSpacing: Double = selected ? 5 : 3
dateLabel.center.y = center.y
dateLabel.frame.origin.x = dayLabel.frame.maxX + interItemSpacing
dateLabel.frame.size = CGSize(width: 30, height: 30)
Expand Down
4 changes: 2 additions & 2 deletions Sources/Header/DaySelector/DaySelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public final class DaySelector: UIView {
override public func layoutSubviews() {
super.layoutSubviews()

let itemCount = CGFloat(items.count)
let itemCount = Double(items.count)
let size = items.first?.intrinsicContentSize ?? .zero

let parentWidth = bounds.size.width
Expand All @@ -132,7 +132,7 @@ public final class DaySelector: UIView {

for (i, item) in items.enumerated() {

var x = minX + (size.width + per) * CGFloat(i)
var x = minX + (size.width + per) * Double(i)

let rightToLeft = UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft
if rightToLeft {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Header/DaySymbolsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ public final class DaySymbolsView: UIView {


override public func layoutSubviews() {
let labelsCount = CGFloat(labels.count)
let labelsCount = Double(labels.count)

var per = bounds.width - bounds.height * labelsCount
per /= labelsCount

let minX = per / 2
for (i, label) in labels.enumerated() {
let frame = CGRect(x: minX + (bounds.height + per) * CGFloat(i), y: 0,
let frame = CGRect(x: minX + (bounds.height + per) * Double(i), y: 0,
width: bounds.height, height: bounds.height)
label.frame = frame
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Header/SwipeLabelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ public final class SwipeLabelView: UIView, DayViewStateUpdating {
}

private func animate(_ direction: AnimationDirection) {
let multiplier: CGFloat = direction == .Forward ? -1 : 1
let shiftRatio: CGFloat = 30/375
let multiplier: Double = direction == .Forward ? -1 : 1
let shiftRatio: Double = 30/375
let screenWidth = bounds.width

secondLabel.alpha = 0
secondLabel.frame = bounds
secondLabel.frame.origin.x -= CGFloat(shiftRatio * screenWidth * 3) * multiplier
secondLabel.frame.origin.x -= Double(shiftRatio * screenWidth * 3) * multiplier

UIView.animate(withDuration: 0.3, animations: {
self.secondLabel.frame = self.bounds
self.firstLabel.frame.origin.x += CGFloat(shiftRatio * screenWidth) * multiplier
self.firstLabel.frame.origin.x += Double(shiftRatio * screenWidth) * multiplier
self.secondLabel.alpha = 1
self.firstLabel.alpha = 0
}, completion: { _ in
Expand Down
2 changes: 1 addition & 1 deletion Sources/Timeline/AllDayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import UIKit
public final class AllDayView: UIView {
private var style = AllDayViewStyle()

private let allDayEventHeight: CGFloat = 24.0
private let allDayEventHeight: Double = 24.0

public var events: [EventDescriptor] = [] {
didSet {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Timeline/CurrentTimeIndicator.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import UIKit

@objc public final class CurrentTimeIndicator: UIView {
private let padding : CGFloat = 3
private let leadingInset: CGFloat = 53
private let padding : Double = 3
private let leadingInset: Double = 53

public var calendar: Calendar = Calendar.autoupdatingCurrent {
didSet {
Expand Down Expand Up @@ -109,7 +109,7 @@ import UIKit
super.layoutSubviews()
line.frame = {

let x: CGFloat
let x: Double
let rightToLeft = UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft
if rightToLeft {
x = 0
Expand All @@ -122,7 +122,7 @@ import UIKit

circle.frame = {

let x: CGFloat
let x: Double
if UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft {
x = bounds.width - leadingInset - 10
} else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Timeline/EventResizeHandleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public final class EventResizeHandleView: UIView {

public override func layoutSubviews() {
super.layoutSubviews()
let radius: CGFloat = 10
let radius: Double = 10
let centerD = (bounds.width - radius) / 2
let origin = CGPoint(x: centerD, y: centerD)
let dotSize = CGSize(width: radius, height: radius)
Expand Down
18 changes: 9 additions & 9 deletions Sources/Timeline/EventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open class EventView: UIView {
public var descriptor: EventDescriptor?
public var color = SystemColors.label

public var contentHeight: CGFloat {
public var contentHeight: Double {
textView.frame.height
}

Expand Down Expand Up @@ -106,8 +106,8 @@ open class EventView: UIView {
context.setLineWidth(3)
context.translateBy(x: 0, y: 0.5)
let leftToRight = UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .leftToRight
let x: CGFloat = leftToRight ? 0 : frame.width - 1 // 1 is the line width
let y: CGFloat = 0
let x: Double = leftToRight ? 0 : frame.width - 1.0 // 1 is the line width
let y: Double = 0
context.beginPath()
context.move(to: CGPoint(x: x, y: y))
context.addLine(to: CGPoint(x: x, y: (bounds).height))
Expand All @@ -134,8 +134,8 @@ open class EventView: UIView {
}
let first = eventResizeHandles.first
let last = eventResizeHandles.last
let radius: CGFloat = 40
let yPad: CGFloat = -radius / 2
let radius: Double = 40
let yPad: Double = -radius / 2
let width = bounds.width
let height = bounds.height
let size = CGSize(width: radius, height: radius)
Expand All @@ -153,10 +153,10 @@ open class EventView: UIView {
private func applySketchShadow(
color: UIColor = .black,
alpha: Float = 0.5,
x: CGFloat = 0,
y: CGFloat = 2,
blur: CGFloat = 4,
spread: CGFloat = 0)
x: Double = 0,
y: Double = 2,
blur: Double = 4,
spread: Double = 0)
{
layer.shadowColor = color.cgColor
layer.shadowOpacity = alpha
Expand Down
8 changes: 4 additions & 4 deletions Sources/Timeline/TimelineContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public final class TimelineContainer: UIScrollView {

//adjust the scroll insets
let allDayViewHeight = timeline.allDayViewHeight
let bottomSafeInset: CGFloat
let bottomSafeInset: Double
if #available(iOS 11.0, *) {
bottomSafeInset = window?.safeAreaInsets.bottom ?? 0
bottomSafeInset = Double(window?.safeAreaInsets.bottom ?? 0.0)
} else {
bottomSafeInset = 0
}
Expand All @@ -44,9 +44,9 @@ public final class TimelineContainer: UIScrollView {
}

public func scrollTo(hour24: Float, animated: Bool = true) {
let percentToScroll = CGFloat(hour24 / 24)
let percentToScroll = Double(hour24 / 24)
let yToScroll = contentSize.height * percentToScroll
let padding: CGFloat = 8
let padding: Double = 8
setTimelineOffset(CGPoint(x: contentOffset.x, y: yToScroll - padding), animated: animated)
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/Timeline/TimelinePagerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr
} else { // Bottom handle
suggestedEventFrame.size.height += diff.y
}
let minimumMinutesEventDurationWhileEditing = CGFloat(style.minimumEventDurationInMinutesWhileEditing)
let minimumMinutesEventDurationWhileEditing = Double(style.minimumEventDurationInMinutesWhileEditing)
let minimumEventHeight = minimumMinutesEventDurationWhileEditing * style.verticalDiff / 60
let suggestedEventHeight = suggestedEventFrame.size.height

Expand All @@ -322,7 +322,7 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr
}
}

private func accentDateForEditedEventView(eventHeight: CGFloat = 0) {
private func accentDateForEditedEventView(eventHeight: Double = 0) {
if let currentTimeline = currentTimeline {
let timeline = currentTimeline.timeline
let converted = timeline.convert(CGPoint.zero, from: editedEventView)
Expand Down Expand Up @@ -401,7 +401,7 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr
}
}

private func yToDate(y: CGFloat, timeline: TimelineView) -> Date {
private func yToDate(y: Double, timeline: TimelineView) -> Date {
let point = CGPoint(x: 0, y: y)
let converted = convert(point, to: timeline).y
let date = timeline.yToDate(converted)
Expand Down
Loading

0 comments on commit f290d25

Please sign in to comment.