Example #1
0
        private void ExecuteGesture(GestureAction action, TaskSubtaskEventArgs e)
        {
            if (e.Task == null || e.Subtask == null)
            {
                return;
            }

            switch (action)
            {
            case GestureAction.Complete:
                VibrateHelper.Short();
                ToggleComplete(e.Task, e.Subtask);
                break;

            case GestureAction.Delete:
                VibrateHelper.Short();
                e.Delete = true;
                Toast.Show(AppResources.ToastSubtaskDeleted, App.IconStyle("Delete"));
                break;

            default:
                break;
            }
        }
Example #2
0
        private void ExecuteGesture(GestureAction action, TaskEventArgs e)
        {
            if (e.Task == null)
            {
                return;
            }
            TaskModel task = e.Task;

            switch (action)
            {
            case GestureAction.Complete:
                VibrateHelper.Short();
                ToggleComplete(task);
                break;

            case GestureAction.Delete:
                VibrateHelper.Short();
                OverlayAction(() =>
                {
                    e.Item.ResetDelete();
                    App.Tasks.Delete(e.Task);
                });
                e.Delete = true;
                Toast.Show(AppResources.ToastTaskDeleted, App.IconStyle("Delete"));
                break;

            case GestureAction.DueToday:
            case GestureAction.DueTomorrow:
                VibrateHelper.Short();
                if (!task.HasRepeats)
                {
                    DateTime?oldDue = task.DueDate;
                    DateTime newDue = (action == GestureAction.DueToday ? DateTimeExtensions.Today : DateTimeExtensions.Tomorrow);
                    newDue = newDue.SetTime(oldDue ?? Settings.Current.DefaultTime);

                    OverlayAction(SetDueDate, task, newDue, action);
                }
                else
                {
                    Toast.Show(AppResources.GestureCantWithRepeats, App.IconStyle("Warning"));
                }
                break;

            case GestureAction.PostponeDay:
            case GestureAction.PostponeWeek:
                VibrateHelper.Short();
                if (!task.HasRepeats)
                {
                    if (task.HasDueDate)
                    {
                        OverlayAction(Postpone, task, task.DueDate.Value.AddDays((action == GestureAction.PostponeDay ? 1 : 7)), action);
                    }
                    else
                    {
                        OverlayAction(Postpone, task, DateTimeExtensions.Today.AddDays((action == GestureAction.PostponeDay ? 1 : 7)).SetTime(Settings.Current.DefaultTime), action);
                    }
                }
                else
                {
                    Toast.Show(AppResources.GestureCantWithRepeats, App.IconStyle("Warning"));
                }
                break;

            case GestureAction.None:
            default:
                break;
            }
        }