void OnTextFieldEditingBegan(object sender, EventArgs e) { if (sender is TextFieldView textFieldView) { textFieldViewFirstResponder = textFieldView; } }
private void ConfigureTextField(TextFieldView view) { bool multiLine = view.MultiLine; view.Width.Value = multiLine ? 380 : 340; view.Height.Value = multiLine ? 200 : 20; }
public override void Awake() { base.Awake(); if (RootConsoleView == null) { int width = main.ScreenSize.Value.X - 6; int textBoxWidth = width - 0; RootConsoleView = new View(main.GeeUI, main.GeeUI.RootView).SetWidth(width + 6).SetHeight(210); ConsoleLogView = (TextFieldView) new TextFieldView(main.GeeUI, RootConsoleView, new Vector2(0, 0)).SetWidth(textBoxWidth) .SetHeight(175); ConsoleInputView = (TextFieldView) new TextFieldView(main.GeeUI, RootConsoleView, new Vector2(0, 0)).SetWidth(textBoxWidth).SetHeight(20); ConsoleLogView.Editable = false; ConsoleInputView.OnTextSubmitted = OnTextSubmitted; ConsoleInputView.MultiLine = false; RootConsoleView.ChildrenLayouts.Add(new VerticalViewLayout(0, false)); this.Add(new NotifyBinding(HandleResize, main.ScreenSize)); //Supercool~ this.Add(new NotifyBinding(HandleToggle, Showing)); this.main.GeeUI.OnKeyPressedHandler += this.keyPressedHandler; } Showing.Value = false; }
private void Awake() { var verticalLayout = new VerticalLayout().AddTo(this); new LabelView("功能名:") .FontBold() .TextMiddleCenter() .FontSize(15) .AddTo(verticalLayout); nameInputView = new TextFieldView(string.Empty).FontSize(20).AddTo(verticalLayout); new SpaceView(8f).AddTo(verticalLayout); new LabelView("描述:") .FontBold() .TextMiddleCenter() .FontSize(15) .AddTo(verticalLayout); descInputView = new TextFieldView(string.Empty).FontSize(20).AddTo(verticalLayout); new SpaceView(8f).AddTo(verticalLayout); saveCreateBtn = new ButtonView("保存", SaveOrCreateEvent, true).AddTo(verticalLayout); }
/// <summary> /// Конструктор /// </summary> /// <param name="parTextField">Текстовое поле</param> /// <param name="parPlatform">Объект платформы</param> public TextFieldController(TextField parTextField, Platform parPlatform) { _textField = parTextField; View = new TextFieldView(parPlatform, parTextField); parPlatform.KeyDown += OnKeyDown; parPlatform.BackspaceDown += OnBackspaceDown; }
private void Awake() { todoVersion = new ToDoVersion(0, 0, 0); var verticalLayout = new VerticalLayout("box").AddTo(this); var addHor = new HorizontalLayout().AddTo(verticalLayout); new SpaceView(98).AddTo(addHor); new ButtonView("+", () => UpdateMajor(true)).Height(20).Width(20).FontSize(10).AddTo(addHor); new SpaceView(15).AddTo(addHor); new ButtonView("+", () => UpdateMiddle(true)).Height(20).Width(20).FontSize(10).AddTo(addHor); new SpaceView(15).AddTo(addHor); new ButtonView("+", () => UpdateSmall(true)).Height(20).Width(20).FontSize(10).AddTo(addHor); var versionHor = new HorizontalLayout().AddTo(verticalLayout); new LabelView("版本号:").Width(80).FontBold().FontSize(20).AddTo(versionHor); new LabelView("V").FontSize(10).Height(20).Width(11).FontBold().AddTo(versionHor); majorView = new LabelView("0").FontSize(20).Height(20).Width(20).FontBold() .AddTo(versionHor); new LabelView(".").FontSize(20).Height(20).Width(11).FontBold().AddTo(versionHor); middleView = new LabelView("0").FontSize(20).Height(20).Width(20).FontBold() .AddTo(versionHor); new LabelView(".").FontSize(20).Height(20).Width(11).FontBold().AddTo(versionHor); smallView = new LabelView("0").FontSize(20).Height(20).Width(20).FontBold() .AddTo(versionHor); var reduceHor = new HorizontalLayout().AddTo(verticalLayout); new SpaceView(98).AddTo(reduceHor); new ButtonView("-", () => UpdateMajor(false)).TextMiddleCenter().Height(20).Width(20).FontSize(10) .AddTo(reduceHor); new SpaceView(15).AddTo(reduceHor); new ButtonView("-", () => UpdateMiddle(false)).TextMiddleCenter().Height(20).Width(20).FontSize(10) .AddTo(reduceHor); new SpaceView(15).AddTo(reduceHor); new ButtonView("-", () => UpdateSmall(false)).TextMiddleCenter().Height(20).Width(20).FontSize(10) .AddTo(reduceHor); new SpaceView().AddTo(verticalLayout); var nameHor = new HorizontalLayout().AddTo(verticalLayout); new LabelView("版本名:").FontBold().Width(80).FontSize(20).AddTo(nameHor); versionNameView = new TextFieldView(productName, str => productName = str).FontSize(20).AddTo(nameHor); new SpaceView().AddTo(verticalLayout); new ButtonView("保存", SaveProduct, true).AddTo(verticalLayout); }
public override void Awake() { // This is to make it so nothing else can be interacted with. this.EncompassingView = new View(this.main.GeeUI, this.main.GeeUI.RootView); this.MainView = new PanelView(this.main.GeeUI, this.EncompassingView, Vector2.Zero); MainView.Resizeable = false; MainView.AnchorPoint.Value = new Vector2(0.5f, 0.5f); MainView.Width.Value = 400; MainView.Height.Value = 100; this.EncompassingView.Add(new Binding <int, Point>(EncompassingView.Height, (p) => p.Y, main.ScreenSize)); this.EncompassingView.Add(new Binding <int, Point>(EncompassingView.Width, (p) => p.X, main.ScreenSize)); this.MainView.Add(new Binding <Vector2, int>(MainView.Position, i => new Vector2(i / 2f, MainView.Y), EncompassingView.Width)); this.MainView.Add(new Binding <Vector2, int>(MainView.Position, i => new Vector2(MainView.X, i / 2f), EncompassingView.Height)); new TextView(this.main.GeeUI, this.MainView, this.label, new Vector2(10, 8)); this.Text = new TextFieldView(this.main.GeeUI, this.MainView, new Vector2(10, 25)) { MultiLine = false, }; this.Text.Height.Value = 20; this.Text.Width.Value = 340; this.Text.Text = this.defaultText; this.Text.Selected.Value = true; this.Okay = new ButtonView(main.GeeUI, MainView, this.action, new Vector2(50, 60)); this.Cancel = new ButtonView(main.GeeUI, MainView, "Cancel", new Vector2(300, 60)); this.Okay.OnMouseClick += (sender, args) => { this.Go(); }; this.Cancel.OnMouseClick += (sender, args) => { this.Delete.Execute(); }; base.Awake(); this.Text.ParentGeeUI.OnKeyPressedHandler += this.keyHandler; }
public override void Awake() { // This is to make it so nothing else can be interacted with. this.EncompassingView = new View(main.GeeUI, main.GeeUI.RootView); this.MainView = new PanelView(main.GeeUI, EncompassingView, Vector2.Zero); MainView.Resizeable = false; MainView.AnchorPoint.Value = new Vector2(0.5f, 0.5f); MainView.Width.Value = 400; MainView.Height.Value = 400; this.EncompassingView.Add(new Binding <int, Point>(EncompassingView.Height, (p) => p.Y, main.ScreenSize)); this.EncompassingView.Add(new Binding <int, Point>(EncompassingView.Width, (p) => p.X, main.ScreenSize)); this.MainView.Add(new Binding <Vector2, int>(MainView.Position, i => new Vector2(i / 2f, MainView.Y), EncompassingView.Width)); this.MainView.Add(new Binding <Vector2, int>(MainView.Position, i => new Vector2(MainView.X, i / 2f), EncompassingView.Height)); new TextView(main.GeeUI, MainView, "Workshop entry:", new Vector2(10, 8)); this.SelectFile = new DropDownView(main.GeeUI, MainView, new Vector2(10, 35)); SelectFile.AddOption("[Fetching...]", null); this.SelectFile.Position.Value = new Vector2(10, 30); this.queryResult = SteamWorker.GetCreatedWorkShopEntries((entries) => { SelectFile.RemoveAllOptions(); SelectFile.AddOption("[new]", delegate() { this.currentPublishedFile = default(SteamUGCDetails_t); this.UploadButton.Text = "Publish"; this.UploadButton.AllowMouseEvents.Value = true; this.CloseButton.AllowMouseEvents.Value = true; }); var listEntries = entries as List <SteamUGCDetails_t>; if (listEntries == null) { SelectFile.AddOption("[Error fetching entries]", null); return; } foreach (var entry in listEntries) { SteamUGCDetails_t entry1 = entry; SelectFile.AddOption(entry.m_rgchTitle, () => { this.currentPublishedFile = entry1; this.NameView.Text = entry1.m_rgchTitle; this.DescriptionView.Text = entry1.m_rgchDescription; this.UploadButton.Text = "Update"; this.UploadButton.AllowMouseEvents.Value = true; this.CloseButton.AllowMouseEvents.Value = true; }, related: entry); } }); new TextView(main.GeeUI, MainView, "Name:", new Vector2(10, 68)); this.NameView = new TextFieldView(main.GeeUI, MainView, new Vector2(10, 85)) { MultiLine = false }; new TextView(main.GeeUI, MainView, "Description:", new Vector2(10, 118)); this.DescriptionView = new TextFieldView(main.GeeUI, MainView, new Vector2(10, 135)); this.UploadButton = new ButtonView(main.GeeUI, MainView, "Publish", new Vector2(50, 360)); this.CloseButton = new ButtonView(main.GeeUI, MainView, "Close", new Vector2(300, 360)); var statusString = new TextView(main.GeeUI, MainView, "Waiting", new Vector2(110, 365)) { TextJustification = TextJustification.Center, }; statusString.AutoSize.Value = false; statusString.Width.Value = 190; ConfigureTextField(NameView); ConfigureTextField(DescriptionView); UploadButton.OnMouseClick += (sender, args) => { DoUpload(); }; CloseButton.OnMouseClick += (sender, args) => { this.Delete.Execute(); }; this.Add(new Binding <string>(statusString.Text, StatusString)); base.Awake(); }
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; }
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; }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = Constants.Color.BackgroundLightGray; Title = "Manage Device"; NavigationItem.LeftBarButtonItem = new UIBarButtonItem(Constants.Assets.ArrowLeft, UIBarButtonItemStyle.Plain, (sender, e) => { NavigationController.PopViewController(true); }); NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, async(object sender, EventArgs e) => { NavigationItem.RightBarButtonItem.Enabled = false; UpdateCurrentDeviceAttributes(); await ViewModel.UpdateDevice(); NavigationItem.RightBarButtonItem.Enabled = true; }); NavigationController.InteractivePopGestureRecognizer.Delegate = null; 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 padding = Constants.Padding; var halfPadding = padding / 2; var doublePadding = padding * 2; scrollView = new UIScrollView { TranslatesAutoresizingMaskIntoConstraints = false, AlwaysBounceVertical = true, ShowsVerticalScrollIndicator = true, }; View.AddSubview(scrollView); scrollView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active = true; scrollView.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true; scrollView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor).Active = true; scrollViewBottomConstraint = scrollView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor); scrollViewBottomConstraint.Active = true; var deviceTypeImageView = new UIImageView { TranslatesAutoresizingMaskIntoConstraints = false, Image = ViewModel.CurrentDeviceModel?.Sensor ?? false ? Constants.Assets.Lines : Constants.Assets.Power, }; var importantDetailsLabel = 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 = "Let's give this device some important details...", }; if (!ViewModel.IsOnboardingStepSix) { scrollView.AddSubview(deviceTypeImageView); deviceTypeImageView.TopAnchor.ConstraintEqualTo(scrollView.TopAnchor, constant: padding).Active = true; deviceTypeImageView.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor, constant: padding).Active = true; deviceTypeImageView.WidthAnchor.ConstraintEqualTo(32).Active = true; deviceTypeImageView.HeightAnchor.ConstraintEqualTo(deviceTypeImageView.WidthAnchor).Active = true; var deviceLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = ViewModel.CurrentDeviceModel.Name, Font = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.TwentyFour), TextColor = Constants.Color.DarkGray, }; scrollView.AddSubview(deviceLabel); deviceLabel.CenterYAnchor.ConstraintEqualTo(deviceTypeImageView.CenterYAnchor).Active = true; deviceLabel.LeftAnchor.ConstraintEqualTo(deviceTypeImageView.RightAnchor, constant: padding).Active = true; deviceLabel.RightAnchor.ConstraintEqualTo(scrollView.RightAnchor, constant: -padding).Active = true; } else { var circleNumberView = new CircleNumberView { TranslatesAutoresizingMaskIntoConstraints = false, Number = 6, }; scrollView.AddSubview(circleNumberView); circleNumberView.TopAnchor.ConstraintEqualTo(scrollView.TopAnchor, constant: padding).Active = true; circleNumberView.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor, constant: padding).Active = true; circleNumberView.WidthAnchor.ConstraintEqualTo(Constants.CircleNumberSize).Active = true; circleNumberView.HeightAnchor.ConstraintEqualTo(circleNumberView.WidthAnchor).Active = true; scrollView.AddSubview(importantDetailsLabel); importantDetailsLabel.LeftAnchor.ConstraintEqualTo(circleNumberView.RightAnchor, constant: padding).Active = true; importantDetailsLabel.CenterYAnchor.ConstraintEqualTo(circleNumberView.CenterYAnchor).Active = true; importantDetailsLabel.RightAnchor.ConstraintEqualTo(View.RightAnchor, constant: -padding).Active = true; } var locationLabel = new UILabel { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Device Location", Font = Constants.Fonts.RubikOfSize(Constants.Fonts.Size.Fourteen), TextColor = Constants.Color.DarkGray, }; scrollView.AddSubview(locationLabel); locationLabel.TopAnchor.ConstraintEqualTo(!ViewModel.IsOnboardingStepSix ? deviceTypeImageView.BottomAnchor : importantDetailsLabel.BottomAnchor, constant: padding).Active = true; locationLabel.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor, constant: padding).Active = true; mapView = new MKMapView { TranslatesAutoresizingMaskIntoConstraints = false, ShowsUserLocation = true, CenterCoordinate = ViewModel.CurrentDeviceModel.Geolocation != null ? new CLLocationCoordinate2D(ViewModel.CurrentDeviceModel.Geolocation.Latitude, ViewModel.CurrentDeviceModel.Geolocation.Longitude) : new CLLocationCoordinate2D(), Delegate = this, }; scrollView.AddSubview(mapView); mapView.AddStandardShadow(); mapView.TopAnchor.ConstraintEqualTo(locationLabel.BottomAnchor, constant: padding).Active = true; mapView.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor).Active = true; mapView.WidthAnchor.ConstraintEqualTo(scrollView.WidthAnchor).Active = true; mapView.HeightAnchor.ConstraintEqualTo(View.HeightAnchor, multiplier: 0.25f).Active = true; if (ViewModel.CurrentDeviceModel.Geolocation == null) { Task.Run(async() => { var edisonLocation = await ViewModel.GetLastKnownLocation(); if (edisonLocation == null) { return; } InvokeOnMainThread(() => mapView.CenterCoordinate = new CLLocationCoordinate2D { Latitude = edisonLocation.Latitude, Longitude = edisonLocation.Longitude, }); }); } pinView = new MKPinAnnotationView(CGRect.Empty) { TranslatesAutoresizingMaskIntoConstraints = false, }; var pinHeight = 39; scrollView.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.", }; scrollView.AddSubview(moveLabel); moveLabel.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor, constant: padding).Active = true; moveLabel.TopAnchor.ConstraintEqualTo(mapView.BottomAnchor, constant: padding).Active = true; moveLabel.WidthAnchor.ConstraintEqualTo(View.WidthAnchor, constant: -padding).Active = true; nameTextFieldView = new TextFieldView { TranslatesAutoresizingMaskIntoConstraints = false, LabelText = "Name", }; scrollView.AddSubview(nameTextFieldView); nameTextFieldView.TopAnchor.ConstraintEqualTo(moveLabel.BottomAnchor, constant: padding).Active = true; nameTextFieldView.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor).Active = true; nameTextFieldView.WidthAnchor.ConstraintEqualTo(View.WidthAnchor).Active = true; enabledSwitchFieldView = new SwitchFieldView { TranslatesAutoresizingMaskIntoConstraints = false, LabelText = "Enabled", }; scrollView.AddSubview(enabledSwitchFieldView); enabledSwitchFieldView.TopAnchor.ConstraintEqualTo(nameTextFieldView.BottomAnchor, constant: padding).Active = true; enabledSwitchFieldView.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor).Active = true; enabledSwitchFieldView.WidthAnchor.ConstraintEqualTo(View.WidthAnchor).Active = true; buildingTextFieldView = new TextFieldView { TranslatesAutoresizingMaskIntoConstraints = false, LabelText = "Building", }; scrollView.AddSubview(buildingTextFieldView); buildingTextFieldView.TopAnchor.ConstraintEqualTo(enabledSwitchFieldView.BottomAnchor, constant: padding).Active = true; buildingTextFieldView.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor).Active = true; buildingTextFieldView.WidthAnchor.ConstraintEqualTo(View.WidthAnchor).Active = true; floorTextFieldView = new TextFieldView { TranslatesAutoresizingMaskIntoConstraints = false, LabelText = "Floor", }; scrollView.AddSubview(floorTextFieldView); floorTextFieldView.TopAnchor.ConstraintEqualTo(buildingTextFieldView.BottomAnchor, constant: halfPadding).Active = true; floorTextFieldView.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor).Active = true; floorTextFieldView.WidthAnchor.ConstraintEqualTo(View.WidthAnchor).Active = true; roomTextFieldView = new TextFieldView { TranslatesAutoresizingMaskIntoConstraints = false, LabelText = "Room", }; scrollView.AddSubview(roomTextFieldView); roomTextFieldView.TopAnchor.ConstraintEqualTo(floorTextFieldView.BottomAnchor, constant: halfPadding).Active = true; roomTextFieldView.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor).Active = true; roomTextFieldView.WidthAnchor.ConstraintEqualTo(View.WidthAnchor).Active = true; if (ViewModel.IsOnboardingStepSix) { roomTextFieldView.BottomAnchor.ConstraintEqualTo(scrollView.BottomAnchor, constant: -halfPadding).Active = true; } else { wifiTextFieldView = new TextFieldView { TranslatesAutoresizingMaskIntoConstraints = false, LabelText = "WiFi", }; scrollView.AddSubview(wifiTextFieldView); wifiTextFieldView.TopAnchor.ConstraintEqualTo(roomTextFieldView.BottomAnchor, constant: padding).Active = true; wifiTextFieldView.LeftAnchor.ConstraintEqualTo(scrollView.LeftAnchor).Active = true; wifiTextFieldView.WidthAnchor.ConstraintEqualTo(View.WidthAnchor).Active = true; wifiTextFieldView.BottomAnchor.ConstraintEqualTo(scrollView.BottomAnchor, constant: -halfPadding).Active = true; } textFieldViews = new List <TextFieldView> { nameTextFieldView, buildingTextFieldView, floorTextFieldView, roomTextFieldView, }; textFieldViews.ForEach(t => t.ReturnKeyType = UIReturnKeyType.Done); }
void OnTextFieldDone(object sender, EventArgs e) { (sender as TextFieldView).ResignFirstResponder(); textFieldViewFirstResponder = null; }