public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Auto Scroll Test"; View.BackgroundColor = UIColor.White; EdgesForExtendedLayout = UIRectEdge.None; // Create containers _contentView = new UIView(); var scrollView = new UIScrollView { _contentView }; Add(scrollView); // Create form elements const int count = 7; for (var i = 1; i <= count; i++) { _contentView.Add(new UITextField { Placeholder = $"Test {i}", BorderStyle = UITextBorderStyle.RoundedRect, Tag = i, ReturnKeyType = i < count ? UIReturnKeyType.Send : UIReturnKeyType.Done }); } var loginButton = new UIButton(UIButtonType.System); loginButton.SetTitle("Save", UIControlState.Normal); loginButton.TouchUpInside += (sender, args) => Save(); _contentView.Add(loginButton); // Auto layout View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); View.AddConstraints(scrollView.FullWidthOf(View)); View.AddConstraints(scrollView.FullHeightOf(View)); View.AddConstraints( _contentView.WithSameWidth(View), _contentView.WithSameHeight(View).SetPriority(UILayoutPriority.DefaultLow) ); scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); scrollView.AddConstraints(_contentView.FullWidthOf(scrollView)); scrollView.AddConstraints(_contentView.FullHeightOf(scrollView)); var formConstraints = _contentView .VerticalStackPanelConstraints(new Margins(20), _contentView.Subviews); // very important to make scrolling work var bottomViewConstraint = _contentView.Subviews.Last().AtBottomOf(_contentView).Minus(20); _contentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); _contentView.AddConstraints(formConstraints); _contentView.AddConstraints(bottomViewConstraint); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.FromRGB(204, 242, 255); _contentConteiner = new UIView(); _scrollView = new UIScrollView(); _scrollView.AddSubview(_contentConteiner); Add(_scrollView); _scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); _scrollView.AddConstraints(_contentConteiner.FullWidthOf(_scrollView)); _scrollView.AddConstraints(_contentConteiner.FullHeightOf(_scrollView)); var _BackBarButton = new UIBarButtonItem(); _BackBarButton.Title = string.Empty; NavigationItem.RightBarButtonItem = _BackBarButton; var _MenuBarButton = new UIBarButtonItem(); _BackBarButton.Title = "Back"; NavigationItem.LeftBarButtonItem = _BackBarButton; _labelError = new UILabel(); _labelError.TextColor = UIColor.Red; _labelError.Font = _labelError.Font.WithSize(10); _contentConteiner.AddSubview(_labelError); _textUserName = new UITextField(); _textUserName.Placeholder = "Login"; _textUserName.Layer.CornerRadius = 5; _textUserName.Layer.BorderWidth = 2; _textUserName.BorderStyle = UITextBorderStyle.RoundedRect; _textUserName.ShouldReturn = (textField) => { textField.ResignFirstResponder(); return(true); }; _contentConteiner.AddSubview(_textUserName); _textUserPassword = new UITextField(); _textUserPassword.Placeholder = "Password"; _textUserPassword.Layer.CornerRadius = 5; _textUserPassword.Layer.BorderWidth = 2; _textUserPassword.SecureTextEntry = true; _textUserPassword.BorderStyle = UITextBorderStyle.RoundedRect; _textUserPassword.ShouldReturn = (textField) => { textField.ResignFirstResponder(); return(true); }; _contentConteiner.AddSubview(_textUserPassword); _textUserPasswordRepeat = new UITextField(); _textUserPasswordRepeat.Placeholder = "Password repeat"; _textUserPasswordRepeat.Layer.CornerRadius = 5; _textUserPasswordRepeat.Layer.BorderWidth = 2; _textUserPasswordRepeat.SecureTextEntry = true; _textUserPasswordRepeat.BorderStyle = UITextBorderStyle.RoundedRect; _textUserPasswordRepeat.ShouldReturn = (textField) => { textField.ResignFirstResponder(); return(true); }; _contentConteiner.AddSubview(_textUserPasswordRepeat); _passwordPattern = new UILabel(); _passwordPattern.Text = "password must contain at least 6 characters, min 1 letter UpperCase,min 1 digit"; _passwordPattern.Font = _passwordPattern.Font.WithSize(10); _passwordPattern.LineBreakMode = UILineBreakMode.WordWrap; _passwordPattern.Lines = 0; _contentConteiner.AddSubview(_passwordPattern); _imageUserPhoto = new UIImageView(); _imageUserPhoto.Layer.CornerRadius = this._imageUserPhoto.Frame.Size.Height / 2; _imageUserPhoto.ClipsToBounds = true; _imageUserPhoto.BackgroundColor = UIColor.LightGray; _contentConteiner.AddSubview(_imageUserPhoto); _buttonPhoto = new UIButton(); _buttonPhoto.Layer.CornerRadius = this._buttonPhoto.Frame.Size.Height / 2; _buttonPhoto.ClipsToBounds = true; _buttonPhoto.BackgroundColor = UIColor.Clear; _buttonPhoto.TouchUpInside += ChoosePicture; _contentConteiner.AddSubview(_buttonPhoto); _buttonCreate = new UIButton(UIButtonType.RoundedRect); _buttonCreate.SetTitle("Create", UIControlState.Normal); _buttonCreate.Layer.CornerRadius = 5; _buttonCreate.BackgroundColor = UIColor.Blue; _buttonCreate.SetTitleColor(UIColor.White, UIControlState.Normal); _contentConteiner.AddSubview(_buttonCreate); var set = this.CreateBindingSet <RegistrationView, RegistrationViewModel>(); set.Bind(_textUserName).To(vm => vm.UserLogin); set.Bind(_labelError).To(vm => vm.Error); set.Bind(_textUserPassword).To(vm => vm.UserPassword); set.Bind(_textUserPasswordRepeat).To(vm => vm.UserPasswordRepeat); set.Bind(_buttonCreate).To(vm => vm.CreateUserCommand); set.Bind(_imageUserPhoto).For(v => v.Image).To(vm => vm.UserImage).WithConversion("ByteToUIImage"); set.Bind(_BackBarButton).To(vm => vm.BackToCommand); set.Apply(); //conastraint View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); View.AddConstraints(_scrollView.FullWidthOf(View)); View.AddConstraints(_scrollView.FullHeightOf(View)); View.AddConstraints( _contentConteiner.WithSameWidth(View), _contentConteiner.WithSameHeight(View).SetPriority(UILayoutPriority.DefaultLow) ); _contentConteiner.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); _contentConteiner.AddConstraints( _labelError.WithSameCenterX(_contentConteiner), //_labelError.WithSameWidth(_contentConteiner).Minus(100), _labelError.AtTopOf(_contentConteiner), _labelError.Height().EqualTo(13), _textUserName.AtLeftOf(_contentConteiner, 25), _textUserName.WithSameWidth(_contentConteiner).Minus(135), _textUserName.Below(_labelError, 60), _textUserPassword.AtLeftOf(_contentConteiner, 25), _textUserPassword.WithSameWidth(_contentConteiner).Minus(135), _textUserPassword.Below(_textUserName, 40), _textUserPasswordRepeat.AtLeftOf(_contentConteiner, 25), _textUserPasswordRepeat.WithSameWidth(_contentConteiner).Minus(135), _textUserPasswordRepeat.Below(_textUserPassword, 40), _imageUserPhoto.AtRightOf(_contentConteiner, 25), _imageUserPhoto.WithSameCenterY(_textUserName), _imageUserPhoto.Width().EqualTo(80), _imageUserPhoto.Height().EqualTo(80), _buttonPhoto.WithSameCenterX(_imageUserPhoto), _buttonPhoto.Width().EqualTo(80), _buttonPhoto.Height().EqualTo(80), _buttonPhoto.Below(_imageUserPhoto, -80) ); View.AddConstraints(_passwordPattern.Below(_textUserPasswordRepeat, 2)); View.AddConstraints(_passwordPattern.FullWidthOf(View, 25)); View.AddConstraints(_buttonCreate.FullWidthOf(View, 25)); View.AddConstraints(_buttonCreate.Below(_passwordPattern, 25)); View.AddConstraints(_buttonCreate.Height().LessThanOrEqualTo(35)); // very important to make scrolling work var bottomViewConstraint = _contentConteiner.Subviews.Last() .AtBottomOf(_contentConteiner).Minus(20); _contentConteiner.AddConstraints(bottomViewConstraint); //disable swipe CreateGestureRecognizer(); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.FromRGB(204, 242, 255); var border = new CALayer(); nfloat width = 2; border.BorderColor = UIColor.Black.CGColor; border.BorderWidth = width; ViewModel.Show(); _contentConteiner = new UIView(); _scrollView = new UIScrollView(); _scrollView.AddSubview(_contentConteiner); Add(_scrollView); var _BackBarButton = new UIBarButtonItem(); _BackBarButton.Title = "Back"; NavigationItem.LeftBarButtonItem = _BackBarButton; _peopleConroller = new ABPeoplePickerNavigationController(); _peopleConroller.SelectPerson2 += SelectPeople; _peopleConroller.Cancelled += delegate { this.DismissModalViewController(true); }; _labelTaskName = new UILabel(); _contentConteiner.AddSubview(_labelTaskName); _labelError = new UILabel(); _labelError.Font = _labelError.Font.WithSize(10); _labelError.TextColor = UIColor.Red; _contentConteiner.AddSubview(_labelError); _textEdit = new UITextField(); _textEdit.Placeholder = "todo..."; _textEdit.BorderStyle = UITextBorderStyle.RoundedRect; _textEdit.ShouldReturn = (textField) => { textField.ResignFirstResponder(); return(true); }; _contentConteiner.AddSubview(_textEdit); _textContactName = new UITextField(); _textContactName.Placeholder = "add contact..."; _textContactName.BorderStyle = UITextBorderStyle.RoundedRect; _textContactName.ShouldReturn = (textField) => { textField.ResignFirstResponder(); return(true); }; _contentConteiner.AddSubview(_textContactName); _textContactPhone = new UITextField(); _textContactPhone.Placeholder = "add Phone..."; _textContactPhone.KeyboardType = UIKeyboardType.NamePhonePad; _textContactPhone.ReturnKeyType = UIReturnKeyType.Done; _textContactPhone.BorderStyle = UITextBorderStyle.RoundedRect; _textContactPhone.ShouldReturn = (textField) => { textField.ResignFirstResponder(); return(true); }; _contentConteiner.AddSubview(_textContactPhone); _buttonSelectContact = new UIButton(); _buttonSelectContact.BackgroundColor = UIColor.Blue; _buttonSelectContact.SetTitle("Add", UIControlState.Normal); _buttonSelectContact.Layer.CornerRadius = 5; _buttonSelectContact.Layer.BorderWidth = 1; _buttonSelectContact.TouchUpInside += delegate { PresentModalViewController(_peopleConroller, true); }; _contentConteiner.AddSubview(_buttonSelectContact); _buttonCall = new UIButton(); _buttonCall.BackgroundColor = UIColor.Blue; _buttonCall.SetTitle("Call", UIControlState.Normal); _buttonCall.Layer.CornerRadius = 5; _buttonCall.Layer.BorderWidth = 1; _contentConteiner.AddSubview(_buttonCall); _swith = new UISwitch(); _swith.On = true; _contentConteiner.AddSubview(_swith); _buttonSave = new UIButton(UIButtonType.Custom); _buttonSave.BackgroundColor = UIColor.Blue; _buttonSave.Layer.CornerRadius = 5; _buttonSave.Layer.BorderWidth = 1; _buttonSave.SetTitle("Save", UIControlState.Normal); _contentConteiner.AddSubview(_buttonSave); _buttonDelete = new UIButton(UIButtonType.Custom); _buttonDelete.Layer.CornerRadius = 5; _buttonDelete.Layer.BorderWidth = 1; _buttonDelete.BackgroundColor = UIColor.Blue; _buttonDelete.SetTitle("Delete", UIControlState.Normal); _buttonDelete.TitleColor(UIControlState.Selected); _contentConteiner.AddSubview(_buttonDelete); var set = this.CreateBindingSet <ItemView, ItemViewModel>(); set.Bind(_BackBarButton).To(vm => vm.BackToCommand); set.Bind(_labelTaskName).To(vm => vm.TaskName); set.Bind(_textEdit).To(vm => vm.TaskContent); set.Bind(_swith).To(vm => vm.TaskDone); set.Bind(_buttonSave).To(vm => vm.SaveItem); set.Bind(_buttonDelete).To(vm => vm.DeleteItem); set.Bind(_textContactName).To(vm => vm.ContactName); set.Bind(_textContactPhone).To(vm => vm.ContactPhone); set.Bind(_buttonCall).To(vm => vm.PhoneCallCommand); set.Bind(_labelError).To(vm => vm.Error); set.Apply(); //conastraint _scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); _scrollView.AddConstraints(_contentConteiner.FullWidthOf(_scrollView)); _scrollView.AddConstraints(_contentConteiner.FullHeightOf(_scrollView)); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); View.AddConstraints(_scrollView.FullWidthOf(View)); View.AddConstraints(_scrollView.FullHeightOf(View)); View.AddConstraints( _contentConteiner.WithSameWidth(View), _contentConteiner.WithSameHeight(View).SetPriority(UILayoutPriority.DefaultLow) ); _contentConteiner.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); _contentConteiner.AddConstraints( _labelError.AtTopOf(_contentConteiner), _labelError.WithSameWidth(_contentConteiner), _labelError.WithSameCenterX(_contentConteiner), _labelError.Height().EqualTo(20), _labelTaskName.WithSameCenterX(_contentConteiner), _labelTaskName.Below(_labelError, 25), _labelTaskName.WithSameWidth(_contentConteiner).Minus(130), _labelTaskName.Height().LessThanOrEqualTo(60), _textEdit.WithSameCenterX(_contentConteiner), _textEdit.Below(_labelTaskName, 20), _textEdit.WithSameWidth(_contentConteiner).Minus(25), _textEdit.Height().LessThanOrEqualTo(60), _textContactName.AtLeftOf(_contentConteiner, 25), _textContactName.Below(_textEdit, 20), _textContactName.WithSameWidth(_contentConteiner).Minus(130), _textContactName.Height().EqualTo(40), _textContactPhone.AtLeftOf(_contentConteiner, 25), _textContactPhone.Below(_textContactName, 20), _textContactPhone.WithSameWidth(_contentConteiner).Minus(130), _textContactPhone.Height().EqualTo(40), _buttonSelectContact.ToRightOf(_textContactName, 20), _buttonSelectContact.WithSameCenterY(_textContactName), _buttonSelectContact.Width().EqualTo(80), _swith.AtLeftOf(_contentConteiner, 25), _swith.Below(_textContactPhone, 20), _buttonCall.WithSameCenterY(_textContactPhone), _buttonCall.ToRightOf(_textContactPhone, 20), _buttonCall.Width().EqualTo(80), _buttonSave.AtLeftOf(_contentConteiner, 25), _buttonSave.Below(_swith, 40), _buttonSave.Width().EqualTo(80), _buttonSave.Height().LessThanOrEqualTo(35), _buttonDelete.WithSameCenterX(_buttonCall), _buttonDelete.Below(_swith, 40), _buttonDelete.Width().EqualTo(80), _buttonDelete.Height().LessThanOrEqualTo(35) ); // very important to make scrolling work var bottomViewConstraint = _contentConteiner.Subviews.Last() .AtBottomOf(_contentConteiner).Minus(20); _contentConteiner.AddConstraints(bottomViewConstraint); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.FromRGB(77, 210, 255); //save user _filePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ToDoUser.txt"); File.WriteAllText(_filePath, $"{SignViewModel.UserCurrent.UserLogin}`" + $"{SignViewModel.UserCurrent.UserPassword}"); _contentConteiner = new UIView(); _scrollView = new UIScrollView(); _scrollView.AddSubview(_contentConteiner); Add(_scrollView); _titleView = new UIView(); _titleView.BackgroundColor = UIColor.FromRGB(245, 245, 239); _titleView.Layer.CornerRadius = 10; _contentConteiner.AddSubview(_titleView); _userImage = new UIImageView(); _userImage.BackgroundColor = UIColor.LightGray; _contentConteiner.AddSubview(_userImage); _imageButton = new UIButton(); _imageButton.BackgroundColor = UIColor.Clear; _imageButton.TouchUpInside += ChoosePicture; _contentConteiner.AddSubview(_imageButton); _userLogin = new UILabel(); _contentConteiner.AddSubview(_userLogin); _home = new UIButton(); _home.SetTitle("Task List", UIControlState.Normal); _home.SetTitleColor(UIColor.Black, UIControlState.Normal); _home.TitleLabel.ShadowOffset = new CGSize(width: 0, height: 0.1); _home.TitleLabel.Layer.ShadowOpacity = 1; _home.TitleLabel.Layer.ShadowRadius = 8; _home.TitleLabel.Layer.MasksToBounds = false; _home.SetImage(UIImage.FromFile("Image/todoIOS.png"), UIControlState.Normal); _home.TouchUpInside += delegate { File.Delete(_filePath); ViewModel.GoHome(); Mvx.Resolve <IMvxSideMenu>().Close(); }; _contentConteiner.AddSubview(_home); _logOff = new UIButton(); _logOff.SetTitle("LogOff", UIControlState.Normal); _logOff.SetTitleColor(UIColor.Black, UIControlState.Normal); _logOff.TitleLabel.ShadowOffset = new CGSize(width: 0, height: 0.1); _logOff.TitleLabel.Layer.ShadowOpacity = 1; _logOff.TitleLabel.Layer.ShadowRadius = 8; _logOff.TitleLabel.Layer.MasksToBounds = false; _logOff.SetImage(UIImage.FromFile("Image/logoffIOS.png"), UIControlState.Normal); _logOff.TouchUpInside += delegate { File.Delete(_filePath); ViewModel.DoLogOff(); Mvx.Resolve <IMvxSideMenu>().Close(); }; _contentConteiner.AddSubview(_logOff); var set = this.CreateBindingSet <LeftPanelView, LeftPanelViewModel>(); set.Bind(_userImage).For(v => v.Image).To(vm => vm.UserImage).WithConversion("ByteToUIImage"); set.Bind(_userLogin).To(vm => vm.UserLogin); set.Apply(); //conastraint _scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); _scrollView.AddConstraints(_contentConteiner.FullWidthOf(_scrollView)); _scrollView.AddConstraints(_contentConteiner.FullHeightOf(_scrollView)); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); View.AddConstraints(_scrollView.FullWidthOf(View)); View.AddConstraints(_scrollView.FullHeightOf(View)); View.AddConstraints( _contentConteiner.WithSameWidth(View), _contentConteiner.WithSameHeight(View).SetPriority(UILayoutPriority.DefaultLow) ); _contentConteiner.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); _contentConteiner.AddConstraints( _titleView.WithSameCenterX(_contentConteiner), _titleView.AtTopOf(_contentConteiner).Plus(20), _titleView.Height().EqualTo(250), _titleView.WithSameWidth(_contentConteiner).Minus(10), _userImage.WithSameCenterX(_titleView), _userImage.WithSameCenterY(_titleView), _userImage.Height().EqualTo(120), _userImage.Width().EqualTo(120), _imageButton.Height().EqualTo(120), _imageButton.Width().EqualTo(120), _imageButton.WithSameCenterX(_userImage), _imageButton.WithSameCenterY(_userImage), _userLogin.Below(_userImage, 10), _userLogin.WithSameCenterX(_userImage), _home.Below(_userLogin, 50), _home.AtLeftOf(_contentConteiner, 5), _logOff.Below(_home, 5), _logOff.AtLeftOf(_contentConteiner, 5) ); // very important to make scrolling work var bottomViewConstraint = _contentConteiner.Subviews.Last() .AtBottomOf(_contentConteiner).Minus(20); _contentConteiner.AddConstraints(bottomViewConstraint); }