コード例 #1
0
        private void ResetConstraints()
        {
            if (trackedConstraints != null)
            {
                View.RemoveConstraints(trackedConstraints);
                trackedConstraints = null;
            }

            var keyboardVisible = keyboardHeight >= 1f;

            trackedConstraints = new FluentLayout[] {
                moodLabel.AtTopOf(View, keyboardVisible ? 20f : 70f),
                moodLabel.AtLeftOf(View, 5f),
                moodLabel.AtRightOf(View, 5f),
                moodLabel.Height().EqualTo(40f),

                neutralMoodButton.Below(moodLabel, 5f),
                neutralMoodButton.WithSameCenterX(View),

                positiveMoodSeparatorView.ToLeftOf(neutralMoodButton, 30f),
                positiveMoodSeparatorView.WithSameCenterY(neutralMoodButton),
                positiveMoodSeparatorView.Height().EqualTo(15f),
                positiveMoodSeparatorView.Width().EqualTo(1f),

                positiveMoodButton.ToLeftOf(positiveMoodSeparatorView, 30f),
                positiveMoodButton.WithSameCenterY(neutralMoodButton),

                negativeMoodSeparatorView.ToRightOf(neutralMoodButton, 30f),
                negativeMoodSeparatorView.WithSameCenterY(neutralMoodButton),
                negativeMoodSeparatorView.Height().EqualTo(15f),
                negativeMoodSeparatorView.Width().EqualTo(1f),

                negativeMoodButton.ToRightOf(negativeMoodSeparatorView, 30f),
                negativeMoodButton.WithSameCenterY(neutralMoodButton),

                messageTopBorderView.Below(neutralMoodButton, 15f),
                messageTopBorderView.AtLeftOf(View),
                messageTopBorderView.AtRightOf(View),
                messageTopBorderView.Height().EqualTo(1f),

                messageTextView.Below(messageTopBorderView),
                messageTextView.AtLeftOf(View),
                messageTextView.AtRightOf(View),

                messageBottomBorderView.Below(messageTextView),
                messageBottomBorderView.AtLeftOf(View),
                messageBottomBorderView.AtRightOf(View),
                messageBottomBorderView.Height().EqualTo(1f),

                sendButton.Below(messageBottomBorderView, 5f),
                sendButton.AtLeftOf(View),
                sendButton.AtRightOf(View),
                sendButton.AtBottomOf(View, (keyboardVisible ? keyboardHeight : 0f) + 5f),
                sendButton.Height().EqualTo(60f),

                null
            }.ToLayoutConstraints();

            View.AddConstraints(trackedConstraints);
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Title = _toDoId == 0 ?
                    NSBundle.MainBundle.GetLocalizedString(ConstantsHelper.NewToDo, ConstantsHelper.NewToDo)
                : NSBundle.MainBundle.GetLocalizedString(ConstantsHelper.EditToDo, ConstantsHelper.EditToDo);

            View.BackgroundColor = UIColor.White;

            var addButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, SaveChanges)
            {
                AccessibilityLabel = ConstantsHelper.ConfirmButtonAccessibilityLabel
            };

            NavigationItem.RightBarButtonItem = addButton;

            _selectedDate = NSDate.Now;

            _dateLabel      = new UILabel();
            _dateLabel.Text = "Date:";
            _dateLabel.Font = UIFont.SystemFontOfSize(16);
            _dateLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            _currentDateField = new UITextField();
            _currentDateField.Layer.BorderColor      = UIColor.LightGray.CGColor;
            _currentDateField.Layer.BorderWidth      = 0.5f;
            _currentDateField.Layer.CornerRadius     = 5f;
            _currentDateField.UserInteractionEnabled = true;
            _currentDateField.TextAlignment          = UITextAlignment.Center;

            var dateFormatter = new NSDateFormatter {
                DateFormat = "dd/MM/yyyy"
            };

            _currentDateField.Text = dateFormatter.StringFor(_selectedDate);
            _currentDateField.Font = UIFont.SystemFontOfSize(16);
            _currentDateField.TranslatesAutoresizingMaskIntoConstraints = false;

            _timeLabel      = new UILabel();
            _timeLabel.Text = "Time:";
            _timeLabel.Font = UIFont.SystemFontOfSize(16);
            _timeLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            var timeFormatter = new NSDateFormatter {
                DateFormat = "HH:mm"
            };

            _currentTimeField = new UITextField();
            _currentTimeField.Layer.BorderColor      = UIColor.LightGray.CGColor;
            _currentTimeField.Layer.BorderWidth      = 0.5f;
            _currentTimeField.Layer.CornerRadius     = 5f;
            _currentTimeField.UserInteractionEnabled = true;
            _currentTimeField.TextAlignment          = UITextAlignment.Center;
            _currentTimeField.Text = timeFormatter.StringFor(_selectedDate);
            _currentTimeField.Font = UIFont.SystemFontOfSize(16);
            _currentTimeField.TranslatesAutoresizingMaskIntoConstraints = false;

            _statusLabel      = new UILabel();
            _statusLabel.Text = "Status:";
            _statusLabel.Font = UIFont.SystemFontOfSize(16);
            _statusLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            _statusField = new UITextField();
            _statusField.Layer.BorderColor      = UIColor.LightGray.CGColor;
            _statusField.Layer.BorderWidth      = 0.5f;
            _statusField.Layer.CornerRadius     = 5f;
            _statusField.UserInteractionEnabled = true;
            _statusField.TextAlignment          = UITextAlignment.Center;
            _statusField.Text = "Active";
            _statusField.TranslatesAutoresizingMaskIntoConstraints = false;

            _descriptionLabel      = new UILabel();
            _descriptionLabel.Text = "Description:";
            _descriptionLabel.Font = UIFont.SystemFontOfSize(16);
            _descriptionLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            _descriptionEditor      = new UITextView();
            _descriptionEditor.Text = "Test to-do";
            _descriptionEditor.Font = UIFont.SystemFontOfSize(16);
            _descriptionEditor.TranslatesAutoresizingMaskIntoConstraints = false;

            _statusGestureRecognizer = new UITapGestureRecognizer(async() => { await ShowStatusPopup(); })
            {
                NumberOfTapsRequired = 1
            };
            _currentDateGestureRecognizer = new UITapGestureRecognizer(async() => { await ShowDatePopup(); })
            {
                NumberOfTapsRequired = 1
            };
            _currentTimeGestureRecognizer = new UITapGestureRecognizer(async() => { await ShowTimePopup(); })
            {
                NumberOfTapsRequired = 1
            };

            View.AddSubviews(_dateLabel,
                             _currentDateField,
                             _timeLabel,
                             _currentTimeField,
                             _statusLabel,
                             _statusField,
                             _descriptionLabel,
                             _descriptionEditor);

            View.AddConstraints(_dateLabel.AtLeftOf(View, 10f),
                                _dateLabel.AtTopOf(View, 80f),
                                _dateLabel.Width().EqualTo(100f),
                                _dateLabel.Height().EqualTo(30f),
                                _currentDateField.WithSameCenterY(_dateLabel),
                                _currentDateField.ToRightOf(_dateLabel),
                                _currentDateField.Width().EqualTo(200f),
                                _currentDateField.Height().EqualTo(30f),
                                _timeLabel.Below(_dateLabel, 10f),
                                _timeLabel.WithSameLeft(_dateLabel),
                                _timeLabel.Width().EqualTo(100f),
                                _timeLabel.Height().EqualTo(30f),
                                _currentTimeField.WithSameCenterY(_timeLabel),
                                _currentTimeField.ToRightOf(_timeLabel),
                                _currentTimeField.Width().EqualTo(200f),
                                _currentTimeField.Height().EqualTo(30f),
                                _statusLabel.Below(_timeLabel, 10f),
                                _statusLabel.WithSameLeft(_timeLabel),
                                _statusLabel.Width().EqualTo(100f),
                                _statusLabel.Height().EqualTo(30f),
                                _statusField.WithSameCenterY(_statusLabel),
                                _statusField.ToRightOf(_statusLabel),
                                _statusField.Width().EqualTo(200f),
                                _statusField.Height().EqualTo(30f),
                                _descriptionLabel.Below(_statusLabel, 10f),
                                _descriptionLabel.WithSameLeft(_statusLabel),
                                _descriptionLabel.Width().EqualTo(100f),
                                _descriptionLabel.Height().EqualTo(30f),
                                _descriptionEditor.Below(_descriptionLabel, 10f),
                                _descriptionEditor.WithSameLeft(_descriptionLabel),
                                _descriptionEditor.Width().EqualTo(View.Bounds.Width - 20f),
                                _descriptionEditor.Height().EqualTo(500f));
        }
コード例 #3
0
        public override void ViewDidLoad()
        {
            var addButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, SaveChanges)
            {
                AccessibilityLabel = ConstantsHelper.ConfirmButtonAccessibilityLabel
            };

            View.BackgroundColor = UIColor.White;
            Title = NSBundle.MainBundle.GetLocalizedString(ConstantsHelper.NewNote, ConstantsHelper.NewNote);
            NavigationItem.RightBarButtonItem = addButton;

            _noteDescriptionHintLabel = new UILabel
            {
                Text          = ConstantsHelper.Note,
                TextAlignment = UITextAlignment.Left,
                TextColor     = UIColor.DarkGray,
                Font          = UIFont.SystemFontOfSize(14),
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            View.AddSubview(_noteDescriptionHintLabel);
            View.AddConstraints(_noteDescriptionHintLabel.AtLeftOf(View, 10f),
                                _noteDescriptionHintLabel.AtTopOf(View, 80f),
                                _noteDescriptionHintLabel.Width().EqualTo(100f),
                                _noteDescriptionHintLabel.Height().EqualTo(20f));

            _noteDescriptionTextView = new UITextView
            {
                Text = ConstantsHelper.NewNote,
                Font = UIFont.SystemFontOfSize(16),
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            View.AddSubview(_noteDescriptionTextView);
            View.AddConstraints(
                _noteDescriptionTextView.WithSameLeft(_noteDescriptionHintLabel),
                _noteDescriptionTextView.Below(_noteDescriptionHintLabel, 10f),
                _noteDescriptionTextView.WithSameWidth(View),
                _noteDescriptionTextView.Height().EqualTo(200));

            ConfigureView();

            _galleryHintLabel = new UILabel
            {
                Text          = ConstantsHelper.Gallery,
                TextAlignment = UITextAlignment.Left,
                TextColor     = UIColor.DarkGray,
                Font          = UIFont.SystemFontOfSize(14),
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            View.AddSubview(_galleryHintLabel);
            View.AddConstraints(_galleryHintLabel.AtLeftOf(View, 10f),
                                _galleryHintLabel.Below(_noteDescriptionTextView, 10f),
                                _galleryHintLabel.Width().EqualTo(100f),
                                _galleryHintLabel.Height().EqualTo(20f));

            var collectionView = new UICollectionView(CGRect.Empty, new GalleryCollectionViewLayout())
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            View.AddSubview(collectionView);

            collectionView.BackgroundColor      = UIColor.White;
            collectionView.AlwaysBounceVertical = true;
            collectionView.Bounces = true;
            collectionView.RegisterClassForCell(typeof(GalleryViewCell), nameof(GalleryViewCell));
            var galleryItems = new List <GalleryItemModel>
            {
                new GalleryItemModel
                {
                    ImagePath =
                        "https://ak5.picdn.net/shutterstock/videos/3775625/thumb/1.jpg?i10c=img.resize(height:160)"
                },
                new GalleryItemModel
                {
                    ImagePath =
                        "https://ak5.picdn.net/shutterstock/videos/3775625/thumb/1.jpg?i10c=img.resize(height:160)"
                },
                new GalleryItemModel
                {
                    ImagePath =
                        "https://ak5.picdn.net/shutterstock/videos/3775625/thumb/1.jpg?i10c=img.resize(height:160)"
                },
                new GalleryItemModel
                {
                    ImagePath =
                        "https://ak5.picdn.net/shutterstock/videos/3775625/thumb/1.jpg?i10c=img.resize(height:160)"
                },
                new GalleryItemModel
                {
                    ImagePath =
                        "https://ak5.picdn.net/shutterstock/videos/3775625/thumb/1.jpg?i10c=img.resize(height:160)"
                },
                new GalleryItemModel
                {
                    ImagePath =
                        "https://ak5.picdn.net/shutterstock/videos/3775625/thumb/1.jpg?i10c=img.resize(height:160)"
                },
                new GalleryItemModel
                {
                    ImagePath =
                        "https://ak5.picdn.net/shutterstock/videos/3775625/thumb/1.jpg?i10c=img.resize(height:160)"
                },
                new GalleryItemModel
                {
                    ImagePath =
                        "https://ak5.picdn.net/shutterstock/videos/3775625/thumb/1.jpg?i10c=img.resize(height:160)"
                },
                new GalleryItemModel
                {
                    ImagePath =
                        "https://ak5.picdn.net/shutterstock/videos/3775625/thumb/1.jpg?i10c=img.resize(height:160)"
                },
                new GalleryItemModel
                {
                    ImagePath =
                        "https://ak5.picdn.net/shutterstock/videos/3775625/thumb/1.jpg?i10c=img.resize(height:160)"
                }
            };

            collectionView.Source   = new GalleryCollectionViewSource(galleryItems, this);
            collectionView.Delegate = new GalleryCollectionViewDelegate(galleryItems, this, new UIEdgeInsets(5, 5, 5, 5));
            collectionView.ReloadData();

            View.AddConstraints(collectionView.Below(_galleryHintLabel, 30f),
                                collectionView.WithSameWidth(View),
                                collectionView.Below(_galleryHintLabel, 5f),
                                collectionView.AtBottomOf(View, 70f));

            var bottomBar = new UIView
            {
                BackgroundColor = UIColor.FromRGB(50, 50, 50),
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            _pickImage = new UIImageView(UIImage.FromBundle(ConstantsHelper.AddIcon))
            {
                ContentMode = UIViewContentMode.Center,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _cameraImage = new UIImageView(UIImage.FromBundle(ConstantsHelper.CameraIcon))
            {
                ContentMode = UIViewContentMode.Center,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _videoImage = new UIImageView(UIImage.FromBundle(ConstantsHelper.VideoIcon))
            {
                ContentMode = UIViewContentMode.Center,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            bottomBar.AddSubviews(_pickImage, _cameraImage, _videoImage);
            bottomBar.AddConstraints(_pickImage.Height().EqualTo(70f),
                                     _pickImage.AtLeftOf(bottomBar),
                                     _pickImage.Width().EqualTo(70f),
                                     _pickImage.WithSameCenterY(bottomBar),
                                     _cameraImage.ToRightOf(_pickImage),
                                     _cameraImage.Height().EqualTo(70f),
                                     _cameraImage.Width().EqualTo(70f),
                                     _cameraImage.WithSameCenterY(bottomBar),
                                     _videoImage.ToRightOf(_cameraImage),
                                     _videoImage.Height().EqualTo(70f),
                                     _videoImage.Width().EqualTo(70f),
                                     _videoImage.WithSameCenterY(bottomBar));

            View.AddSubview(bottomBar);
            View.AddConstraints(bottomBar.WithSameWidth(View),
                                bottomBar.Height().EqualTo(70f),
                                bottomBar.AtBottomOf(View));
        }