private void changeStartTime(CGPoint point) { if (!isActive) { return; } if (point.Y < 0 || point.Y >= Layout.ContentViewHeight) { return; } LastPoint = point; var now = timeService.CurrentDateTime; var newStartTime = NewStartTimeWithDynamicDuration(point, allItemsStartAndEndTime); var newDuration = calendarItem.Duration.HasValue ? calendarItem.EndTime(now) - newStartTime : null as TimeSpan?; if (newDuration != null && newDuration <= TimeSpan.Zero || newDuration == null && newStartTime > now) { return; } calendarItem = calendarItem .WithStartTime(newStartTime) .WithDuration(newDuration); dataSource.UpdateItemView(calendarItem.StartTime, calendarItem.Duration(now)); if (previousStartTime != newStartTime) { selectionFeedback.SelectionChanged(); previousStartTime = newStartTime; } if (point.Y < TopAutoScrollLine && !CollectionView.IsAtTop()) { StartAutoScrollUp(changeStartTime); } else if (point.Y > BottomAutoScrollLine && calendarItem.Duration > defaultDuration) { StartAutoScrolDown(changeStartTime); } else { StopAutoScroll(); } }
private void changeOffset(CGPoint point) { if (!isActive) { return; } var currentPointWithOffest = new CGPoint(point.X, point.Y - verticalOffset); var newStartTime = NewStartTimeWithStaticDuration(currentPointWithOffest, allItemsStartAndEndTime, calendarItem.Duration); LastPoint = point; var now = timeService.CurrentDateTime; if (newStartTime + calendarItem.Duration > newStartTime.Date.AddDays(1)) { return; } calendarItem = calendarItem .WithStartTime(newStartTime); dataSource.UpdateItemView(calendarItem.StartTime, calendarItem.Duration(now)); if (previousStartTime != newStartTime) { selectionFeedback.SelectionChanged(); previousStartTime = newStartTime; } var topY = Layout.PointAtDate(calendarItem.StartTime).Y; var bottomY = Layout.PointAtDate(calendarItem.EndTime(now)).Y; if (topY < TopAutoScrollLine && !CollectionView.IsAtTop() && didDragUp) { StartAutoScrollUp(changeOffset); } else if (bottomY > BottomAutoScrollLine && !CollectionView.IsAtBottom() && didDragDown) { StartAutoScrolDown(changeOffset); } else { StopAutoScroll(); } }
private void changeEndTime(CGPoint point) { if (calendarItem.Duration == null || !isActive || itemIndexPath == null) { return; } if (point.Y < 0 || point.Y >= Layout.ContentViewHeight) { return; } LastPoint = point; var now = timeService.CurrentDateTime; var newEndTime = NewEndTimeWithDynamicDuration(point, allItemsStartAndEndTime); var newDuration = newEndTime - calendarItem.StartTime; if (newDuration <= TimeSpan.Zero) { return; } calendarItem = calendarItem .WithDuration(newDuration); itemIndexPath = dataSource.UpdateItemView(itemIndexPath, calendarItem.StartTime, calendarItem.Duration(now)); selectionFeedback.SelectionChanged(); if (point.Y > BottomAutoScrollLine && !CollectionView.IsAtBottom()) { StartAutoScrolDown(changeEndTime); } else if (point.Y < TopAutoScrollLine && calendarItem.Duration > defaultDuration) { StartAutoScrollUp(changeEndTime); } else { StopAutoScroll(); } }