Beispiel #1
0
        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));

            if (previousEndTime != newEndTime)
            {
                selectionFeedback.SelectionChanged();
                previousEndTime = newEndTime;
            }

            if (point.Y > BottomAutoScrollLine && !CollectionView.IsAtBottom())
            {
                StartAutoScrolDown(changeEndTime);
            }
            else if (point.Y < TopAutoScrollLine && calendarItem.Duration > defaultDuration)
            {
                StartAutoScrollUp(changeEndTime);
            }
            else
            {
                StopAutoScroll();
            }
        }
        private void changeEndTime(CGPoint point)
        {
            if (!isActive || itemIndexPath == null)
            {
                return;
            }

            if (Math.Abs(LastPoint.Y - point.Y) < CalendarCollectionViewLayout.HourHeight / 4)
            {
                return;
            }

            if (point.Y < 0 || point.Y >= Layout.ContentViewHeight)
            {
                return;
            }

            LastPoint = point;
            var endTime  = Layout.DateAtPoint(LastPoint).ToLocalTime().RoundUpToClosestQuarter();
            var duration = endTime - calendarItem.StartTime;

            if (duration <= TimeSpan.Zero)
            {
                return;
            }

            calendarItem = calendarItem
                           .WithDuration(duration);

            itemIndexPath = dataSource.UpdateItemView(itemIndexPath, calendarItem.StartTime, calendarItem.Duration);
            selectionFeedback.SelectionChanged();

            if (point.Y > BottomAutoScrollLine && !CollectionView.IsAtBottom())
            {
                StartAutoScrolDown(changeEndTime);
            }
            else if (point.Y < TopAutoScrollLine && calendarItem.Duration > defaultDuration)
            {
                StartAutoScrollUp(changeEndTime);
            }
            else
            {
                StopAutoScroll();
            }
        }