コード例 #1
0
        private void OnNavigationBarRightClicked(object sender, EventArgs args)
        {
            var duration = TimeSpan.Zero;

            var entered = durationView.EnteredDuration;

            if (model == null || model.State == TimeEntryState.New)
            {
                duration = new TimeSpan(entered.Hours, entered.Minutes, 0);
            }
            else
            {
                duration = model.GetDuration();
                // Keep the current seconds and milliseconds
                duration = new TimeSpan(0, entered.Hours, entered.Minutes, duration.Seconds, duration.Milliseconds);
            }

            if (model == null)
            {
                var m          = TimeEntryModel.CreateFinished(duration);
                var controller = new EditTimeEntryViewController(m);

                // Replace self with edit controller on the stack
                var vcs = NavigationController.ViewControllers;
                vcs [vcs.Length - 1] = controller;
                NavigationController.SetViewControllers(vcs, true);
            }
            else
            {
                model.SetDuration(duration);
                NavigationController.PopViewControllerAnimated(true);
            }
        }
コード例 #2
0
        private async void OnNavigationBarRightClicked(object sender, EventArgs args)
        {
            if (isSaving)
            {
                return;
            }

            try {
                isSaving = true;
                var duration = TimeSpan.Zero;

                var entered = durationView.EnteredDuration;
                if (model == null || model.State == TimeEntryState.New)
                {
                    duration = new TimeSpan(entered.Hours, entered.Minutes, 0);
                }
                else
                {
                    duration = model.GetDuration();
                    // Keep the current seconds and milliseconds
                    duration = new TimeSpan(0, entered.Hours, entered.Minutes, duration.Seconds, duration.Milliseconds);
                }

                if (model == null)
                {
                    var m = await TimeEntryModel.CreateFinishedAsync(duration);

                    var controller = new EditTimeEntryViewController(m);

                    // Replace self with edit controller on the stack
                    var vcs = NavigationController.ViewControllers;
                    vcs [vcs.Length - 1] = controller;
                    NavigationController.SetViewControllers(vcs, true);

                    // Ping analytics
                    ServiceContainer.Resolve <ITracker>().SendTimerStartEvent(TimerStartSource.AppManual);
                }
                else
                {
                    model.SetDuration(duration);
                    await model.SaveAsync();

                    NavigationController.PopViewController(true);
                }
            } finally {
                isSaving = false;
            }
        }
コード例 #3
0
        private async void OnNavigationBarRightClicked (object sender, EventArgs args)
        {
            if (isSaving) {
                return;
            }

            try {
                isSaving = true;
                var duration = TimeSpan.Zero;

                var entered = durationView.EnteredDuration;
                if (model == null || model.State == TimeEntryState.New) {
                    duration = new TimeSpan (entered.Hours, entered.Minutes, 0);
                } else {
                    duration = model.GetDuration ();
                    // Keep the current seconds and milliseconds
                    duration = new TimeSpan (0, entered.Hours, entered.Minutes, duration.Seconds, duration.Milliseconds);
                }

                if (model == null) {
                    var m = await TimeEntryModel.CreateFinishedAsync (duration);
                    var controller = new EditTimeEntryViewController (m);

                    // Replace self with edit controller on the stack
                    var vcs = NavigationController.ViewControllers;
                    vcs [vcs.Length - 1] = controller;
                    NavigationController.SetViewControllers (vcs, true);

                    // Ping analytics
                    ServiceContainer.Resolve<ITracker>().SendTimerStartEvent (TimerStartSource.AppManual);
                } else {
                    model.SetDuration (duration);
                    await model.SaveAsync ();
                    NavigationController.PopViewController (true);
                }
            } finally {
                isSaving = false;
            }
        }
コード例 #4
0
 public async void ShowNewTimeEntryScreen (TimeEntryModel currentTimeEntry)
 {
     var topVCList = new List<UIViewController> (rootController.ChildViewControllers);
     if (topVCList.Count > 0) {
         // Get current VC's navigation
         var controllers = new List<UIViewController> (topVCList[0].NavigationController.ViewControllers);
         var tags = await ServiceContainer.Resolve<IDataStore> ().GetTimeEntryTags (currentTimeEntry.Data.Id);
         var editController = new EditTimeEntryViewController (currentTimeEntry.Data, tags);
         controllers.Add (editController);
         if (ServiceContainer.Resolve<SettingsStore> ().ChooseProjectForNew) {
             controllers.Add (new ProjectSelectionViewController (currentTimeEntry.Workspace.Id, editController));
         }
         topVCList[0].NavigationController.SetViewControllers (controllers.ToArray (), true);
     }
 }
コード例 #5
0
        private void OnNavigationBarRightClicked (object sender, EventArgs args)
        {
            var duration = TimeSpan.Zero;

            var entered = durationView.EnteredDuration;
            if (model == null || model.State == TimeEntryState.New) {
                duration = new TimeSpan (entered.Hours, entered.Minutes, 0);
            } else {
                duration = model.GetDuration ();
                // Keep the current seconds and milliseconds
                duration = new TimeSpan (0, entered.Hours, entered.Minutes, duration.Seconds, duration.Milliseconds);
            }

            if (model == null) {
                var m = TimeEntryModel.CreateFinished (duration);
                var controller = new EditTimeEntryViewController (m);

                // Replace self with edit controller on the stack
                var vcs = NavigationController.ViewControllers;
                vcs [vcs.Length - 1] = controller;
                NavigationController.SetViewControllers (vcs, true);
            } else {
                model.SetDuration (duration);
                NavigationController.PopViewControllerAnimated (true);
            }
        }