-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intergation custom table view to vc #4
Changes from 5 commits
c6442c0
91eca48
f710bbd
1dcac2c
5af918a
4d4c923
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,23 +60,22 @@ public final class TimelineContainer: UIScrollView { | |
} | ||
|
||
public func scroollToCurrentTime(animated: Bool) { | ||
let allDayViewHeight = timeline.allDayViewHeight | ||
let padding = allDayViewHeight + 200 | ||
if let yToScroll = timeline.currentTimeYPosition { | ||
setTimelineOffset(CGPoint(x: contentOffset.x, y: yToScroll - padding), animated: animated) | ||
} | ||
let timeToScroll = Date().timeOnly() - 4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тут еще какие-то магические 4 единицы чего-то отнимаются... |
||
scrollTo(hour24: timeToScroll, animated: animated) | ||
} | ||
|
||
public func scrollTo(hour24: Float, animated: Bool = true) { | ||
let percentToScroll = CGFloat(hour24 / 24) | ||
let yToScroll = contentSize.height * percentToScroll | ||
let padding: CGFloat = 8 | ||
setTimelineOffset(CGPoint(x: contentOffset.x, y: yToScroll - padding), animated: animated) | ||
if let parent = parent?.parent as? CKPageViewController { | ||
parent.commonOffset?.y = yToScroll | ||
} | ||
setTimelineOffset(CGPoint(x: contentOffset.x, y: yToScroll), animated: animated) | ||
} | ||
|
||
private func setTimelineOffset(_ offset: CGPoint, animated: Bool) { | ||
let yToScroll = offset.y | ||
let bottomOfScrollView = contentSize.height - bounds.size.height | ||
let bottomOfScrollView = contentSize.height - bounds.size.height + 30 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Опять магическая цифра) |
||
let newContentY = (yToScroll < bottomOfScrollView) ? yToScroll : bottomOfScrollView | ||
setContentOffset(CGPoint(x: offset.x, y: newContentY), animated: animated) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,8 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr | |
} | ||
|
||
public var autoScrollToFirstEvent = false | ||
|
||
public var minDate: Date? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Добавить бы комментарий с описанием, что это за минимальная дата и для чего она используется |
||
|
||
private var pagingViewController = CKPageViewController(transitionStyle: .scroll, | ||
navigationOrientation: .horizontal, | ||
|
@@ -212,9 +214,11 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr | |
} | ||
} | ||
|
||
public func scrollToCurrentTime(animated: Bool) { | ||
if let controller = currentTimeline { | ||
controller.container.scroollToCurrentTime(animated: animated) | ||
public func scrollToCurrentTimeIfNeeded(needToScroll: Bool, animated: Bool) { | ||
if needToScroll { | ||
if let controller = currentTimeline { | ||
controller.container.scroollToCurrentTime(animated: animated) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -456,6 +460,7 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr | |
|
||
self.pagingViewController.viewControllers?.first?.view.setNeedsLayout() | ||
self.scrollToFirstEventIfNeeded(animated: true) | ||
self.scrollToCurrentTimeIfNeeded(needToScroll: false, animated: true) | ||
self.delegate?.timelinePager(timelinePager: self, didMoveTo: newDate) | ||
} | ||
} | ||
|
@@ -500,6 +505,9 @@ public final class TimelinePagerView: UIView, UIGestureRecognizerDelegate, UIScr | |
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { | ||
guard let containerController = viewController as? TimelineContainerController else { return nil } | ||
let previousDate = calendar.date(byAdding: .day, value: -1, to: containerController.timeline.date)! | ||
if let minDate = minDate { | ||
guard previousDate >= minDate else { return nil } | ||
} | ||
let timelineContainerController = configureTimelineController(date: previousDate) | ||
let offset = containerController.container.contentOffset | ||
timelineContainerController.pendingContentOffset = offset | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
честно сказать, так и не понял, что этот метод возвращает... Float... Time... В каких единицах измерения возвращается timeOnly?