public static IEnumerable <FluentLayout> FullSizeOf(
            [NotNull] this UIView view,
            [NotNull] UILayoutGuide safeAreaLayoutGuide,
            [NotNull] Margins margins)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }
            if (safeAreaLayoutGuide == null)
            {
                throw new ArgumentNullException(nameof(safeAreaLayoutGuide));
            }
            if (margins == null)
            {
                throw new ArgumentNullException(nameof(margins));
            }

            return(new List <FluentLayout>
            {
                view.Top().NotNull().EqualTo(margins.Top).NotNull().TopOf(safeAreaLayoutGuide).NotNull().WithIdentifier("Top"),
                view.Bottom().NotNull().EqualTo(margins.Bottom).NotNull().BottomOf(safeAreaLayoutGuide).NotNull().WithIdentifier("Bottom"),
                view.Left().NotNull().EqualTo(margins.Left).NotNull().LeftOf(safeAreaLayoutGuide).NotNull().WithIdentifier("Left"),
                view.Right().NotNull().EqualTo(margins.Right).NotNull().RightOf(safeAreaLayoutGuide).NotNull().WithIdentifier("Right")
            });
        }
        public void Initialize(nfloat cellHeight, ActionPlanListModel actionPlan)
        {
            if (!isInitialized)
            {
                iconBackgroundView = new UIView
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    BackgroundColor = Constants.Color.LightGray,
                };

                backgroundCircleSize = cellHeight * (38f / 60f);

                ContentView.TranslatesAutoresizingMaskIntoConstraints         = false;
                ContentView.HeightAnchor.ConstraintEqualTo(cellHeight).Active = true;
                ContentView.WidthAnchor.ConstraintGreaterThanOrEqualTo(backgroundCircleSize + (2 * cellPadding)).Active = true;

                ContentView.AddSubview(iconBackgroundView);
                iconBackgroundView.TopAnchor.ConstraintEqualTo(ContentView.TopAnchor, constant: cellPadding).Active = true;
                iconBackgroundView.CenterXAnchor.ConstraintEqualTo(ContentView.CenterXAnchor).Active = true;
                iconBackgroundView.WidthAnchor.ConstraintEqualTo(backgroundCircleSize).Active        = true;
                iconBackgroundView.HeightAnchor.ConstraintEqualTo(backgroundCircleSize).Active       = true;
                iconBackgroundView.Layer.CornerRadius = backgroundCircleSize / 2;

                iconImageView = new UIImageView {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };

                ContentView.AddSubview(iconImageView);
                iconImageView.CenterXAnchor.ConstraintEqualTo(iconBackgroundView.CenterXAnchor).Active = true;
                iconImageView.CenterYAnchor.ConstraintEqualTo(iconBackgroundView.CenterYAnchor).Active = true;
                iconImageView.WidthAnchor.ConstraintEqualTo(iconBackgroundView.WidthAnchor, multiplier: iconSizeFactor).Active   = true;
                iconImageView.HeightAnchor.ConstraintEqualTo(iconBackgroundView.HeightAnchor, multiplier: iconSizeFactor).Active = true;

                titleLabel = new UILabel
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font          = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Ten),
                    TextColor     = Constants.Color.MidGray,
                    TextAlignment = UITextAlignment.Center,
                };

                var titleLayoutGuide = new UILayoutGuide();
                ContentView.AddLayoutGuide(titleLayoutGuide);
                titleLayoutGuide.TopAnchor.ConstraintEqualTo(iconBackgroundView.BottomAnchor).Active = true;
                titleLayoutGuide.BottomAnchor.ConstraintEqualTo(ContentView.BottomAnchor).Active     = true;

                ContentView.AddSubview(titleLabel);
                titleLabel.LeftAnchor.ConstraintEqualTo(ContentView.LeftAnchor, constant: cellPadding).Active    = true;
                titleLabel.RightAnchor.ConstraintEqualTo(ContentView.RightAnchor, constant: -cellPadding).Active = true;
                titleLabel.CenterYAnchor.ConstraintEqualTo(titleLayoutGuide.CenterYAnchor).Active = true;

                isInitialized = true;
            }

            selectionColor      = Constants.Color.MapFromActionPlanColor(actionPlan.Color);
            iconImage           = Constants.Assets.MapFromActionPlanIcon(actionPlan.Icon, true);
            selectedIconImage   = Constants.Assets.MapFromActionPlanIcon(actionPlan.Icon);
            titleLabel.Text     = actionPlan.Name;
            iconImageView.Image = iconImage;
        }
Exemple #3
0
        NSLayoutConstraint GuideHeightToPlanet(UILayoutGuide layoutGuide, UIView planet, string identifier)
        {
            NSLayoutConstraint guideHeightToPlanet = layoutGuide.HeightAnchor.ConstraintEqualToAnchor(planet.HeightAnchor);

            guideHeightToPlanet.SetIdentifier(identifier);
            return(guideHeightToPlanet);
        }
Exemple #4
0
        UILayoutGuide NewLayoutGuide(string identifierName)
        {
            var newGuide = new UILayoutGuide {
                Identifier = identifierName
            };

            View.AddLayoutGuide(newGuide);
            return(newGuide);
        }
Exemple #5
0
        public void Initialize(string name, UIImage profileImage = null, float fontSize = 12, string initials = null)
        {
            if (!isInitialized)
            {
                var labelContainerView = new UIView {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                ContentView.AddSubview(labelContainerView);

                labelContainerView.BottomAnchor.ConstraintEqualTo(ContentView.BottomAnchor).Active = true;
                labelContainerView.LeftAnchor.ConstraintEqualTo(ContentView.LeftAnchor, Constants.MenuRightMargin).Active = true;
                labelContainerView.RightAnchor.ConstraintEqualTo(ContentView.RightAnchor).Active   = true;
                labelContainerView.HeightAnchor.ConstraintEqualTo(Constants.MenuCellHeight).Active = true;

                titleLabel = new UILabel
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    TextColor     = Constants.Color.Black,
                    Font          = Constants.Fonts.RubikOfSize(fontSize),
                    TextAlignment = UITextAlignment.Center,
                };

                labelContainerView.AddSubview(titleLabel);

                titleLabel.LeftAnchor.ConstraintEqualTo(labelContainerView.LeftAnchor).Active       = true;
                titleLabel.RightAnchor.ConstraintEqualTo(ContentView.RightAnchor).Active            = true;
                titleLabel.CenterYAnchor.ConstraintEqualTo(labelContainerView.CenterYAnchor).Active = true;

                var avatarLayoutGuide = new UILayoutGuide();

                ContentView.AddLayoutGuide(avatarLayoutGuide);

                avatarLayoutGuide.LeftAnchor.ConstraintEqualTo(ContentView.LeftAnchor, Constants.MenuRightMargin).Active = true;
                avatarLayoutGuide.RightAnchor.ConstraintEqualTo(ContentView.RightAnchor).Active = true;

                avatarView = new CircleAvatarView
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    BackgroundColor = Constants.Color.MidGray,
                };

                avatarView.Layer.CornerRadius = avatarHeight / 2;

                ContentView.AddSubview(avatarView);

                avatarView.BottomAnchor.ConstraintEqualTo(labelContainerView.TopAnchor).Active = true;
                avatarView.HeightAnchor.ConstraintEqualTo(avatarHeight).Active = true;
                avatarView.WidthAnchor.ConstraintEqualTo(avatarHeight).Active  = true;
                avatarView.CenterXAnchor.ConstraintEqualTo(avatarLayoutGuide.CenterXAnchor).Active = true;

                isInitialized = true;
            }

            titleLabel.Text     = name;
            avatarView.Image    = profileImage;
            avatarView.Initials = initials;
        }
        public static IEnumerable <FluentLayout> FullSizeOf(
            [NotNull] this UIView view,
            [NotNull] UILayoutGuide safeAreaLayoutGuide,
            [CanBeNull] nfloat?margin = null)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }
            if (safeAreaLayoutGuide == null)
            {
                throw new ArgumentNullException(nameof(safeAreaLayoutGuide));
            }

            return(FullSizeOf(view, safeAreaLayoutGuide, new Margins((float)margin.GetValueOrDefault(DefaultMargin))));
        }
Exemple #7
0
        public static UILayoutGuide GetCompatibleLayoutGuide(this UIViewController self)
        {
#pragma warning disable XI0002 // Notifies you from using newer Apple APIs when targeting an older OS version
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                return(self.View.SafeAreaLayoutGuide);
            }
#pragma warning restore XI0002 // Notifies you from using newer Apple APIs when targeting an older OS version

            var guide = new UILayoutGuide();

#pragma warning disable XI0003 // Notifies you when using a deprecated, obsolete or unavailable Apple API
            guide.LeadingAnchor.ConstraintEqualTo(self.View.LeadingAnchor).Active              = true;
            guide.TrailingAnchor.ConstraintEqualTo(self.View.TrailingAnchor).Active            = true;
            guide.TopAnchor.ConstraintEqualTo(self.TopLayoutGuide.GetBottomAnchor()).Active    = true;
            guide.BottomAnchor.ConstraintEqualTo(self.BottomLayoutGuide.GetTopAnchor()).Active = true;
#pragma warning restore XI0003 // Notifies you when using a deprecated, obsolete or unavailable Apple API

            return(guide);
        }
Exemple #8
0
        void CreateRegularConstraints()
        {
            if (regularConstraints?.Length > 0 && sharedConstraints?.Count > 0)
            {
                return;
            }

            UILayoutGuide leadingMercuryGuide = NewLayoutGuide("leadingMercuryGuide");
            UILayoutGuide leadingVenusGuide   = NewLayoutGuide("leadingVenusGuide");
            UILayoutGuide leadingEarthGuide   = NewLayoutGuide("leadingEarthGuide");
            UILayoutGuide leadingMarsGuide    = NewLayoutGuide("leadingMarsGuide");
            UILayoutGuide leadingJupiterGuide = NewLayoutGuide("leadingJupiterGuide");
            UILayoutGuide leadingSaturnGuide  = NewLayoutGuide("leadingSaturnGuide");
            UILayoutGuide leadingUranusGuide  = NewLayoutGuide("leadingUranusGuide");
            UILayoutGuide leadingNeptuneGuide = NewLayoutGuide("leadingNeptuneGuide");

            UILayoutGuide trailingMercuryGuide = NewLayoutGuide("trailingMercuryGuide");
            UILayoutGuide trailingVenusGuide   = NewLayoutGuide("trailingVenusGuide");
            UILayoutGuide trailingEarthGuide   = NewLayoutGuide("trailingEarthGuide");
            UILayoutGuide trailingMarsGuide    = NewLayoutGuide("trailingMarsGuide");
            UILayoutGuide trailingJupiterGuide = NewLayoutGuide("trailingJupiterGuide");
            UILayoutGuide trailingSaturnGuide  = NewLayoutGuide("trailingSaturnGuide");
            UILayoutGuide trailingUranusGuide  = NewLayoutGuide("trailingUranusGuide");
            UILayoutGuide trailingNeptuneGuide = NewLayoutGuide("trailingNeptuneGuide");

            IUILayoutSupport topLayoutGuide = TopLayoutGuide;

            var planetsAndGuides = NSDictionary.FromObjectsAndKeys(new object[] {
                mercury, venus, earth, mars, jupiter, saturn, uranus, neptune,
                leadingMercuryGuide, leadingVenusGuide, leadingEarthGuide, leadingMarsGuide,
                leadingJupiterGuide, leadingSaturnGuide, leadingUranusGuide, leadingNeptuneGuide,
                trailingMercuryGuide, trailingVenusGuide, trailingEarthGuide, trailingMarsGuide,
                trailingJupiterGuide, trailingSaturnGuide, trailingUranusGuide, trailingNeptuneGuide, topLayoutGuide
            }, new object[] {
                "mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune",
                "leadingMercuryGuide", "leadingVenusGuide", "leadingEarthGuide", "leadingMarsGuide",
                "leadingJupiterGuide", "leadingSaturnGuide", "leadingUranusGuide", "leadingNeptuneGuide",
                "trailingMercuryGuide", "trailingVenusGuide", "trailingEarthGuide", "trailingMarsGuide",
                "trailingJupiterGuide", "trailingSaturnGuide", "trailingUranusGuide", "trailingNeptuneGuide", "topLayoutGuide"
            });

            var topToBottom = NSLayoutConstraint.FromVisualFormat("V:|[topLayoutGuide]-[leadingMercuryGuide]-" +
                                                                  "[leadingVenusGuide]-[leadingEarthGuide]-[leadingMarsGuide]-" +
                                                                  "[leadingJupiterGuide][leadingSaturnGuide][leadingUranusGuide]-" +
                                                                  "[leadingNeptuneGuide]-20-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, planetsAndGuides);

            sharedConstraints = new List <NSLayoutConstraint> (topToBottom);
            SetLayoutIdentifierForArray((NSString)"topToBottom", NSArray.FromObjects(topToBottom));

            NewHorizontalArray("|[leadingMercuryGuide][mercury][trailingMercuryGuide]|", "hMercury", planetsAndGuides);
            NewHorizontalArray("|[leadingVenusGuide][venus][trailingVenusGuide]|", "hVenus", planetsAndGuides);
            NewHorizontalArray("|[leadingEarthGuide][earth][trailingEarthGuide]|", "hEarth", planetsAndGuides);
            NewHorizontalArray("|[leadingMarsGuide][mars][trailingMarsGuide]|", "hMars", planetsAndGuides);
            NewHorizontalArray("|[leadingJupiterGuide][jupiter][trailingJupiterGuide]|", "hJupiter", planetsAndGuides);
            NewHorizontalArray("|[leadingSaturnGuide][saturn][trailingSaturnGuide]|", "hSaturn", planetsAndGuides);
            NewHorizontalArray("|[leadingUranusGuide][uranus][trailingUranusGuide]|", "hUranus", planetsAndGuides);
            NewHorizontalArray("|[leadingNeptuneGuide][neptune][trailingNeptuneGuide]|", "hNeptune", planetsAndGuides);

            sharedConstraints.Add(GuideHeightToPlanet(leadingMercuryGuide, mercury, "guideHeightToMercury"));
            sharedConstraints.Add(GuideHeightToPlanet(leadingVenusGuide, venus, "guideHeightToVenus"));
            sharedConstraints.Add(GuideHeightToPlanet(leadingEarthGuide, earth, "guideHeightToEarth"));
            sharedConstraints.Add(GuideHeightToPlanet(leadingMarsGuide, mars, "guideHeightToMars"));
            sharedConstraints.Add(GuideHeightToPlanet(leadingJupiterGuide, jupiter, "guideHeightToJupiter"));
            sharedConstraints.Add(GuideHeightToPlanet(leadingSaturnGuide, saturn, "guideHeightToSaturn"));
            sharedConstraints.Add(GuideHeightToPlanet(leadingUranusGuide, uranus, "guideHeightToUranus"));
            sharedConstraints.Add(GuideHeightToPlanet(leadingNeptuneGuide, neptune, "guideHeightToNeptune"));

            mercuryLeadingToTrailing = leadingMercuryGuide.WidthAnchor.ConstraintEqualToAnchor(trailingMercuryGuide.WidthAnchor, .02f);
            venusLeadingToTrailing   = leadingVenusGuide.WidthAnchor.ConstraintEqualToAnchor(trailingVenusGuide.WidthAnchor, .03f);
            earthLeadingToTrailing   = leadingEarthGuide.WidthAnchor.ConstraintEqualToAnchor(trailingEarthGuide.WidthAnchor, .06f);
            marsLeadingToTrailing    = leadingMarsGuide.WidthAnchor.ConstraintEqualToAnchor(trailingMarsGuide.WidthAnchor, .1f);
            jupiterLeadingToTrailing = leadingJupiterGuide.WidthAnchor.ConstraintEqualToAnchor(trailingJupiterGuide.WidthAnchor, .2f);
            saturnLeadingToTrailing  = leadingSaturnGuide.WidthAnchor.ConstraintEqualToAnchor(trailingSaturnGuide.WidthAnchor, 1f);
            uranusLeadingToTrailing  = leadingUranusGuide.WidthAnchor.ConstraintEqualToAnchor(trailingUranusGuide.WidthAnchor, 2.7f);
            neptuneLeadingToTrailing = leadingNeptuneGuide.WidthAnchor.ConstraintEqualToAnchor(trailingNeptuneGuide.WidthAnchor, 10f);

            mercuryLeadingToTrailing.SetIdentifier("leadingTrailingAnchorMercury");
            venusLeadingToTrailing.SetIdentifier("leadingTrailingAnchorVenus");
            earthLeadingToTrailing.SetIdentifier("leadingTrailingAnchorEarth");
            marsLeadingToTrailing.SetIdentifier("leadingTrailingAnchorMars");
            jupiterLeadingToTrailing.SetIdentifier("leadingTrailingAnchorJupiter");
            saturnLeadingToTrailing.SetIdentifier("leadingTrailingAnchorSaturn");
            uranusLeadingToTrailing.SetIdentifier("leadingTrailingAnchorUranus");
            neptuneLeadingToTrailing.SetIdentifier("leadingTrailingAnchorNeptune");

            regularConstraints = new [] {
                mercuryLeadingToTrailing, venusLeadingToTrailing, earthLeadingToTrailing, marsLeadingToTrailing,
                saturnLeadingToTrailing, jupiterLeadingToTrailing, uranusLeadingToTrailing, neptuneLeadingToTrailing
            };
        }
        public void Initialize(ChatMessage message, string initials = null)
        {
            if (!isInitialized)
            {
                isInitialized = true;

                ContentView.TranslatesAutoresizingMaskIntoConstraints = false;
                ContentView.WidthAnchor.ConstraintEqualTo(UIScreen.MainScreen.Bounds.Width).Active = true;
                ContentView.HeightAnchor.ConstraintGreaterThanOrEqualTo(speakerCircleSize + (2 * padding)).Active = true;

                speakerAvatarView = new CircleAvatarView {
                    TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = Constants.Color.LightGray
                };
                ContentView.AddSubview(speakerAvatarView);
                speakerAvatarView.WidthAnchor.ConstraintEqualTo(speakerCircleSize).Active  = true;
                speakerAvatarView.HeightAnchor.ConstraintEqualTo(speakerCircleSize).Active = true;
                speakerAvatarView.TopAnchor.ConstraintEqualTo(ContentView.TopAnchor, constant: padding).Active = true;

                circleImageViewRightAnchorOutgoingConstraint = speakerAvatarView.RightAnchor.ConstraintEqualTo(ContentView.RightAnchor, constant: -padding);
                circleImageViewLeftAnchorIncomingConstraint  = speakerAvatarView.LeftAnchor.ConstraintEqualTo(ContentView.LeftAnchor, constant: padding);

                var messageLayoutGuide = new UILayoutGuide();
                ContentView.AddLayoutGuide(messageLayoutGuide);
                messageLayoutGuideRightAnchorOutgoingConstraint = messageLayoutGuide.RightAnchor.ConstraintEqualTo(speakerAvatarView.LeftAnchor, constant: -padding);
                messageLayoutGuideLeftAnchorIncomingConstraint  = messageLayoutGuide.LeftAnchor.ConstraintEqualTo(speakerAvatarView.RightAnchor, constant: padding);
                messageLayoutGuideLeftAnchorOutgoingConstraint  = messageLayoutGuide.LeftAnchor.ConstraintEqualTo(ContentView.LeftAnchor, constant: padding);
                messageLayoutGuideRightAnchorIncomingConstraint = messageLayoutGuide.RightAnchor.ConstraintEqualTo(ContentView.RightAnchor, constant: -padding);

                messageLabel = new UILabel
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Lines         = 0,
                    LineBreakMode = UILineBreakMode.WordWrap,
                    Font          = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Twelve),
                };

                ContentView.AddSubview(messageLabel);

                topView = new UIView {
                    TranslatesAutoresizingMaskIntoConstraints = false, ClipsToBounds = true
                };
                ContentView.AddSubview(topView);
                topView.TopAnchor.ConstraintEqualTo(speakerAvatarView.TopAnchor, constant: padding).Active = true;
                topView.LeftAnchor.ConstraintEqualTo(messageLabel.LeftAnchor).Active = true;
                topViewRightAnchorConstraint   = topView.RightAnchor.ConstraintEqualTo(messageLabel.RightAnchor);
                topViewHeightConstraint        = topView.HeightAnchor.ConstraintEqualTo(0);
                topViewHeightConstraint.Active = true;

                bottomView = new UIView {
                    TranslatesAutoresizingMaskIntoConstraints = false, ClipsToBounds = true
                };
                ContentView.AddSubview(bottomView);
                bottomViewTopAnchorConstraint        = bottomView.TopAnchor.ConstraintEqualTo(messageLabel.BottomAnchor);
                bottomViewTopAnchorConstraint.Active = true;
                bottomView.LeftAnchor.ConstraintEqualTo(messageLabel.LeftAnchor).Active = true;
                bottomViewRightAnchorConstraint = bottomView.RightAnchor.ConstraintEqualTo(messageLabel.RightAnchor);
                bottomView.BottomAnchor.ConstraintEqualTo(ContentView.BottomAnchor, constant: -padding).Active = true;
                bottomViewHeightConstraint        = bottomView.HeightAnchor.ConstraintEqualTo(0);
                bottomViewHeightConstraint.Active = true;

                var locationSentImageView = new UIImageView
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Image = Constants.Assets.LocationSent,
                };
                bottomView.AddSubview(locationSentImageView);
                locationSentImageView.LeftAnchor.ConstraintEqualTo(bottomView.LeftAnchor).Active       = true;
                locationSentImageView.CenterYAnchor.ConstraintEqualTo(bottomView.CenterYAnchor).Active = true;

                var locationSentLabel = new UILabel
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font      = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Ten),
                    TextColor = Constants.Color.MidGray,
                    Text      = "Location sent",
                };
                bottomView.AddSubview(locationSentLabel);
                locationSentLabel.LeftAnchor.ConstraintEqualTo(locationSentImageView.RightAnchor, constant: padding / 2).Active = true;
                locationSentLabel.CenterYAnchor.ConstraintEqualTo(bottomView.CenterYAnchor).Active       = true;
                locationSentLabel.RightAnchor.ConstraintLessThanOrEqualTo(bottomView.RightAnchor).Active = true;

                messageLabelTopAnchorConstraint           = messageLabel.TopAnchor.ConstraintEqualTo(topView.BottomAnchor);
                messageLabelTopAnchorConstraint.Active    = true;
                messageLabelRightAnchorOutgoingConstraint = messageLabel.RightAnchor.ConstraintEqualTo(messageLayoutGuide.RightAnchor, constant: -padding);
                messageLabelLeftAnchorIncomingConstraint  = messageLabel.LeftAnchor.ConstraintEqualTo(messageLayoutGuide.LeftAnchor, constant: padding);
                messageLabel.WidthAnchor.ConstraintLessThanOrEqualTo(messageLayoutGuide.WidthAnchor, multiplier: 0.75f, constant: -(padding * 2)).Active = true;

                messageBackgroundView = new UIView {
                    TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = Constants.Color.LightGray
                };
                ContentView.InsertSubviewBelow(messageBackgroundView, messageLabel);
                messageBackgroundView.TopAnchor.ConstraintEqualTo(topView.TopAnchor, constant: -padding).Active         = true;
                messageBackgroundView.LeftAnchor.ConstraintEqualTo(messageLabel.LeftAnchor, constant: -padding).Active  = true;
                messageBackgroundView.RightAnchor.ConstraintEqualTo(messageLabel.RightAnchor, constant: padding).Active = true;
                messageBackgroundView.BottomAnchor.ConstraintEqualTo(bottomView.BottomAnchor, constant: padding).Active = true;
                messageBackgroundView.Layer.CornerRadius = 4;

                leftTriangleView = new TriangleChatView
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    BackgroundColor = Constants.Color.LightGray,
                    Mirrored        = true,
                };

                ContentView.InsertSubviewBelow(leftTriangleView, messageBackgroundView);
                leftTriangleView.RightAnchor.ConstraintEqualTo(messageBackgroundView.LeftAnchor, constant: 3).Active = true;
                leftTriangleView.TopAnchor.ConstraintEqualTo(speakerAvatarView.BottomAnchor, constant: -10).Active   = true;
                leftTriangleView.WidthAnchor.ConstraintEqualTo(8).Active   = true;
                leftTriangleView.HeightAnchor.ConstraintEqualTo(14).Active = true;
                leftTriangleView.Transform = CGAffineTransform.Rotate(leftTriangleView.Transform, -(nfloat)Math.PI * 0.08f);

                rightTriangleView = new TriangleChatView
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    BackgroundColor = Constants.Color.LightGray,
                };

                ContentView.InsertSubviewBelow(rightTriangleView, messageBackgroundView);
                rightTriangleView.LeftAnchor.ConstraintEqualTo(messageBackgroundView.RightAnchor, constant: -3).Active = true;
                rightTriangleView.TopAnchor.ConstraintEqualTo(speakerAvatarView.BottomAnchor, constant: -10).Active    = true;
                rightTriangleView.WidthAnchor.ConstraintEqualTo(8).Active   = true;
                rightTriangleView.HeightAnchor.ConstraintEqualTo(14).Active = true;
                rightTriangleView.Transform = CGAffineTransform.Rotate(rightTriangleView.Transform, (nfloat)Math.PI * 0.08f);

                outgoingMessageConstraints = new NSLayoutConstraint[]
                {
                    circleImageViewRightAnchorOutgoingConstraint,
                    messageLayoutGuideLeftAnchorOutgoingConstraint,
                    messageLayoutGuideRightAnchorOutgoingConstraint,
                    messageLabelRightAnchorOutgoingConstraint,
                };

                incomingMessageConstraints = new NSLayoutConstraint[]
                {
                    circleImageViewLeftAnchorIncomingConstraint,
                    messageLayoutGuideLeftAnchorIncomingConstraint,
                    messageLayoutGuideRightAnchorIncomingConstraint,
                    messageLabelLeftAnchorIncomingConstraint,
                };
            }

            var isOutgoing            = message.UserModel.Role == ChatUserRole.Consumer;
            var isNewActopmPlanPrompt = message.IsNewActionPlan && message.ActionPlan != null;
            var topViewHeight         = smallerCircleSize;
            var bottomViewheight      = 13;

            foreach (var c in outgoingMessageConstraints)
            {
                c.Active = isOutgoing;
            }
            foreach (var c in incomingMessageConstraints)
            {
                c.Active = !isOutgoing;
            }

            messageLabel.Text          = message.Text;
            speakerAvatarView.Initials = isOutgoing ? initials : string.Empty;

            topViewHeightConstraint.Constant    = isNewActopmPlanPrompt ? topViewHeight : 0;
            bottomViewHeightConstraint.Constant = isNewActopmPlanPrompt ? bottomViewheight : 0;

            bottomViewTopAnchorConstraint.Constant   = isNewActopmPlanPrompt ? padding : 0;
            messageLabelTopAnchorConstraint.Constant = isNewActopmPlanPrompt ? padding : 0;

            bottomViewRightAnchorConstraint.Active = isNewActopmPlanPrompt;
            topViewRightAnchorConstraint.Active    = isNewActopmPlanPrompt;

            leftTriangleView.Hidden  = isOutgoing;
            rightTriangleView.Hidden = !isOutgoing;

            if (isNewActopmPlanPrompt && message.ActionPlan != null)
            {
                foreach (var v in topView.Subviews)
                {
                    v.RemoveFromSuperview();
                }

                var suggestionCircleView = new CircleAvatarView
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Image           = Constants.Assets.MapFromActionPlanIcon(message.ActionPlan.Icon),
                    BackgroundColor = Constants.Color.MapFromActionPlanColor(message.ActionPlan.Color),
                };

                topView.AddSubview(suggestionCircleView);
                suggestionCircleView.LeftAnchor.ConstraintEqualTo(topView.LeftAnchor).Active       = true;
                suggestionCircleView.CenterYAnchor.ConstraintEqualTo(topView.CenterYAnchor).Active = true;
                suggestionCircleView.WidthAnchor.ConstraintEqualTo(smallerCircleSize).Active       = true;
                suggestionCircleView.HeightAnchor.ConstraintEqualTo(smallerCircleSize).Active      = true;

                var titleLabel = new UILabel
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text      = message.ActionPlan.Name,
                    Font      = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Ten),
                    TextColor = Constants.Color.MidGray,
                };
                topView.AddSubview(titleLabel);
                titleLabel.LeftAnchor.ConstraintEqualTo(suggestionCircleView.RightAnchor, constant: padding / 2).Active = true;
                titleLabel.CenterYAnchor.ConstraintEqualTo(topView.CenterYAnchor).Active = true;
                titleLabel.RightAnchor.ConstraintEqualTo(topView.RightAnchor).Active     = true;
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(Constants.Assets.ArrowLeft, UIBarButtonItemStyle.Plain, (sender, e) =>
            {
                NavigationController.PopViewController(true);
            });

            NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes
            {
                ForegroundColor = Constants.Color.White,
                Font            = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Eighteen),
            };

            NavigationController.InteractivePopGestureRecognizer.Delegate = null;

            View.BackgroundColor = Constants.Color.BackgroundLightGray;

            Title = $"Set Up {ViewModel.DeviceTypeAsString}";

            cameraView = new CameraView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            View.AddSubview(cameraView);

            cameraView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor).Active = true;
            cameraView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active   = true;
            cameraView.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true;
            cameraView.HeightAnchor.ConstraintEqualTo(View.HeightAnchor, multiplier: 0.55f).Active = true;

            var padding    = Constants.Padding;
            var circleSize = Constants.CircleNumberSize;

            var circleView = new CircleNumberView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Number = 3,
            };

            View.AddSubview(circleView);

            circleView.TopAnchor.ConstraintEqualTo(cameraView.BottomAnchor, constant: padding).Active = true;
            circleView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor, constant: padding).Active        = true;
            circleView.WidthAnchor.ConstraintEqualTo(circleSize).Active = true;
            circleView.HeightAnchor.ConstraintEqualTo(circleView.WidthAnchor).Active = true;

            var scanLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor = Constants.Color.MidGray,
                Font      = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Eighteen),
                AdjustsFontSizeToFitWidth = true,
                MinimumScaleFactor        = 0.1f,
                LineBreakMode             = UILineBreakMode.WordWrap,
                Lines = 0,
                Text  = $"Scan the QR Code on the {ViewModel.DeviceTypeAsString.ToLower()} to connect it to this phone.",
            };

            View.AddSubview(scanLabel);

            scanLabel.LeftAnchor.ConstraintEqualTo(circleView.RightAnchor, constant: padding).Active = true;
            scanLabel.CenterYAnchor.ConstraintEqualTo(circleView.CenterYAnchor).Active           = true;
            scanLabel.RightAnchor.ConstraintEqualTo(View.RightAnchor, constant: -padding).Active = true;

            var bottomLayoutGuide = new UILayoutGuide();

            View.AddLayoutGuide(bottomLayoutGuide);

            bottomLayoutGuide.TopAnchor.ConstraintEqualTo(scanLabel.BottomAnchor).Active = true;
            bottomLayoutGuide.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor).Active = true;

            noQRCodeButton = new UIButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = Constants.Color.DarkBlue,
            };

            noQRCodeButton.SetAttributedTitle(new NSAttributedString("NO QR CODE?", new UIStringAttributes
            {
                Font            = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Eighteen),
                ForegroundColor = Constants.Color.White,
            }), UIControlState.Normal);

            noQRCodeButton.AddStandardShadow();

            View.AddSubview(noQRCodeButton);

            noQRCodeButton.WidthAnchor.ConstraintEqualTo(View.WidthAnchor, multiplier: 0.5f).Active = true;
            noQRCodeButton.HeightAnchor.ConstraintEqualTo(44).Active = true;
            noQRCodeButton.CenterXAnchor.ConstraintEqualTo(View.CenterXAnchor).Active = true;
            noQRCodeButton.CenterYAnchor.ConstraintEqualTo(bottomLayoutGuide.CenterYAnchor).Active = true;
        }
Exemple #11
0
 public RowContainer(UILayoutGuide guide, UIView[] cells, NSLayoutConstraint rowHeightConstraint)
 {
     Guide = guide;
     Cells = cells;
     RowHeightConstraint = rowHeightConstraint;
 }
		UILayoutGuide NewLayoutGuide (string identifierName)
		{
			var newGuide = new UILayoutGuide {
				Identifier = identifierName
			};

			View.AddLayoutGuide (newGuide);
			return newGuide;
		}
		NSLayoutConstraint GuideHeightToPlanet (UILayoutGuide layoutGuide, UIView planet, string identifier)
		{
			NSLayoutConstraint guideHeightToPlanet = layoutGuide.HeightAnchor.ConstraintEqualTo (planet.HeightAnchor);
			guideHeightToPlanet.SetIdentifier (identifier);
			return guideHeightToPlanet;
		}
Exemple #14
0
 private ConstraintLayoutGuide(UILayoutGuide guide)
 {
     _value = guide;
 }
Exemple #15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Constants.Color.BackgroundLightGray;

            Title = "Set Up New Device";

            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(Constants.Assets.ArrowLeft, UIBarButtonItemStyle.Plain, (sender, e) =>
            {
                NavigationController.PopViewController(true);
            });

            NavigationController.InteractivePopGestureRecognizer.Delegate = null;

            var topHalfLayoutGuide = new UILayoutGuide();

            View.AddLayoutGuide(topHalfLayoutGuide);
            topHalfLayoutGuide.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor).Active = true;
            topHalfLayoutGuide.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active   = true;
            topHalfLayoutGuide.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true;
            topHalfLayoutGuide.HeightAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.HeightAnchor, multiplier: 0.5f).Active = true;

            var bottomHalfLayoutGuide = new UILayoutGuide();

            View.AddLayoutGuide(bottomHalfLayoutGuide);
            bottomHalfLayoutGuide.TopAnchor.ConstraintEqualTo(topHalfLayoutGuide.BottomAnchor).Active = true;
            bottomHalfLayoutGuide.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active   = true;
            bottomHalfLayoutGuide.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true;
            bottomHalfLayoutGuide.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor).Active = true;

            var padding    = Constants.Padding;
            var circleSize = Constants.CircleNumberSize;

            var oneCircleNumberView = new CircleNumberView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Number = 1,
            };

            View.AddSubview(oneCircleNumberView);
            oneCircleNumberView.TopAnchor.ConstraintEqualTo(topHalfLayoutGuide.TopAnchor, constant: padding).Active   = true;
            oneCircleNumberView.LeftAnchor.ConstraintEqualTo(topHalfLayoutGuide.LeftAnchor, constant: padding).Active = true;
            oneCircleNumberView.WidthAnchor.ConstraintEqualTo(circleSize).Active = true;
            oneCircleNumberView.HeightAnchor.ConstraintEqualTo(oneCircleNumberView.WidthAnchor).Active = true;

            var deviceTypeLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor = Constants.Color.MidGray,
                Font      = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Eighteen),
                AdjustsFontSizeToFitWidth = true,
                MinimumScaleFactor        = 0.1f,
                LineBreakMode             = UILineBreakMode.Clip,
                Lines = 0,
                Text  = "What type of device?",
            };

            View.AddSubview(deviceTypeLabel);
            deviceTypeLabel.LeftAnchor.ConstraintEqualTo(oneCircleNumberView.RightAnchor, constant: padding).Active = true;
            deviceTypeLabel.CenterYAnchor.ConstraintEqualTo(oneCircleNumberView.CenterYAnchor).Active = true;
            deviceTypeLabel.RightAnchor.ConstraintEqualTo(topHalfLayoutGuide.RightAnchor).Active      = true;

            buttonCheckboxView = new CheckBoxItemView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor         = Constants.Color.DarkGray,
                SelectedTextColor = Constants.Color.DarkBlue,
                Text = "Button",
            };

            buttonCheckboxView.OnTap += HandleCheckboxTap;

            View.AddSubview(buttonCheckboxView);

            buttonCheckboxView.LeftAnchor.ConstraintEqualTo(deviceTypeLabel.LeftAnchor, constant: -Constants.Padding).Active = true;
            buttonCheckboxView.TopAnchor.ConstraintEqualTo(deviceTypeLabel.BottomAnchor, constant: padding).Active           = true;
            buttonCheckboxView.RightAnchor.ConstraintEqualTo(topHalfLayoutGuide.RightAnchor, constant: -padding).Active      = true;
            buttonCheckboxView.HeightAnchor.ConstraintEqualTo(topHalfLayoutGuide.HeightAnchor, multiplier: 0.25f).Active     = true;

            soundSensorCheckboxView = new CheckBoxItemView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor         = Constants.Color.DarkGray,
                SelectedTextColor = Constants.Color.DarkBlue,
                Text = "Sound Sensor",
            };

            soundSensorCheckboxView.OnTap += HandleCheckboxTap;

            View.AddSubview(soundSensorCheckboxView);

            soundSensorCheckboxView.LeftAnchor.ConstraintEqualTo(deviceTypeLabel.LeftAnchor, constant: -Constants.Padding).Active = true;
            soundSensorCheckboxView.TopAnchor.ConstraintEqualTo(buttonCheckboxView.BottomAnchor, constant: padding).Active        = true;
            soundSensorCheckboxView.RightAnchor.ConstraintEqualTo(topHalfLayoutGuide.RightAnchor, constant: -padding).Active      = true;
            soundSensorCheckboxView.HeightAnchor.ConstraintEqualTo(topHalfLayoutGuide.HeightAnchor, multiplier: 0.25f).Active     = true;

            lightCheckboxView = new CheckBoxItemView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor         = Constants.Color.DarkGray,
                SelectedTextColor = Constants.Color.DarkBlue,
                Text = "Light",
            };

            lightCheckboxView.OnTap += HandleCheckboxTap;

            View.AddSubview(lightCheckboxView);

            lightCheckboxView.LeftAnchor.ConstraintEqualTo(deviceTypeLabel.LeftAnchor, constant: -Constants.Padding).Active = true;
            lightCheckboxView.TopAnchor.ConstraintEqualTo(soundSensorCheckboxView.BottomAnchor, constant: padding).Active   = true;
            lightCheckboxView.RightAnchor.ConstraintEqualTo(topHalfLayoutGuide.RightAnchor, constant: -padding).Active      = true;
            lightCheckboxView.HeightAnchor.ConstraintEqualTo(topHalfLayoutGuide.HeightAnchor, multiplier: 0.25f).Active     = true;

            var twoCircleNumberView = new CircleNumberView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Number = 2,
            };

            View.AddSubview(twoCircleNumberView);
            twoCircleNumberView.TopAnchor.ConstraintEqualTo(bottomHalfLayoutGuide.TopAnchor, constant: padding).Active   = true;
            twoCircleNumberView.LeftAnchor.ConstraintEqualTo(bottomHalfLayoutGuide.LeftAnchor, constant: padding).Active = true;
            twoCircleNumberView.WidthAnchor.ConstraintEqualTo(circleSize).Active = true;
            twoCircleNumberView.HeightAnchor.ConstraintEqualTo(twoCircleNumberView.WidthAnchor).Active = true;

            var powerLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor = Constants.Color.MidGray,
                Font      = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Eighteen),
                AdjustsFontSizeToFitWidth = true,
                MinimumScaleFactor        = 0.1f,
                LineBreakMode             = UILineBreakMode.Clip,
                Lines = 0,
                Text  = "Turn on the device power.",
            };

            View.AddSubview(powerLabel);
            powerLabel.LeftAnchor.ConstraintEqualTo(twoCircleNumberView.RightAnchor, constant: padding).Active = true;
            powerLabel.CenterYAnchor.ConstraintEqualTo(twoCircleNumberView.CenterYAnchor).Active = true;
            powerLabel.RightAnchor.ConstraintEqualTo(bottomHalfLayoutGuide.RightAnchor).Active   = true;

            nextButton = new UIButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = Constants.Color.DarkBlue,
                Enabled         = false,
                Alpha           = 0.4f,
            };

            nextButton.SetAttributedTitle(new NSAttributedString("NEXT", new UIStringAttributes
            {
                Font            = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Eighteen),
                ForegroundColor = Constants.Color.White,
            }), UIControlState.Normal);

            var buttonCenterLayoutGuide = new UILayoutGuide();

            View.AddLayoutGuide(buttonCenterLayoutGuide);
            buttonCenterLayoutGuide.TopAnchor.ConstraintEqualTo(powerLabel.BottomAnchor).Active = true;
            buttonCenterLayoutGuide.BottomAnchor.ConstraintEqualTo(bottomHalfLayoutGuide.BottomAnchor).Active = true;

            View.AddSubview(nextButton);
            nextButton.WidthAnchor.ConstraintEqualTo(bottomHalfLayoutGuide.WidthAnchor, multiplier: 0.5f).Active = true;
            nextButton.HeightAnchor.ConstraintEqualTo(44).Active = true;
            nextButton.CenterYAnchor.ConstraintEqualTo(buttonCenterLayoutGuide.CenterYAnchor).Active = true;
            nextButton.CenterXAnchor.ConstraintEqualTo(bottomHalfLayoutGuide.CenterXAnchor).Active   = true;

            nextButton.AddStandardShadow();
        }
 public void Recycle(UILayoutGuide guide)
 {
     _usables.Enqueue(guide);
 }
Exemple #17
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            NavigationController.NavigationBar.SetBackgroundImage(null, UIBarMetrics.Default);
            NavigationController.NavigationBar.ShadowImage     = null;
            NavigationController.NavigationBar.Translucent     = true;
            NavigationController.NavigationBar.BackgroundColor = Constants.Color.DarkBlue;
            NavigationController.NavigationBar.BarTintColor    = Constants.Color.DarkBlue;
            NavigationController.NavigationBar.TintColor       = Constants.Color.White;

            NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes
            {
                ForegroundColor = Constants.Color.White,
                Font            = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Eighteen),
            };

            var deviceTypeImageView = new UIImageView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Image = ViewModel.DeviceModel?.Sensor ?? false ? Constants.Assets.Lines : Constants.Assets.Power,
            };

            View.AddSubview(deviceTypeImageView);

            deviceTypeImageView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor, constant: Constants.Padding).Active = true;
            deviceTypeImageView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor, constant: Constants.Padding).Active = true;
            deviceTypeImageView.WidthAnchor.ConstraintEqualTo(32).Active = true;
            deviceTypeImageView.HeightAnchor.ConstraintEqualTo(deviceTypeImageView.WidthAnchor).Active = true;

            var deviceLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text      = ViewModel.DeviceModel.Name,
                Font      = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.TwentyFour),
                TextColor = Constants.Color.DarkGray,
            };

            View.AddSubview(deviceLabel);

            deviceLabel.CenterYAnchor.ConstraintEqualTo(deviceTypeImageView.CenterYAnchor).Active = true;
            deviceLabel.LeftAnchor.ConstraintEqualTo(deviceTypeImageView.RightAnchor, constant: Constants.Padding).Active = true;
            deviceLabel.RightAnchor.ConstraintEqualTo(View.RightAnchor, constant: -Constants.Padding).Active = true;

            var locationLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text      = "Device Location",
                Font      = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Fourteen),
                TextColor = Constants.Color.DarkGray,
            };

            View.AddSubview(locationLabel);

            locationLabel.TopAnchor.ConstraintEqualTo(deviceTypeImageView.BottomAnchor, constant: Constants.Padding).Active = true;
            locationLabel.LeftAnchor.ConstraintEqualTo(View.LeftAnchor, constant: Constants.Padding).Active = true;

            mapView = new MKMapView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                CenterCoordinate = ViewModel.DeviceModel.Geolocation != null
                    ? new CLLocationCoordinate2D(ViewModel.DeviceModel.Geolocation.Latitude, ViewModel.DeviceModel.Geolocation.Longitude)
                    : new CLLocationCoordinate2D(),
            };

            View.AddSubview(mapView);

            mapView.AddStandardShadow();

            mapView.TopAnchor.ConstraintEqualTo(locationLabel.BottomAnchor, constant: Constants.Padding).Active = true;
            mapView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active   = true;
            mapView.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true;
            mapView.HeightAnchor.ConstraintEqualTo(View.HeightAnchor, multiplier: 0.25f).Active = true;

            pinView = new MKPinAnnotationView(CGRect.Empty)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            var pinHeight = 39;

            View.AddSubview(pinView);
            pinView.CenterXAnchor.ConstraintEqualTo(mapView.CenterXAnchor, constant: pinView.CenterOffset.X).Active = true;
            pinView.CenterYAnchor.ConstraintEqualTo(mapView.CenterYAnchor, constant: pinView.CenterOffset.Y).Active = true;
            pinView.HeightAnchor.ConstraintEqualTo(pinHeight).Active = true;
            pinView.WidthAnchor.ConstraintEqualTo(pinHeight).Active  = true;

            var moveLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Lines         = 0,
                LineBreakMode = UILineBreakMode.WordWrap,
                TextColor     = Constants.Color.MidGray,
                Font          = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Twelve),
                Text          = "MOVE THE PIN AS NEEDED TO MAKE SURE ITS LOCATION ACCURATELY REPRESENTS A PRECISE SPOT WHERE THE DEVICE WILL BE.",
            };

            View.AddSubview(moveLabel);

            moveLabel.LeftAnchor.ConstraintEqualTo(View.LeftAnchor, constant: Constants.Padding).Active     = true;
            moveLabel.TopAnchor.ConstraintEqualTo(mapView.BottomAnchor, constant: Constants.Padding).Active = true;
            moveLabel.RightAnchor.ConstraintEqualTo(View.RightAnchor, constant: -Constants.Padding).Active  = true;

            buildingTextFieldView = new TextFieldView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                LabelText = "Building",
            };

            View.AddSubview(buildingTextFieldView);

            buildingTextFieldView.TopAnchor.ConstraintEqualTo(moveLabel.BottomAnchor, constant: Constants.Padding).Active = true;
            buildingTextFieldView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active   = true;
            buildingTextFieldView.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true;

            floorTextFieldView = new TextFieldView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                LabelText = "Floor",
            };

            View.AddSubview(floorTextFieldView);

            floorTextFieldView.TopAnchor.ConstraintEqualTo(buildingTextFieldView.BottomAnchor, constant: Constants.Padding / 2).Active = true;
            floorTextFieldView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active   = true;
            floorTextFieldView.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true;

            roomTextFieldView = new TextFieldView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                LabelText = "Room",
            };

            View.AddSubview(roomTextFieldView);

            roomTextFieldView.TopAnchor.ConstraintEqualTo(floorTextFieldView.BottomAnchor, constant: Constants.Padding / 2).Active = true;
            roomTextFieldView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active   = true;
            roomTextFieldView.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true;

            wifiTextFieldView = new TextFieldView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                LabelText = "WiFi",
            };

            View.AddSubview(wifiTextFieldView);

            wifiTextFieldView.TopAnchor.ConstraintEqualTo(roomTextFieldView.BottomAnchor, constant: Constants.Padding * 2).Active = true;
            wifiTextFieldView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active   = true;
            wifiTextFieldView.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true;

            var bottomAreaLayoutGuide = new UILayoutGuide();

            View.AddLayoutGuide(bottomAreaLayoutGuide);

            bottomAreaLayoutGuide.TopAnchor.ConstraintEqualTo(wifiTextFieldView.BottomAnchor).Active           = true;
            bottomAreaLayoutGuide.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor).Active = true;

            doneButton = new UIButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = Constants.Color.DarkBlue,
            };

            doneButton.SetAttributedTitle(new NSAttributedString("DONE", new UIStringAttributes
            {
                Font            = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Eighteen),
                ForegroundColor = Constants.Color.White,
            }), UIControlState.Normal);

            doneButton.AddStandardShadow();

            View.AddSubview(doneButton);

            doneButton.WidthAnchor.ConstraintEqualTo(View.WidthAnchor, multiplier: 0.5f).Active = true;
            doneButton.HeightAnchor.ConstraintEqualTo(44).Active = true;
            doneButton.CenterXAnchor.ConstraintEqualTo(View.CenterXAnchor).Active = true;
            doneButton.CenterYAnchor.ConstraintEqualTo(bottomAreaLayoutGuide.CenterYAnchor).Active = true;
        }
Exemple #18
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Constants.Color.BackgroundLightGray;

            Title = $"Set Up {ViewModel.DeviceTypeAsString}";

            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(Constants.Assets.ArrowLeft, UIBarButtonItemStyle.Plain, (sender, e) =>
            {
                NavigationController.PopViewController(true);
            });

            var padding = Constants.Padding;

            var circleNumberView = new CircleNumberView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Number = 5,
            };

            View.AddSubview(circleNumberView);
            circleNumberView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor, constant: padding).Active = true;
            circleNumberView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor, constant: padding).Active = true;
            circleNumberView.WidthAnchor.ConstraintEqualTo(Constants.CircleNumberSize).Active        = true;
            circleNumberView.HeightAnchor.ConstraintEqualTo(circleNumberView.WidthAnchor).Active     = true;

            var enterPasswordLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor = Constants.Color.MidGray,
                Font      = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Eighteen),
                AdjustsFontSizeToFitWidth = true,
                MinimumScaleFactor        = 0.1f,
                LineBreakMode             = UILineBreakMode.WordWrap,
                Lines = 0,
                Text  = $"Enter the password for {selectedWifiNetwork.SSID}",
            };

            View.AddSubview(enterPasswordLabel);
            enterPasswordLabel.LeftAnchor.ConstraintEqualTo(circleNumberView.RightAnchor, constant: padding).Active = true;
            enterPasswordLabel.CenterYAnchor.ConstraintEqualTo(circleNumberView.CenterYAnchor).Active     = true;
            enterPasswordLabel.RightAnchor.ConstraintEqualTo(View.RightAnchor, constant: -padding).Active = true;

            bottomLayoutGuide = new UILayoutGuide();

            View.AddLayoutGuide(bottomLayoutGuide);

            bottomLayoutGuide.TopAnchor.ConstraintEqualTo(enterPasswordLabel.BottomAnchor).Active = true;
            bottomLayoutConstraint        = bottomLayoutGuide.BottomAnchor.ConstraintEqualTo(View.BottomAnchor);
            bottomLayoutConstraint.Active = true;

            passwordTextFieldView = new TextFieldView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                SecureTextEntry = true,
                LabelText       = "Password",
                ReturnKeyType   = UIReturnKeyType.Go,
            };

            View.AddSubview(passwordTextFieldView);

            passwordTextFieldView.CenterXAnchor.ConstraintEqualTo(View.CenterXAnchor).Active = true;
            passwordTextFieldView.CenterYAnchor.ConstraintEqualTo(bottomLayoutGuide.CenterYAnchor).Active = true;
            passwordTextFieldView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active   = true;
            passwordTextFieldView.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true;

            showPasswordButton = new UIButton {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            showPasswordButton.SetTitle("Show Password", UIControlState.Normal);
            showPasswordButton.TitleLabel.Font = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Fourteen);
            showPasswordButton.SetTitleColor(Constants.Color.DarkBlue, UIControlState.Normal);

            View.AddSubview(showPasswordButton);

            showPasswordButton.TopAnchor.ConstraintEqualTo(passwordTextFieldView.BottomAnchor, constant: padding / 2).Active = true;
            showPasswordButton.RightAnchor.ConstraintEqualTo(passwordTextFieldView.RightAnchor, constant: -padding).Active   = true;
        }
Exemple #19
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Constants.Color.White;

            containerView = new UIView {
                TranslatesAutoresizingMaskIntoConstraints = false, Alpha = 0
            };
            View.AddSubview(containerView);
            containerView.TopAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.TopAnchor).Active       = true;
            containerView.BottomAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.BottomAnchor).Active = true;
            containerView.LeftAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.LeftAnchor).Active     = true;
            containerView.RightAnchor.ConstraintEqualTo(View.LayoutMarginsGuide.RightAnchor).Active   = true;

            var deviceSetupLayoutGuide = new UILayoutGuide();

            containerView.AddLayoutGuide(deviceSetupLayoutGuide);
            deviceSetupLayoutGuide.CenterXAnchor.ConstraintEqualTo(containerView.CenterXAnchor).Active = true;
            deviceSetupLayoutGuide.CenterYAnchor.ConstraintEqualTo(containerView.CenterYAnchor).Active = true;

            sensorsImageView = new UIImageView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Image = Constants.Assets.SensorsGray,
            };
            containerView.AddSubview(sensorsImageView);

            sensorsImageView.CenterXAnchor.ConstraintEqualTo(containerView.CenterXAnchor).Active = true;
            sensorsImageView.CenterYAnchor.ConstraintEqualTo(containerView.CenterYAnchor).Active = true;

            deviceSetupLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Eighteen),
                TextColor = Constants.Color.MidGray,
                Text      = "Device Setup",
            };
            containerView.AddSubview(deviceSetupLabel);

            deviceSetupLabel.CenterXAnchor.ConstraintEqualTo(containerView.CenterXAnchor).Active = true;
            deviceSetupLabel.TopAnchor.ConstraintEqualTo(sensorsImageView.BottomAnchor, constant: Constants.Padding).Active = true;

            signInButton = new UIButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            signInButton.SetAttributedTitle(new NSAttributedString("SIGN IN", new UIStringAttributes
            {
                Font            = Constants.Fonts.RubikMediumOfSize(Constants.Fonts.Size.Eighteen),
                ForegroundColor = Constants.Color.White,
            }), UIControlState.Normal);
            containerView.AddSubview(signInButton);
            signInButton.CenterXAnchor.ConstraintEqualTo(containerView.CenterXAnchor).Active             = true;
            signInButton.TopAnchor.ConstraintEqualTo(deviceSetupLabel.BottomAnchor, constant: 60).Active = true;

            var signInButtonBackground = new UIView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = Constants.Color.DarkBlue,
            };

            containerView.InsertSubviewBelow(signInButtonBackground, signInButton);
            signInButtonBackground.CenterXAnchor.ConstraintEqualTo(signInButton.CenterXAnchor).Active = true;
            signInButtonBackground.CenterYAnchor.ConstraintEqualTo(signInButton.CenterYAnchor).Active = true;
            signInButtonBackground.HeightAnchor.ConstraintEqualTo(44).Active = true;
            signInButtonBackground.WidthAnchor.ConstraintEqualTo(containerView.WidthAnchor, multiplier: 0.5f).Active = true;

            var browserLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text      = "A browser window will open",
                TextColor = Constants.Color.MidGray,
                Font      = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Twelve),
            };

            containerView.AddSubview(browserLabel);
            browserLabel.CenterXAnchor.ConstraintEqualTo(containerView.CenterXAnchor).Active = true;
            browserLabel.TopAnchor.ConstraintEqualTo(signInButtonBackground.BottomAnchor, constant: 30).Active = true;

            logoImageView = new UIImageView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Image = Constants.Assets.LoginLogo,
            };
            containerView.AddSubview(logoImageView);
            logoImageView.BottomAnchor.ConstraintEqualTo(sensorsImageView.TopAnchor, constant: -60).Active = true;
            logoImageView.CenterXAnchor.ConstraintEqualTo(containerView.CenterXAnchor).Active = true;
        }