Beispiel #1
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (thisTask.ChildTasks == null ||
                !thisTask.ChildTasks.Any())
            {
                FinishButton.SetTitle("Add follow-up tasks by tapping +!", UIControlState.Normal);
            }
            else
            {
                FinishButton.SetTitle("Save and Return", UIControlState.Normal);
                TableView.Source = new CreateViewSource(thisTask.ChildTasks.ToList(), EditTask, null, false);
            }
        }
Beispiel #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            InitKeyboardHandling();
            DismissKeyboardOnBackgroundTap();

            if (thisActivity == null)
            {
                NavigationController.PopViewController(true);
                return;
            }

            if (thisActivity.LearningTasks == null)
            {
                thisActivity.LearningTasks = new List <LearningTask>();
            }

            // check if we're editing an existing task
            if (thisActivity.LearningTasks.ToList().Count > parentTaskIndex)
            {
                if (childTaskIndex != null)
                {
                    var parent = thisActivity.LearningTasks.ToList()[parentTaskIndex];
                    if (parent.ChildTasks != null & parent.ChildTasks.Count() > childTaskIndex)
                    {
                        thisTask     = parent.ChildTasks.ToList()[(int)childTaskIndex];
                        thisTaskType = thisTask.TaskType;
                    }
                }
                else
                {
                    thisTask     = thisActivity.LearningTasks.ToList()[parentTaskIndex];
                    thisTaskType = thisTask.TaskType;
                }

                UIBarButtonItem customButton = new UIBarButtonItem(
                    UIImage.FromFile("ic_delete"),
                    UIBarButtonItemStyle.Plain,
                    (s, e) =>
                {
                    ConfirmDelete();
                }
                    );
                NavigationItem.RightBarButtonItem = customButton;
            }

            if (thisTaskType == null)
            {
                NavigationController.PopViewController(true);
            }

            NavigationItem.Title = thisTaskType.DisplayName;

            ImageService.Instance.LoadUrl(thisTaskType.IconUrl).Into(TaskTypeIcon);

            FinishButton.TouchUpInside += FinishButton_TouchUpInside;

            // style the text view to look like a text field - why the hell are they different?
            TaskDescription.Layer.BorderColor  = UIColor.Gray.ColorWithAlpha(0.5f).CGColor;
            TaskDescription.Layer.BorderWidth  = 2;
            TaskDescription.Layer.CornerRadius = 5;
            TaskDescription.ClipsToBounds      = true;

            if (thisTask != null)
            {
                TaskDescription.Text = thisTask.Description;
                FinishButton.SetTitle("Save Changes", UIControlState.Normal);
            }
            else
            {
                // Add placeholder text
                TaskDescription.Delegate = new TextViewPlaceholderDelegate(TaskDescription, placeholderText);
            }
        }