public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            prepareViews();
            prepareSiriButton();
            localizeLabels();

            BillableSwitch.Rx().Changed()
            .Select(_ => BillableSwitch.On)
            .Subscribe(ViewModel.IsBillable.Accept)
            .DisposedBy(DisposeBag);

            TagsTextView.Rx()
            .BindAction(ViewModel.SelectTags)
            .DisposedBy(DisposeBag);

            ViewModel.HasTags
            .Invert()
            .Subscribe(AddTagsView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.HasTags
            .Subscribe(TagsTextView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.TagNames
            .Select(tagsListToAttributedString.Convert)
            .Subscribe(TagsTextView.Rx().AttributedTextObserver())
            .DisposedBy(DisposeBag);

            SelectTagsView.Rx()
            .BindAction(ViewModel.SelectTags)
            .DisposedBy(DisposeBag);

            SelectProjectView.Rx()
            .BindAction(ViewModel.SelectProject)
            .DisposedBy(DisposeBag);

            ViewModel.ProjectClientTask
            .Select(info => projectTaskClientToAttributedString.Convert(
                        info.Project,
                        info.Task,
                        info.Client,
                        new Color(info.ProjectColor).ToNativeColor()))
            .Subscribe(ProjectTaskClientLabel.Rx().AttributedText())
            .DisposedBy(DisposeBag);

            ViewModel.ProjectClientTask
            .Select(info => info.HasProject)
            .Subscribe(ProjectTaskClientLabel.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.ProjectClientTask
            .Select(info => !info.HasProject)
            .Subscribe(AddProjectAndTaskView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsBillable
            .Subscribe(BillableSwitch.Rx().CheckedObserver())
            .DisposedBy(DisposeBag);

            ViewModel.IsBillableAvailable
            .Subscribe(BillableView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.PasteFromClipboard
            .Invert()
            .Subscribe(DescriptionTextView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.PasteFromClipboard
            .Subscribe(DescriptionUsingClipboardWrapperView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.PasteFromClipboard
            .Subscribe(PasteFromClipboardHintView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.PasteFromClipboard
            .Select(enabled => enabled ? pasteFromClipboardButtonImageEnabled : pasteFromClipboardButtonImage)
            .Subscribe(image =>
            {
                PasteFromClipboardButton.SetImage(image, UIControlState.Normal);
            })
            .DisposedBy(DisposeBag);

            ViewModel.PasteFromClipboard
            .Subscribe(enabled =>
            {
                if (enabled)
                {
                    DescriptionTextView.ResignFirstResponder();
                }
                else
                {
                    DescriptionTextView.BecomeFirstResponder();
                }
            })
            .DisposedBy(DisposeBag);

            DescriptionTextView.TextObservable
            .Subscribe(ViewModel.Description.Accept)
            .DisposedBy(DisposeBag);

            PasteFromClipboardButton.Rx()
            .BindAction(ViewModel.SelectClipboard)
            .DisposedBy(DisposeBag);
        }
Пример #2
0
        void ReleaseDesignerOutlets()
        {
            if (AddDescriptionView != null)
            {
                AddDescriptionView.Dispose();
                AddDescriptionView = null;
            }

            if (AddProjectAndTaskView != null)
            {
                AddProjectAndTaskView.Dispose();
                AddProjectAndTaskView = null;
            }

            if (AddTagsView != null)
            {
                AddTagsView.Dispose();
                AddTagsView = null;
            }

            if (BillableSwitch != null)
            {
                BillableSwitch.Dispose();
                BillableSwitch = null;
            }

            if (CloseButton != null)
            {
                CloseButton.Dispose();
                CloseButton = null;
            }

            if (ConfirmButton != null)
            {
                ConfirmButton.Dispose();
                ConfirmButton = null;
            }

            if (DeleteButton != null)
            {
                DeleteButton.Dispose();
                DeleteButton = null;
            }

            if (DescriptionLabel != null)
            {
                DescriptionLabel.Dispose();
                DescriptionLabel = null;
            }

            if (DurationLabel != null)
            {
                DurationLabel.Dispose();
                DurationLabel = null;
            }

            if (ProjectDot != null)
            {
                ProjectDot.Dispose();
                ProjectDot = null;
            }

            if (ProjectLabel != null)
            {
                ProjectLabel.Dispose();
                ProjectLabel = null;
            }

            if (StartDateLabel != null)
            {
                StartDateLabel.Dispose();
                StartDateLabel = null;
            }

            if (StartTimeLabel != null)
            {
                StartTimeLabel.Dispose();
                StartTimeLabel = null;
            }

            if (TaskLabel != null)
            {
                TaskLabel.Dispose();
                TaskLabel = null;
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            projectTaskClientToAttributedString = new ProjectTaskClientToAttributedString(
                ProjectTaskClientLabel.Font.CapHeight,
                Colors.EditTimeEntry.ClientText.ToNativeColor());

            tagsListToAttributedString = new TagsListToAttributedString(TagsTextView);

            localizeLabels();
            prepareViews();
            prepareOnboarding();

            contentSizeChangedDisposable = ScrollViewContent.AddObserver(boundsKey, NSKeyValueObservingOptions.New, onContentSizeChanged);

            DescriptionTextView.Text = ViewModel.Description.Value;

            ViewModel.Preferences
            .Select(preferences => preferences.DurationFormat)
            .Select(format => ViewModel.GroupDuration.ToFormattedString(format))
            .Subscribe(GroupDuration.Rx().Text())
            .DisposedBy(DisposeBag);

            CloseButton.Rx().Tap()
            .Subscribe(ViewModel.CloseWithDefaultResult)
            .DisposedBy(DisposeBag);

            ConfirmButton.Rx()
            .BindAction(ViewModel.Save)
            .DisposedBy(DisposeBag);

            DescriptionTextView.TextObservable
            .Subscribe(ViewModel.Description.Accept)
            .DisposedBy(DisposeBag);

            DescriptionTextView.SizeChangedObservable
            .Subscribe(adjustHeight)
            .DisposedBy(DisposeBag);

            ViewModel.SyncErrorMessage
            .Subscribe(ErrorMessageLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.IsSyncErrorMessageVisible
            .Subscribe(ErrorView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ErrorView.Rx().Tap()
            .Subscribe(ViewModel.DismissSyncErrorMessage.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.ProjectClientTask
            .Select(info => projectTaskClientToAttributedString.Convert(
                        info.Project,
                        info.Task,
                        info.Client,
                        new Color(info.ProjectColor).ToNativeColor()))
            .Subscribe(ProjectTaskClientLabel.Rx().AttributedText())
            .DisposedBy(DisposeBag);

            ViewModel.ProjectClientTask
            .Select(info => info.HasProject)
            .Subscribe(ProjectTaskClientLabel.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.ProjectClientTask
            .Select(info => !info.HasProject)
            .Subscribe(AddProjectAndTaskView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            SelectProject.Rx()
            .BindAction(ViewModel.SelectProject)
            .DisposedBy(DisposeBag);

            TagsTextView.Rx()
            .BindAction(ViewModel.SelectTags)
            .DisposedBy(DisposeBag);

            AddTagsView.Rx()
            .BindAction(ViewModel.SelectTags)
            .DisposedBy(DisposeBag);

            var containsTags = ViewModel.Tags
                               .Select(tags => tags.Any());

            containsTags
            .Invert()
            .Subscribe(AddTagsView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            containsTags
            .Subscribe(TagsTextView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsBillable
            .Subscribe(BillableSwitch.Rx().CheckedObserver())
            .DisposedBy(DisposeBag);

            BillableSwitch.Rx().Changed()
            .Subscribe(ViewModel.ToggleBillable.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.IsBillableAvailable
            .Subscribe(BillableView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsInaccessible
            .Subscribe(adjustUIForInaccessibleTimeEntry)
            .DisposedBy(DisposeBag);

            ViewModel.StartTime
            .WithLatestFrom(ViewModel.Preferences,
                            (startTime, preferences) => DateTimeToFormattedString.Convert(
                                startTime,
                                preferences.TimeOfDayFormat.Format))
            .Subscribe(StartTimeLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.StartTime
            .WithLatestFrom(ViewModel.Preferences,
                            (startTime, preferences) => DateTimeToFormattedString.Convert(
                                startTime,
                                preferences.DateFormat.Short))
            .Subscribe(StartDateLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            StartTimeView.Rx().Tap()
            .SelectValue(EditViewTapSource.StartTime)
            .Subscribe(ViewModel.EditTimes.Inputs)
            .DisposedBy(DisposeBag);

            StartDateView.Rx().Tap()
            .Subscribe(ViewModel.SelectStartDate.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.IsTimeEntryRunning
            .Subscribe(StopButton.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsTimeEntryRunning
            .Select(CommonFunctions.Invert)
            .Subscribe(EndTimeLabel.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.StopTime
            .Where(stopTime => stopTime.HasValue)
            .Select(stopTime => stopTime.Value)
            .WithLatestFrom(ViewModel.Preferences,
                            (stopTime, preferences) => DateTimeToFormattedString.Convert(
                                stopTime,
                                preferences.TimeOfDayFormat.Format))
            .Subscribe(EndTimeLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            EndTimeView.Rx().Tap()
            .SelectLatestFrom(ViewModel.IsTimeEntryRunning)
            .Invert()
            .Where(CommonFunctions.Identity)
            .SelectValue(EditViewTapSource.StopTime)
            .Subscribe(ViewModel.EditTimes.Inputs)
            .DisposedBy(DisposeBag);

            EndTimeView.Rx().Tap()
            .Merge(StopButton.Rx().Tap())
            .SelectLatestFrom(ViewModel.IsTimeEntryRunning)
            .Where(CommonFunctions.Identity)
            .SelectUnit()
            .Subscribe(ViewModel.StopTimeEntry.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.Duration
            .WithLatestFrom(ViewModel.Preferences,
                            (duration, preferences) => duration.ToFormattedString(preferences.DurationFormat))
            .Subscribe(DurationLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            DurationView.Rx().Tap()
            .SelectValue(EditViewTapSource.Duration)
            .Subscribe(ViewModel.EditTimes.Inputs)
            .DisposedBy(DisposeBag);

            DeleteButton.Rx()
            .BindAction(ViewModel.Delete)
            .DisposedBy(DisposeBag);
        }
Пример #4
0
        void ReleaseDesignerOutlets()
        {
            if (AddProjectAndTaskView != null)
            {
                AddProjectAndTaskView.Dispose();
                AddProjectAndTaskView = null;
            }

            if (AddTagsView != null)
            {
                AddTagsView.Dispose();
                AddTagsView = null;
            }

            if (BillableSwitch != null)
            {
                BillableSwitch.Dispose();
                BillableSwitch = null;
            }

            if (BillableView != null)
            {
                BillableView.Dispose();
                BillableView = null;
            }

            if (CategorizeWithProjectsBubbleView != null)
            {
                CategorizeWithProjectsBubbleView.Dispose();
                CategorizeWithProjectsBubbleView = null;
            }

            if (CloseButton != null)
            {
                CloseButton.Dispose();
                CloseButton = null;
            }

            if (ConfirmButton != null)
            {
                ConfirmButton.Dispose();
                ConfirmButton = null;
            }

            if (ConfirmButtonBottomConstraint != null)
            {
                ConfirmButtonBottomConstraint.Dispose();
                ConfirmButtonBottomConstraint = null;
            }

            if (DeleteButton != null)
            {
                DeleteButton.Dispose();
                DeleteButton = null;
            }

            if (DeleteButtonBottomConstraint != null)
            {
                DeleteButtonBottomConstraint.Dispose();
                DeleteButtonBottomConstraint = null;
            }

            if (DescriptionTextView != null)
            {
                DescriptionTextView.Dispose();
                DescriptionTextView = null;
            }

            if (DurationLabel != null)
            {
                DurationLabel.Dispose();
                DurationLabel = null;
            }

            if (DurationView != null)
            {
                DurationView.Dispose();
                DurationView = null;
            }

            if (EndTimeLabel != null)
            {
                EndTimeLabel.Dispose();
                EndTimeLabel = null;
            }

            if (EndTimeView != null)
            {
                EndTimeView.Dispose();
                EndTimeView = null;
            }

            if (ErrorMessageLabel != null)
            {
                ErrorMessageLabel.Dispose();
                ErrorMessageLabel = null;
            }

            if (ErrorView != null)
            {
                ErrorView.Dispose();
                ErrorView = null;
            }

            if (ProjectTaskClientLabel != null)
            {
                ProjectTaskClientLabel.Dispose();
                ProjectTaskClientLabel = null;
            }

            if (RemainingCharacterCount != null)
            {
                RemainingCharacterCount.Dispose();
                RemainingCharacterCount = null;
            }

            if (ScrollView != null)
            {
                ScrollView.Dispose();
                ScrollView = null;
            }

            if (ScrollViewContent != null)
            {
                ScrollViewContent.Dispose();
                ScrollViewContent = null;
            }

            if (StartDateLabel != null)
            {
                StartDateLabel.Dispose();
                StartDateLabel = null;
            }

            if (StartDateView != null)
            {
                StartDateView.Dispose();
                StartDateView = null;
            }

            if (StartTimeLabel != null)
            {
                StartTimeLabel.Dispose();
                StartTimeLabel = null;
            }

            if (StartTimeView != null)
            {
                StartTimeView.Dispose();
                StartTimeView = null;
            }

            if (StopButton != null)
            {
                StopButton.Dispose();
                StopButton = null;
            }

            if (TagsContainerView != null)
            {
                TagsContainerView.Dispose();
                TagsContainerView = null;
            }

            if (TagsSeparator != null)
            {
                TagsSeparator.Dispose();
                TagsSeparator = null;
            }

            if (TagsTextView != null)
            {
                TagsTextView.Dispose();
                TagsTextView = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }

            if (BillableLabel != null)
            {
                BillableLabel.Dispose();
                BillableLabel = null;
            }

            if (StartDateDescriptionLabel != null)
            {
                StartDateDescriptionLabel.Dispose();
                StartDateDescriptionLabel = null;
            }

            if (DurationDescriptionLabel != null)
            {
                DurationDescriptionLabel.Dispose();
                DurationDescriptionLabel = null;
            }

            if (StartDescriptionLabel != null)
            {
                StartDescriptionLabel.Dispose();
                StartDescriptionLabel = null;
            }

            if (EndDescriptionLabel != null)
            {
                EndDescriptionLabel.Dispose();
                EndDescriptionLabel = null;
            }

            if (ErrorMessageTitleLabel != null)
            {
                ErrorMessageTitleLabel.Dispose();
                ErrorMessageTitleLabel = null;
            }

            if (AddProjectTaskLabel != null)
            {
                AddProjectTaskLabel.Dispose();
                AddProjectTaskLabel = null;
            }

            if (CategorizeWithProjectsLabel != null)
            {
                CategorizeWithProjectsLabel.Dispose();
                CategorizeWithProjectsLabel = null;
            }

            if (AddTagsLabel != null)
            {
                AddTagsLabel.Dispose();
                AddTagsLabel = null;
            }
        }
Пример #5
0
        void ReleaseDesignerOutlets()
        {
            if (AddProjectAndTaskView != null)
            {
                AddProjectAndTaskView.Dispose();
                AddProjectAndTaskView = null;
            }

            if (AddProjectTaskLabel != null)
            {
                AddProjectTaskLabel.Dispose();
                AddProjectTaskLabel = null;
            }

            if (AddTagsLabel != null)
            {
                AddTagsLabel.Dispose();
                AddTagsLabel = null;
            }

            if (AddTagsView != null)
            {
                AddTagsView.Dispose();
                AddTagsView = null;
            }

            if (AddToSiriWrapperView != null)
            {
                AddToSiriWrapperView.Dispose();
                AddToSiriWrapperView = null;
            }

            if (BillabelLabel != null)
            {
                BillabelLabel.Dispose();
                BillabelLabel = null;
            }

            if (BillableSwitch != null)
            {
                BillableSwitch.Dispose();
                BillableSwitch = null;
            }

            if (BillableView != null)
            {
                BillableView.Dispose();
                BillableView = null;
            }

            if (DescriptionFromClipboardLabel != null)
            {
                DescriptionFromClipboardLabel.Dispose();
                DescriptionFromClipboardLabel = null;
            }

            if (DescriptionTextView != null)
            {
                DescriptionTextView.Dispose();
                DescriptionTextView = null;
            }

            if (DescriptionUsingClipboardWrapperView != null)
            {
                DescriptionUsingClipboardWrapperView.Dispose();
                DescriptionUsingClipboardWrapperView = null;
            }

            if (DescriptionView != null)
            {
                DescriptionView.Dispose();
                DescriptionView = null;
            }

            if (PasteFromClipboardButton != null)
            {
                PasteFromClipboardButton.Dispose();
                PasteFromClipboardButton = null;
            }

            if (PasteFromClipboardHintLabel != null)
            {
                PasteFromClipboardHintLabel.Dispose();
                PasteFromClipboardHintLabel = null;
            }

            if (PasteFromClipboardHintView != null)
            {
                PasteFromClipboardHintView.Dispose();
                PasteFromClipboardHintView = null;
            }

            if (ProjectTaskClientLabel != null)
            {
                ProjectTaskClientLabel.Dispose();
                ProjectTaskClientLabel = null;
            }

            if (ScrollView != null)
            {
                ScrollView.Dispose();
                ScrollView = null;
            }

            if (ScrollViewContent != null)
            {
                ScrollViewContent.Dispose();
                ScrollViewContent = null;
            }

            if (SelectProjectView != null)
            {
                SelectProjectView.Dispose();
                SelectProjectView = null;
            }

            if (SelectTagsView != null)
            {
                SelectTagsView.Dispose();
                SelectTagsView = null;
            }

            if (TagsTextView != null)
            {
                TagsTextView.Dispose();
                TagsTextView = null;
            }
        }
Пример #6
0
        void ReleaseDesignerOutlets()
        {
            if (AddProjectAndTaskView != null)
            {
                AddProjectAndTaskView.Dispose();
                AddProjectAndTaskView = null;
            }

            if (AddTagsView != null)
            {
                AddTagsView.Dispose();
                AddTagsView = null;
            }

            if (BillableSwitch != null)
            {
                BillableSwitch.Dispose();
                BillableSwitch = null;
            }

            if (BillableView != null)
            {
                BillableView.Dispose();
                BillableView = null;
            }

            if (CloseButton != null)
            {
                CloseButton.Dispose();
                CloseButton = null;
            }

            if (ConfirmButton != null)
            {
                ConfirmButton.Dispose();
                ConfirmButton = null;
            }

            if (ConfirmButtonBottomConstraint != null)
            {
                ConfirmButtonBottomConstraint.Dispose();
                ConfirmButtonBottomConstraint = null;
            }

            if (DeleteButton != null)
            {
                DeleteButton.Dispose();
                DeleteButton = null;
            }

            if (DeleteButtonBottomConstraint != null)
            {
                DeleteButtonBottomConstraint.Dispose();
                DeleteButtonBottomConstraint = null;
            }

            if (DescriptionTextView != null)
            {
                DescriptionTextView.Dispose();
                DescriptionTextView = null;
            }

            if (DurationLabel != null)
            {
                DurationLabel.Dispose();
                DurationLabel = null;
            }

            if (DurationView != null)
            {
                DurationView.Dispose();
                DurationView = null;
            }

            if (ProjectTaskClientLabel != null)
            {
                ProjectTaskClientLabel.Dispose();
                ProjectTaskClientLabel = null;
            }

            if (ScrollView != null)
            {
                ScrollView.Dispose();
                ScrollView = null;
            }

            if (ScrollViewContent != null)
            {
                ScrollViewContent.Dispose();
                ScrollViewContent = null;
            }

            if (ErrorMessageLabel != null)
            {
                ErrorMessageLabel.Dispose();
                ErrorMessageLabel = null;
            }

            if (ErrorView != null)
            {
                ErrorView.Dispose();
                ErrorView = null;
            }

            if (StartDateLabel != null)
            {
                StartDateLabel.Dispose();
                StartDateLabel = null;
            }

            if (StartDateView != null)
            {
                StartDateView.Dispose();
                StartDateView = null;
            }

            if (StartTimeLabel != null)
            {
                StartTimeLabel.Dispose();
                StartTimeLabel = null;
            }

            if (StartTimeView != null)
            {
                StartTimeView.Dispose();
                StartTimeView = null;
            }

            if (EndTimeLabel != null)
            {
                EndTimeLabel.Dispose();
                EndTimeLabel = null;
            }

            if (EndTimeView != null)
            {
                EndTimeView.Dispose();
                EndTimeView = null;
            }

            if (StopButton != null)
            {
                StopButton.Dispose();
                StopButton = null;
            }

            if (TagsTextView != null)
            {
                TagsTextView.Dispose();
                TagsTextView = null;
            }
        }