예제 #1
0
        void ReleaseDesignerOutlets()
        {
            if (ClientLabel != null)
            {
                ClientLabel.Dispose();
                ClientLabel = null;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

            if (PrivateProjectLabel != null)
            {
                PrivateProjectLabel.Dispose();
                PrivateProjectLabel = null;
            }
        }
예제 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TitleLabel.Text           = Resources.NewProject;
            NameTextField.Placeholder = Resources.ProjectName;
            ErrorLabel.Text           = Resources.ProjectNameTakenError;
            DoneButton.SetTitle(Resources.Create, UIControlState.Normal);
            ProjectNameUsedErrorTextHeight.Constant = 0;

            // Name
            NameTextField.Rx().Text()
            .Subscribe(ViewModel.Name.Accept)
            .DisposedBy(DisposeBag);

            ViewModel.Name
            .Subscribe(NameTextField.Rx().TextObserver())
            .DisposedBy(DisposeBag);

            // Color
            ColorPickerOpeningView.Rx()
            .BindAction(ViewModel.PickColor)
            .DisposedBy(DisposeBag);

            ViewModel.Color
            .Select(color => color.ToNativeColor())
            .Subscribe(ColorCircleView.Rx().BackgroundColor())
            .DisposedBy(DisposeBag);

            // Error
            ViewModel.Error
            .Subscribe(ErrorLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            ViewModel.Error
            .Select(e => string.IsNullOrEmpty(e) ? new nfloat(0) : errorVisibleHeight)
            .Subscribe(ProjectNameUsedErrorTextHeight.Rx().Constant())
            .DisposedBy(DisposeBag);

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                ViewModel.Error
                .Select(e => string.IsNullOrEmpty(e) ? desiredIpadHeight : errorVisibleHeight + desiredIpadHeight)
                .Select(h => new CGSize(0, h))
                .Subscribe(this.Rx().PreferredContentSize())
                .DisposedBy(DisposeBag);
            }

            // Workspace
            WorkspaceLabel.Rx()
            .BindAction(ViewModel.PickWorkspace)
            .DisposedBy(DisposeBag);

            ViewModel.WorkspaceName
            .Subscribe(WorkspaceLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            // Client
            ClientLabel.Rx()
            .BindAction(ViewModel.PickClient)
            .DisposedBy(DisposeBag);

            var emptyText = Resources.AddClient.PrependWithAddIcon(ClientLabel.Font.CapHeight);

            ViewModel.ClientName
            .Select(attributedClientName)
            .Subscribe(ClientLabel.Rx().AttributedText())
            .DisposedBy(DisposeBag);

            // Is Private
            PrivateProjectSwitchContainer.Rx().Tap()
            .Select(_ => PrivateProjectSwitch.On)
            .Subscribe(ViewModel.IsPrivate.Accept)
            .DisposedBy(DisposeBag);

            ViewModel.IsPrivate
            .Subscribe(PrivateProjectSwitch.Rx().On())
            .DisposedBy(DisposeBag);

            // Save
            DoneButton.Rx()
            .BindAction(ViewModel.Save)
            .DisposedBy(DisposeBag);

            CloseButton.Rx()
            .BindAction(ViewModel.Close)
            .DisposedBy(DisposeBag);

            NSAttributedString attributedClientName(string clientName)
            {
                if (string.IsNullOrEmpty(clientName))
                {
                    return(emptyText);
                }

                return(new NSAttributedString(clientName));
            }
        }