コード例 #1
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        /// <returns>The did load.</returns>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            UIBarButtonItem backButton = new UIBarButtonItem("< Back", UIBarButtonItemStyle.Bordered, HandleSignout);

            NavigationItem.SetLeftBarButtonItem(backButton, false);

            View.BackgroundColor = UIColor.White;

            _presenter.SetView(this);

            var width  = View.Bounds.Width;
            var height = View.Bounds.Height;

            Title = "Clients";

            var titleLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text          = "Connected Clients",
                Font          = UIFont.FromName("Helvetica-Bold", 22),
                TextAlignment = UITextAlignment.Center
            };

            var descriptionLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text          = "Select a client you would like to chat with",
                Font          = UIFont.FromName("Helvetica", 18),
                TextAlignment = UITextAlignment.Center
            };

            _tableView = new UITableView(new CGRect(0, 0, width, height))
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _tableView.AutoresizingMask = UIViewAutoresizing.All;
            _tableView.Source           = _source;

            Add(titleLabel);
            Add(descriptionLabel);
            Add(_tableView);

            var views = new DictionaryViews()
            {
                { "titleLabel", titleLabel },
                { "descriptionLabel", descriptionLabel },
                { "tableView", _tableView },
            };

            View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-100-[titleLabel(30)]-[descriptionLabel(30)]-[tableView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[tableView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[titleLabel]-10-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[descriptionLabel]-10-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.iOS.Controls.LocationView"/> class.
        /// </summary>
        public LocationView()
        {
            _locationTargetImageView = new UIImageView(new CGRect(0, 0, IMG_TARGET_BOUND, IMG_TARGET_BOUND))
            {
                ContentMode = UIViewContentMode.ScaleAspectFill,
                Image       = UIImage.FromFile("location_target.png"),
                Alpha       = 0.0f
            };

            _locationPlaceholderImageView = new UIImageView(new CGRect(0, 0, 200, IMG_TARGET_BOUND))
            {
                ContentMode = UIViewContentMode.ScaleAspectFill,
                Image       = UIImage.FromFile("location_placeholder.png"),
                Alpha       = 0.0f
            };

            _locationPlaceholderLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.FromName("Helvetica", 14f),
                TextColor = iOSColorPalette.Maroon,
                Alpha     = 0.0f
            };

            var topImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFill,
                Image       = UIImage.FromFile("bg-top.jpg"),
            };

            var mapImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFill,
                Image       = UIImage.FromFile("map.png"),
            };

            Add(topImageView);
            Add(mapImageView);
            Add(_locationTargetImageView);
            Add(_locationPlaceholderImageView);
            Add(_locationPlaceholderLabel);

            var views = new DictionaryViews()
            {
                { "topImageView", topImageView },
                { "mapImageView", mapImageView },
            };

            AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[topImageView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                           .Concat(NSLayoutConstraint.FromVisualFormat("V:|[mapImageView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                           .Concat(NSLayoutConstraint.FromVisualFormat("H:|[topImageView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                           .Concat(NSLayoutConstraint.FromVisualFormat("H:|[mapImageView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                           .ToArray());
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:MatchDayManagement.iOS.InjurySearchResultTableViewCell"/> class.
        /// </summary>
        /// <param name="handle">Handle.</param>
        protected ContactTableViewCell(IntPtr handle) : base(handle)
        {
            _titleLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.FromName("Helvetica", 16f),
                TextColor = UIColor.Clear.FromHex("#444444"),
            };

            _iconImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
            };

            _leftView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear.FromHex("#ca505d")
            };

            var views = new DictionaryViews()
            {
                { "titleLabel", _titleLabel },
                { "iconImageView", _iconImageView },
            };

            ContentView.Add(_titleLabel);
            ContentView.Add(_iconImageView);

            ContentView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-5-[titleLabel]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-10-[iconImageView]-10-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-18-[iconImageView(20)]-5-[titleLabel]-15-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            // selected view
            SelectedBackgroundView = new UIView(ContentView.Bounds)
            {
                BackgroundColor = UIColor.Clear.FromHex("#fefafa"),
            };

            SelectedBackgroundView.Add(_leftView);

            var selectedViews = new DictionaryViews()
            {
                { "leftView", _leftView }
            };

            SelectedBackgroundView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[leftView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, selectedViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[leftView(3)]", NSLayoutFormatOptions.AlignAllTop, null, selectedViews))
                .ToArray());
        }
コード例 #4
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            base.StyleNavigationBar();

            _tilesCollectionView = new UICollectionView(new CGRect(), new TetrixLayout())
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.White
            };
            _tilesCollectionView.RegisterClassForCell(typeof(TileCollectionViewCell), TileCollectionViewCell.Key);

            _tilesSource = new TetrixCollectionSource(_tilesCollectionView, TileCollectionViewCell.Key,
                                                      (item, collectionView, indexPath) =>
            {
                var cell = default(BaseCollectionViewCell);

                TypeSwitch.On(item)
                .Case((TileViewModel x) => cell = (BaseCollectionViewCell)collectionView.DequeueReusableCell(TileCollectionViewCell.Key, indexPath));

                //cell.DataContext = item;

                return(cell);
            });
            _tilesCollectionView.Source = _tilesSource;

            Add(_tilesCollectionView);

            var views = new DictionaryViews()
            {
                { "tilesCollectionView", _tilesCollectionView }
            };

            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-20-[tilesCollectionView]-20-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-20-[tilesCollectionView]-20-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                .ToArray());

            this.WhenActivated(d =>
            {
                // We need to bind the ViewModel property to the DataContext in order to be able to
                // use WPF Bindings. Let's use WPF bindings for the UserName property.
                //this.Bind(ViewModel, vm => vm.Cells, v => v._tilesSource.ItemsSource);

                //set.Bind(_tilesSource).For(s => s.ItemsSource).To(vm => vm.Cells);
                //set.Bind(_tilesSource).For(cv => cv.SelectionChangedCommand)
                //   .To(vm => vm.SelectCommand);

                //OnAppear(new Dictionary<string, object>());
            });
        }
コード例 #5
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        /// <returns>The did load.</returns>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Chat Room";

            _presenter.SetView(this);

            View.BackgroundColor = UIColor.White;

            _width = View.Bounds.Width;

            var _sendButton = new UIButton(UIButtonType.RoundedRect)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _sendButton.SetTitle("Send", UIControlState.Normal);
            _sendButton.TouchUpInside += HandleSendButton;

            _chatField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear.FromHex("#DFE4E6"),
                Placeholder     = "Enter message"
            };

            _scrollView = new UIScrollView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            Add(_chatField);
            Add(_sendButton);
            Add(_scrollView);

            var views = new DictionaryViews()
            {
                { "sendButton", _sendButton },
                { "chatField", _chatField },
                { "scrollView", _scrollView },
            };

            this.View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-68-[chatField(60)]", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-62-[sendButton(60)]-20-[scrollView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[chatField]-[sendButton(60)]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[scrollView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:MatchDayManagement.iOS.InjurySearchResultTableViewCell"/> class.
        /// </summary>
        /// <param name="handle">Handle.</param>
        protected FeedbackListItemTableViewCell(IntPtr handle) : base(handle)
        {
            _nameLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font = UIFont.FromName("Helvetica", 18f),
            };

            _addressLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font = UIFont.FromName("Helvetica", 14f),
            };

            _distanceLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font = UIFont.FromName("Helvetica", 14f),
            };

            _arrowImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
            };

            var views = new DictionaryViews()
            {
                { "nameLabel", _nameLabel },
                { "addressLabel", _addressLabel },
                { "distanceLabel", _distanceLabel },
                { "arrowImageView", _arrowImageView }
            };

            ContentView.Add(_nameLabel);
            ContentView.Add(_addressLabel);
            ContentView.Add(_distanceLabel);
            ContentView.Add(_arrowImageView);

            ContentView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-5-[nameLabel]-[addressLabel]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-5-[arrowImageView(25)]-[distanceLabel]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[nameLabel]-10-[arrowImageView(25)]-10-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[addressLabel]-10-[distanceLabel(40)]-10-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());
        }
コード例 #7
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _serialDisposable = new SerialDisposable();

            this.StyleNavigationBar();

            Title = "Results";

            _searchResultsTableView = new UITableView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            _progressView = new UIActivityIndicatorView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Color = UIColor.White,
            };

            Add(_searchResultsTableView);
            Add(_progressView);

            var views = new DictionaryViews()
            {
                { "searchResultsTableView", _searchResultsTableView },
                { "progressView", _progressView },
            };

            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[searchResultsTableView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[progressView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[searchResultsTableView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[progressView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                .ToArray());

            this.Bind(ViewModel, x => x.IsLoading, x => x._searchResultsTableView.Hidden);

            this.WhenActivated(d =>
            {
                // HACK: Clean this up with proper navigation
                ViewModel.OnShow(new Dictionary <string, object>());
            });
        }
コード例 #8
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _serialDisposable = new SerialDisposable();

            //this.StyleNavigationBar();

            Title = "Menu";

            _searchResultsTableView = new UITableView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            Add(_searchResultsTableView);

            var views = new DictionaryViews()
            {
                { "searchResultsTableView", _searchResultsTableView },
            };

            View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[searchResultsTableView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[searchResultsTableView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            this.WhenActivated(d =>
            {
                ViewModel.WhenAnyValue(vm => vm.Results).BindTo <EReactiveUIAroundMeListItemViewModel,
                                                                 EReactiveUIAroundMeListItemTableViewCell>(_searchResultsTableView, 80, cell => cell.Initialize());

                this.WhenAnyValue(v => v._tableSource.ElementSelected)
                .Subscribe(x =>
                {
                    // when ever this value is updated we want to make sure we only ever have
                    // the latest subscription
                    _serialDisposable.Disposable = x.Subscribe(vm => ViewModel.SelectAsync());
                });

                // HACK: Clean this up with proper navigation
                ViewModel.OnShow(new Dictionary <string, object>());
            });
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Chat.iOS.Views.ChatBoxView"/> class.
        /// </summary>
        /// <param name="message">Message.</param>
        public ChatBoxView(string message)
        {
            Layer.CornerRadius = 10;

            messageLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text = message
            };

            Add(messageLabel);

            var views = new DictionaryViews()
            {
                { "messageLabel", messageLabel },
            };

            AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[messageLabel]|", NSLayoutFormatOptions.AlignAllTop, null, views)
                           .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[messageLabel]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                           .ToArray());
        }
コード例 #10
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //base.StyleNavigationBar();

            View.BackgroundColor = UIColor.White;

            Title = "Login";

            var mainView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            Add(mainView);

            _usernameTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder = "Username",
            };

            _passwordTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder     = "Password",
                SecureTextEntry = true,
            };

            var errorLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Font          = UIFont.FromName("Helvetica", 20f),
                TextColor     = iOSColorPalette.Red,
            };

            _loginButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font            = UIFont.FromName("Alfa Slab One", 20f),
                BackgroundColor = iOSColorPalette.Blue
            };
            _loginButton.SetTitle("Login", UIControlState.Normal);
            _loginButton.SetTitleColor(UIColor.White, UIControlState.Normal);

            var activityIndicatorView = new CustomIndicatorView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Color  = UIColor.Black,
                Hidden = true,
            };

            mainView.Add(_usernameTextField);
            mainView.Add(_passwordTextField);
            mainView.Add(errorLabel);
            mainView.Add(_loginButton);
            mainView.Add(activityIndicatorView);

            var views = new DictionaryViews()
            {
                { "mainView", mainView },
            };

            var mainViews = new DictionaryViews()
            {
                { "usernameTextField", _usernameTextField },
                { "passwordTextField", _passwordTextField },
                { "errorLabel", errorLabel },
                { "loginButton", _loginButton },
                { "activityIndicatorView", activityIndicatorView }
            };

            View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[mainView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[mainView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            mainView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-140-[usernameTextField]-40-[passwordTextField]-40-[loginButton]-40-[errorLabel]-40-[activityIndicatorView(60)]", NSLayoutFormatOptions.DirectionLeftToRight, null, mainViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[usernameTextField(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[passwordTextField(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[loginButton(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[errorLabel(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[activityIndicatorView(60)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(new[] { NSLayoutConstraint.Create(_usernameTextField, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(_passwordTextField, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(_loginButton, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(errorLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(activityIndicatorView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .ToArray());

            // create the binding set
            //var set = this.CreateBindingSet<LoginPage, LoginPageViewModel>();
            //set.Bind(usernameTextField).To(vm => vm.Username);
            //set.Bind(passwordTextField).To(vm => vm.Password);
            //set.Bind(_loginButton).To(vm => vm.LoginCommand);
            //set.Bind(errorLabel).To(vm => vm.ErrorMessage);
            //set.Bind(errorLabel).For("Hidden").To(vm => vm.IsError).WithConversion("NotValueConverter", false);
            //set.Bind(activityIndicatorView).For("IsRunning").To(vm => vm.IsLoading);
            //set.Apply();

            this.WhenActivated(d =>
            {
                this.Bind(ViewModel, x => x.Username, x => x._usernameTextField.Text);
                this.Bind(ViewModel, x => x.Password, x => x._passwordTextField.Text);

                this.BindCommand(ViewModel, x => x.LoginCommand, x => x._loginButton);
            });
        }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.iOS.AddUmpireAlertView"/> class.
        /// </summary>
        public AddUmpireAlertView()
        {
            Layer.BorderWidth = 1;
            Layer.BorderColor = iOSColorPalette.GradientStroke3.CGColor;

            BackgroundColor = UIColor.White;

            var topView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            CreateViewGradient(topView);

            var cancelButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            cancelButton.SetTitle("Cancel", UIControlState.Normal);
            cancelButton.SetTitleColor(iOSColorPalette.Red, UIControlState.Normal);

            var saveButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            saveButton.SetTitle("Save", UIControlState.Normal);
            saveButton.SetTitleColor(iOSColorPalette.Red, UIControlState.Normal);

            var retireButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = iOSColorPalette.Red
            };

            retireButton.SetTitle("Retire", UIControlState.Normal);
            retireButton.SetTitleColor(UIColor.White, UIControlState.Normal);

            var titleLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Font          = UIFont.FromName("Helvetica", 16f),
                Text          = "Edit",
            };

            var firstNameTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder = "First Name"
            };

            var surnameTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder = "Surname"
            };

            topView.Add(saveButton);
            topView.Add(titleLabel);
            topView.Add(cancelButton);

            Add(topView);
            Add(retireButton);
            Add(firstNameTextField);
            Add(surnameTextField);

            var topViews = new DictionaryViews()
            {
                { "cancelButton", cancelButton },
                { "saveButton", saveButton },
                { "titleLabel", titleLabel },
            };

            var views = new DictionaryViews()
            {
                { "topView", topView },
                { "retireButton", retireButton },
                { "firstNameTextField", firstNameTextField },
                { "surnameTextField", surnameTextField },
            };

            topView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("H:|-5-[cancelButton]-2-[titleLabel(cancelButton)]-2-[saveButton(cancelButton)]-5-|", NSLayoutFormatOptions.AlignAllTop, null, topViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[cancelButton]|", NSLayoutFormatOptions.DirectionLeftToRight, null, topViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[titleLabel]|", NSLayoutFormatOptions.DirectionLeftToRight, null, topViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[saveButton]|", NSLayoutFormatOptions.DirectionLeftToRight, null, topViews))
                .ToArray());

            AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[topView(40)]-[firstNameTextField][surnameTextField][retireButton(35)]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[topView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[firstNameTextField]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[surnameTextField]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[retireButton]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            // create the binding set
            //var set = this.CreateBindingSet<AddUmpireAlertView, UmpireViewModel>();
            //set.Bind(firstNameTextField).To(vm => vm.FirstName);
            //set.Bind(surnameTextField).To(vm => vm.Surname);
            //set.Bind(cancelButton).To(vm => vm.CancelCommand);
            //set.Bind(saveButton).To(vm => vm.SaveCommand);
            //set.Bind(retireButton).To(vm => vm.RetireCommand);

            //set.Apply();
        }
コード例 #12
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var mainView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.White
            };

            var buttonView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear
            };

            var imageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
                Image       = new UIImage("moby.png")
            };

            var descriptionLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center
            };

            var currentLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Left,
            };

            var endLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Right,
            };

            progressSlider = new UISlider()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                MinValue = 0
            };

            progressSlider.ValueChanged += progressSliderValueChanged;

            playButton = new UIButton(UIButtonType.Custom)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };
            playButton.TouchUpInside += handlePlayButton;
            playButton.SetImage(UIImage.FromFile("play.png"), UIControlState.Normal);

            var rewindButton = new UIButton(UIButtonType.Custom)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            rewindButton.TouchUpInside += handleRewindForwardButton;
            rewindButton.SetImage(UIImage.FromFile("rewind.png"), UIControlState.Normal);

            var fastForwardButton = new UIButton(UIButtonType.Custom)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            fastForwardButton.TouchUpInside += handleRewindForwardButton;
            fastForwardButton.SetImage(UIImage.FromFile("fast_forward.png"), UIControlState.Normal);

            var views = new DictionaryViews()
            {
                { "mainView", mainView },
                { "buttonView", buttonView },
                { "imageView", imageView },
                { "descriptionLabel", descriptionLabel },
                { "currentLabel", currentLabel },
                { "endLabel", endLabel },
                { "progressSlider", progressSlider },
                { "playButton", playButton },
                { "rewindButton", rewindButton },
                { "fastForwardButton", fastForwardButton }
            };

            View.Add(mainView);

            mainView.Add(imageView);
            mainView.Add(descriptionLabel);
            mainView.Add(buttonView);
            mainView.Add(currentLabel);
            mainView.Add(endLabel);
            mainView.Add(progressSlider);

            buttonView.Add(playButton);
            buttonView.Add(rewindButton);
            buttonView.Add(fastForwardButton);

            View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[mainView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[mainView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            mainView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-100-[imageView(200)]-[descriptionLabel(30)]-[buttonView(50)]-[currentLabel(30)]-[progressSlider]", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-100-[imageView(200)]-[descriptionLabel(30)]-[buttonView(50)]-[endLabel(30)]-[progressSlider]", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-20-[progressSlider]-20-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-25-[currentLabel(100)]", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[endLabel(100)]-25-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[descriptionLabel]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[imageView]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(new[] { NSLayoutConstraint.Create(buttonView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1, 0) })
                .ToArray());

            buttonView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-5-[rewindButton]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-5-[playButton]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-5-[fastForwardButton]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-20-[rewindButton]-[playButton(100)]-[fastForwardButton]-20-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            // create the binding set
            var set = this.CreateBindingSet <AudioPlayerPage, AudioPlayerPageViewModel>();

            set.Bind(this).For("Title").To(vm => vm.Title);
            set.Bind(descriptionLabel).To(vm => vm.DescriptionMessage);
            set.Bind(currentLabel).To(vm => vm.CurrentTimeStr);
            set.Bind(endLabel).To(vm => vm.EndTimeStr);
            set.Bind(progressSlider).For(v => v.Value).To(vm => vm.CurrentTime).TwoWay().Apply();
            set.Bind(progressSlider).For(v => v.MaxValue).To(vm => vm.EndTime);
            set.Bind(playButton).To(vm => vm.PlayPauseCommand);
            set.Bind(rewindButton).To(vm => vm.RewindCommand);
            set.Bind(fastForwardButton).To(vm => vm.ForwardCommand);
            set.Apply();

            model = (AudioPlayerPageViewModel)DataContext;
        }
コード例 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.iOS.TileCollectionViewCell"/> class.
        /// </summary>
        /// <param name="handle">Handle.</param>
        protected TileCollectionViewCell(IntPtr handle) : base(handle)
        {
            ContentView.Layer.BorderWidth = 1;
            ContentView.Layer.BorderColor = iOSColorPalette.GradientStroke3.CGColor;

            AllowSelectedStyle = false;

            _bannerImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleToFill,
            };

            _tileImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
                Image       = UIImage.FromFile("profile_image.jpeg"),
            };
            _tileImageView.Layer.CornerRadius  = 22.5f;
            _tileImageView.Layer.MasksToBounds = true;

            var stateLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font          = UIFont.FromName("Helvetica", 12f),
                TextAlignment = UITextAlignment.Right,
                TextColor     = iOSColorPalette.Red
            };

            var firstNameLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.FromName("Helvetica", 16f),
                TextColor = iOSColorPalette.DarkGray1
            };

            var lastNameLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.FromName("Helvetica", 20f),
                TextColor = iOSColorPalette.DarkGray1
            };

            var titleGradientView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            var titleLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font                   = UIFont.FromName("Helvetica", 20f),
                TextAlignment          = UITextAlignment.Center,
                UserInteractionEnabled = false,
            };

            CreateViewGradient(titleGradientView, 50);

            var views = new DictionaryViews()
            {
                { "stateLabel", stateLabel },
                { "firstNameLabel", firstNameLabel },
                { "lastNameLabel", lastNameLabel },
                { "tileImageView", _tileImageView },
                { "bannerImageView", _bannerImageView },
                { "titleLabel", titleLabel },
                { "titleGradientView", titleGradientView },
            };

            ContentView.Add(stateLabel);
            ContentView.Add(firstNameLabel);
            ContentView.Add(lastNameLabel);
            ContentView.Add(_bannerImageView);
            //ContentView.Add(_tileImageView);
            ContentView.Add(titleGradientView);
            ContentView.Add(titleLabel);

            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[bannerImageView(70)]-2-[stateLabel(20)]-5-[firstNameLabel(25)][lastNameLabel(35)]-5-[titleLabel(50)]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                                       .Concat(NSLayoutConstraint.FromVisualFormat("V:|[bannerImageView(70)]-2-[stateLabel(20)]-5-[firstNameLabel(25)][lastNameLabel(35)]-5-[titleGradientView(50)]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                                       //.Concat(NSLayoutConstraint.FromVisualFormat("V:|-45-[tileImageView(45)]", NSLayoutFormatOptions.AlignAllTop, null, views))
                                       .Concat(NSLayoutConstraint.FromVisualFormat("H:|[bannerImageView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                       //.Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[tileImageView(45)]", NSLayoutFormatOptions.AlignAllTop, null, views))
                                       .Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[firstNameLabel]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                       .Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[lastNameLabel]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                       .Concat(NSLayoutConstraint.FromVisualFormat("H:|[stateLabel]-10-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                       .Concat(NSLayoutConstraint.FromVisualFormat("H:|[titleLabel]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                                       .Concat(NSLayoutConstraint.FromVisualFormat("H:|[titleGradientView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                                       .ToArray());

            this.WhenAny(x => x.ViewModel, x => x.Value)
            .Where(x => x != null)
            .Subscribe(x =>
            {
                titleLabel.Text = x.Title;
                //set.Bind(_bannerImageViewLoader).For(i => i.DefaultImagePath)
                //	.To(vm => vm.BannerImage);
            });
        }
コード例 #14
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.StyleNavigationBar();
            this.NavigationController.SetNavigationBarHidden(false, true);

            _mapView = new MKMapView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                OverlayRenderer = (mapView, overlay) =>
                {
                    if (overlay is MKPolyline)
                    {
                        var route    = (MKPolyline)overlay;
                        var renderer = new MKPolylineRenderer(route)
                        {
                            StrokeColor = UIColor.Blue, Alpha = 0.5f
                        };

                        return(renderer);
                    }

                    return(null);
                }
            };

            /* -- directions panel view -- */

            var directionView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            var directionTopView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.White
            };

            var directionBottomView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.White
            };

            directionView.Add(directionTopView);
            directionView.Add(directionBottomView);

            var directionViews = new DictionaryViews()
            {
                { "directionTopView", directionTopView },
                { "directionBottomView", directionBottomView },
            };

            directionView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[directionTopView(40)][directionBottomView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[directionTopView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[directionBottomView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionViews))
                .ToArray());

            /* -- directions top view -- */

            var directionTopViews = new DictionaryViews();

            _buttons = new List <UIButton>();

            for (int i = 0; i < _buttonTitles.Length; i++)
            {
                var button = new UIButton(UIButtonType.Custom)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                };

                // all images except car and direction buttons are active
                button.SetImage(UIImage.FromFile(i == 0 || i == 3 ? _buttonActiveImagePaths[i] :
                                                 _buttonNonActiveImagePaths[i]), UIControlState.Normal);

                button.TintColor = UIColor.Clear.FromHex("#c14d60");

                directionTopViews.Add(_buttonTitles[i].ToLower() + "Button", button);
                directionTopView.Add(button);
                _buttons.Add(button);
            }

            // share and feedback button will highlight when touched rather than change to active
            _buttons[4].SetImage(UIImage.FromFile(_buttonActiveImagePaths[4]), UIControlState.Highlighted);
            _buttons[5].SetImage(UIImage.FromFile(_buttonActiveImagePaths[5]), UIControlState.Highlighted);

            // all gps buttons
            for (int i = 1; i < 4; i++)
            {
                _buttons[i].Tag = i;
                // each button when touched will reset other gps buttons to non active
                // and set self to active
                _buttons[i].TouchUpInside += (sender, e) =>
                {
                    var button = (sender as UIButton);
                    var index  = button.Tag;

                    // all gps buttons reset
                    for (int j = 1; j < 4; j++)
                    {
                        if (j != index)
                        {
                            _buttons[j].SetImage(UIImage.FromFile(_buttonNonActiveImagePaths[j]), UIControlState.Normal);
                        }
                    }

                    button.SetImage(UIImage.FromFile(_buttonActiveImagePaths[index]), UIControlState.Normal);
                    gpsDirectionSelection = index;
                };
            }

            // direction button
            _buttons[0].TouchUpInside += (sender, e) =>
            {
                _directionsShowing         = !_directionsShowing;
                directionBottomView.Hidden = !_directionsShowing;
                _buttons[0].SetImage(UIImage.FromFile(_directionsShowing ? _buttonActiveImagePaths[0] :
                                                      _buttonNonActiveImagePaths[0]), UIControlState.Normal);
            };

            var directionTopVerticalSeperator = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear.FromHex("#dddddd")
            };

            var directionTopHorizontalSeperator = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear.FromHex("#dddddd")
            };

            directionTopViews.Add("directionTopVerticalSeperator", directionTopVerticalSeperator);
            directionTopViews.Add("directionTopHorizontalSeperator", directionTopHorizontalSeperator);

            directionTopView.Add(directionTopVerticalSeperator);
            directionTopView.Add(directionTopHorizontalSeperator);

            directionTopView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[directionButton]|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionTopViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-7-[carButton]-10-|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionTopViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-7-[busButton]-10-|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionTopViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-7-[walkButton]-10-|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionTopViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-7-[favouriteButton]-10-|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionTopViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-7-[shareButton]-10-|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionTopViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-10-[directionTopVerticalSeperator]-10-|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionTopViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:[directionTopHorizontalSeperator(1)]|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionTopViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[directionButton(30)]-15-[carButton(23)]-15-[busButton(carButton)]-15-[walkButton(carButton)]-15-[directionTopVerticalSeperator(1)]", NSLayoutFormatOptions.AlignAllTop, null, directionTopViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[favouriteButton(25)]-15-[shareButton(22)]-15-|", NSLayoutFormatOptions.AlignAllTop, null, directionTopViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[directionTopHorizontalSeperator]|", NSLayoutFormatOptions.AlignAllTop, null, directionTopViews))
                .ToArray());

            /* -- directions top view -- */

            /* -- directions bottom view -- */

            _currentAddressTextField = new UnderlinedUITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text = "Address",
                Font = UIFont.FromName("Arial", 12f),
            };

            _destinationLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font = UIFont.FromName("Arial", 12f),
                Text = "Address",
            };

            var directionImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
                Image       = UIImage.FromFile("direction-sign.png")
            };

            directionBottomView.Add(_currentAddressTextField);
            directionBottomView.Add(_destinationLabel);
            directionBottomView.Add(directionImageView);

            var directionBottomViews = new DictionaryViews()
            {
                { "currentAddressTextField", _currentAddressTextField },
                { "destinationLabel", _destinationLabel },
                { "directionImageView", directionImageView },
            };

            directionBottomView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-5-[currentAddressTextField]-5-[destinationLabel(currentAddressTextField)]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionBottomViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-5-[directionImageView]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, directionBottomViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[directionImageView(10)]-5-[currentAddressTextField]-5-|", NSLayoutFormatOptions.AlignAllTop, null, directionBottomViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-20-[destinationLabel]-5-|", NSLayoutFormatOptions.AlignAllTop, null, directionBottomViews))
                .ToArray());

            /* -- directions bottom view -- */

            /* -- directions panel view -- */

            var infoView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            _progressView = new UIActivityIndicatorView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Color = UIColor.White,
            };

            Add(_mapView);
            Add(_progressView);
            Add(directionView);
            Add(infoView);

            var views = new DictionaryViews()
            {
                { "mapView", _mapView },
                { "progressView", _progressView },
                { "infoView", infoView },
                { "directionView", directionView },
            };

            var coords = new CLLocationCoordinate2D(48.857, 2.351);
            var span   = new MKCoordinateSpan(MilesToLatitudeDegrees(20), MilesToLongitudeDegrees(20, coords.Latitude));

            _mapView.Region = new MKCoordinateRegion(coords, span);

            var segmentControl = new UISegmentedControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            segmentControl.Layer.CornerRadius = 0;
            segmentControl.Layer.BorderWidth  = 1.5f;
            segmentControl.Layer.BorderColor  = UIColor.Clear.CGColor;
            segmentControl.BackgroundColor    = UIColor.Clear.FromHex("#f9f9f9");
            segmentControl.TintColor          = UIColor.Clear;

            var selectedTextAttributes = new UITextAttributes();

            selectedTextAttributes.TextColor = UIColor.Clear.FromHex("#c14d60");
            var unSelectedTextAttributes = new UITextAttributes();

            unSelectedTextAttributes.TextColor = UIColor.Clear.FromHex("#7a7a7a");

            //set the new text color attributes on the selected segment's title
            segmentControl.SetTitleTextAttributes(selectedTextAttributes, UIControlState.Selected);
            segmentControl.SetTitleTextAttributes(unSelectedTextAttributes, UIControlState.Normal);

            segmentControl.InsertSegment("Contact", 0, false);
            segmentControl.InsertSegment("Feedback", 1, false);
            segmentControl.SelectedSegment = 0;
            segmentControl.ValueChanged   += (sender, e) =>
            {
                var selectedSegmentId = (sender as UISegmentedControl).SelectedSegment;
                switch (selectedSegmentId)
                {
                case 0:
                    _infoTableView.Hidden = false;
                    _feedbackView.Hidden  = true;
                    break;

                case 1:
                    _infoTableView.Hidden = true;
                    _feedbackView.Hidden  = false;
                    break;
                }
            };

            /* -- feedback view -- */

            _serialDisposable = new SerialDisposable();

            _feedbackView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Hidden = true,
            };

            var ratingLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font          = UIFont.FromName("Helvetica", 24f),
                TextAlignment = UITextAlignment.Right,
                Text          = "4.5",
                TextColor     = UIColor.Clear.FromHex("#c14d60")
            };

            /* -- ratings panel view -- */

            var ratingsPanel = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            var numberOfReviewsLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font          = UIFont.FromName("Helvetica", 14f),
                TextColor     = UIColor.Clear.FromHex("#666666"),
                TextAlignment = UITextAlignment.Left,
                Text          = "25 Reviews",
            };

            ratingsPanel.Add(numberOfReviewsLabel);

            var ratingsPanelViews = new DictionaryViews()
            {
                { "numberOfReviewsLabel", numberOfReviewsLabel },
            };

            ratingsPanel.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-20-[numberOfReviewsLabel]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, ratingsPanelViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[numberOfReviewsLabel]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, ratingsPanelViews))
                .ToArray());

            /* -- ratings panel view -- */

            var verticalSeperator = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear.FromHex("#dddddd")
            };

            var horizontalSeperator = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear.FromHex("#dddddd")
            };

            _feedbackTableView = new UITableView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _infoTableView = new UITableView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _infoTableView.RegisterClassForCellReuse(typeof(HeaderTableViewCell), HeaderTableViewCell.Key);
            _infoTableView.RegisterClassForCellReuse(typeof(ContactTableViewCell), ContactTableViewCell.Key);

            _feedbackView.Add(ratingLabel);
            _feedbackView.Add(ratingsPanel);
            _feedbackView.Add(verticalSeperator);
            _feedbackView.Add(horizontalSeperator);
            _feedbackView.Add(_feedbackTableView);

            var feedbackViews = new DictionaryViews()
            {
                { "ratingLabel", ratingLabel },
                { "ratingsPanel", ratingsPanel },
                { "verticalSeperator", verticalSeperator },
                { "horizontalSeperator", horizontalSeperator },
                { "feedbackTableView", _feedbackTableView },
            };

            /* -- feedback view -- */

            infoView.Add(segmentControl);
            infoView.Add(_infoTableView);
            infoView.Add(_feedbackView);

            var infoViews = new DictionaryViews()
            {
                { "segmentControl", segmentControl },
                { "infoTableView", _infoTableView },
                { "feedbackView", _feedbackView },
            };

            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[mapView][infoView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                                // map view is a bit smaller than info view
                                .Concat(new NSLayoutConstraint[] { NSLayoutConstraint.Create(_mapView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, infoView, NSLayoutAttribute.Height, 0.9f, 0) })
                                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-5-[directionView]", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                                // direction view is a third of the map view
                                .Concat(new NSLayoutConstraint[] { NSLayoutConstraint.Create(directionView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, _mapView, NSLayoutAttribute.Height, 0.35f, 0) })
                                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[mapView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[directionView]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[infoView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                                .ToArray());

            infoView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[segmentControl(35)][infoTableView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, infoViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[segmentControl(35)][feedbackView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, infoViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[segmentControl]|", NSLayoutFormatOptions.AlignAllTop, null, infoViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[infoTableView]|", NSLayoutFormatOptions.AlignAllTop, null, infoViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[feedbackView]|", NSLayoutFormatOptions.AlignAllTop, null, infoViews))
                .ToArray());

            _feedbackView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-5-[ratingLabel(40)]-5-[horizontalSeperator(1)]-5-[feedbackTableView]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, feedbackViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-5-[verticalSeperator(40)]-5-[horizontalSeperator(1)]-5-[feedbackTableView]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, feedbackViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-5-[ratingsPanel(40)]-5-[horizontalSeperator(1)]-5-[feedbackTableView]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, feedbackViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[ratingLabel]-5-[verticalSeperator(1)]-5-[ratingsPanel(ratingLabel)]-10-|", NSLayoutFormatOptions.AlignAllTop, null, feedbackViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[horizontalSeperator]-10-|", NSLayoutFormatOptions.AlignAllTop, null, feedbackViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[feedbackTableView]|", NSLayoutFormatOptions.AlignAllTop, null, feedbackViews))
                .ToArray());

            this.Bind(ViewModel, x => x.CompanyName, x => x.Title);
            this.Bind(ViewModel, x => x.DestinationAddress, x => x._destinationLabel.Text);
            this.Bind(ViewModel, x => x.CurrentAddress, x => x._currentAddressTextField.Text);

            this.Bind(ViewModel, x => x.Phone, x => x._phoneLabel.Text);
            this.Bind(ViewModel, x => x.Email, x => x._emailLabel.Text);
            this.Bind(ViewModel, x => x.Website, x => x._websiteLabel.Text);

            this.BindCommand(ViewModel, x => x.DrivingCommand, x => x._buttons[1]);
            this.BindCommand(ViewModel, x => x.TransitCommand, x => x._buttons[2]);
            this.BindCommand(ViewModel, x => x.WalkingCommand, x => x._buttons[3]);

            this.WhenActivated(d =>
            {
            });
        }
コード例 #15
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        /// <returns>The did load.</returns>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = UIColor.White;

            _presenter.SetView(this);

            var width  = View.Bounds.Width;
            var height = View.Bounds.Height;

            Title = "Welcome";

            var titleLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text          = "Chat",
                Font          = UIFont.FromName("Helvetica-Bold", 22),
                TextAlignment = UITextAlignment.Center
            };

            _activityIndicatorView = new UIActivityIndicatorView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Color = UIColor.Black
            };

            var descriptionLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text          = "Enter your login name to join the chat room.",
                Font          = UIFont.FromName("Helvetica", 18),
                TextAlignment = UITextAlignment.Center
            };

            _loginTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder     = "Username",
                Font            = UIFont.FromName("Helvetica", 18),
                BackgroundColor = UIColor.Clear.FromHex("#DFE4E6"),
                TextAlignment   = UITextAlignment.Center
            };

            _passwordTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder     = "Password",
                Font            = UIFont.FromName("Helvetica", 18),
                BackgroundColor = UIColor.Clear.FromHex("#DFE4E6"),
                TextAlignment   = UITextAlignment.Center
            };

            var buttonView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            var loginButton = new UIButton(UIButtonType.RoundedRect)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            loginButton.SetTitle("Login", UIControlState.Normal);
            loginButton.TouchUpInside += (sender, e) =>
                                         Login(this, new Tuple <string, string>(_loginTextField.Text, _passwordTextField.Text));

            var registerButton = new UIButton(UIButtonType.RoundedRect)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            registerButton.SetTitle("Register", UIControlState.Normal);
            registerButton.TouchUpInside += (sender, e) =>
                                            Register(this, new Tuple <string, string>(_loginTextField?.Text, _passwordTextField?.Text));

            Add(titleLabel);
            Add(descriptionLabel);
            Add(_activityIndicatorView);
            Add(_loginTextField);
            Add(_passwordTextField);
            Add(buttonView);

            buttonView.Add(loginButton);
            buttonView.Add(registerButton);

            var views = new DictionaryViews()
            {
                { "titleLabel", titleLabel },
                { "descriptionLabel", descriptionLabel },
                { "loginTextField", _loginTextField },
                { "passwordTextField", _passwordTextField },
                { "loginButton", loginButton },
                { "registerButton", registerButton },
                { "activityIndicatorView", _activityIndicatorView },
                { "buttonView", buttonView }
            };

            buttonView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-[registerButton]-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-[loginButton]-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-[registerButton]-30-[loginButton]-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .ToArray());

            View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-100-[titleLabel(50)]-[descriptionLabel(30)]-10-[loginTextField(30)]-10-[passwordTextField(30)]-10-[buttonView]", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-100-[activityIndicatorView(50)]-[descriptionLabel(30)]-10-[loginTextField(30)]-10-[passwordTextField(30)]-10-[buttonView]", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[titleLabel]-10-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[activityIndicatorView(30)]-10-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-10-[descriptionLabel]-10-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-30-[loginTextField]-30-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-30-[passwordTextField]-30-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(new[] { NSLayoutConstraint.Create(buttonView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterX, 1, 1) })
                .ToArray());
        }
コード例 #16
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.NavigationController.SetNavigationBarHidden(true, false);

            _buttons = new List <ImageButton>();

            Title = "Home";

            var mainView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            var buttonView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            Add(mainView);

            /* ----- image views ----- */

            _locationView = new LocationView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            var logoImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
                Image       = UIImage.FromFile("logo.png"),
            };

            var bottomImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFill,
                Image       = UIImage.FromFile("bg-bottom.jpg"),
            };

            var transparentBackgroundView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Black,
                Alpha           = 0.05f
            };

            _progressView = new UIActivityIndicatorView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Color = UIColor.Black,
            };

            _screenSaverView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Alpha  = 0.0f,
                Hidden = false
            };

            var screenSaverTapGesture = new UITapGestureRecognizer(() =>
            {
                _screenSaverView.Alpha  = 0.0f;
                _screenSaverView.Hidden = true;
                _screenSaverShowing     = false;

                ViewModel.ResetActions();
            });

            _screenSaverView.AddGestureRecognizer(screenSaverTapGesture);

            mainView.Add(_locationView);
            mainView.Add(_progressView);
            mainView.Add(logoImageView);

            mainView.Add(buttonView);

            buttonView.Add(bottomImageView);
            buttonView.Add(transparentBackgroundView);

            mainView.Add(_screenSaverView);

            /* ----- image views ----- */

            /* ----- buttons ----- */

            var buttonViews = new DictionaryViews()
            {
                { "bottomImageView", bottomImageView },
                { "transparentBackgroundView", transparentBackgroundView },
            };

            for (int i = 0; i < _buttonTitles.Length; i++)
            {
                var button = new ImageButton()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                };

                var title = _buttonTitles[i];

                StyleButton(button, _buttonImagePaths[i], _buttonTitles[i]);
                buttonViews.Add(title.ToLower() + "Button", button);
                buttonView.Add(button);
                // add to button list so we can perform flips
                _buttons.Add(button);
            }

            /* ----- buttons ----- */

            var views = new DictionaryViews()
            {
                { "mainView", mainView },
            };

            var mainViews = new DictionaryViews()
            {
                { "locationView", _locationView },
                { "progressView", _progressView },
                { "logoImageView", logoImageView },
                { "buttonView", buttonView },
                { "screenSaverView", _screenSaverView },
            };

            View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[mainView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[mainView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            mainView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[locationView][logoImageView][buttonView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, mainViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[progressView][logoImageView][buttonView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[screenSaverView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[screenSaverView]|", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[progressView]|", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[locationView]|", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[buttonView]|", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(new[] { NSLayoutConstraint.Create(buttonView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, _locationView, NSLayoutAttribute.Height, 0.8f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(logoImageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.Width, 0.3f, 0) })
                // height is proportional to width
                .Concat(new[] { NSLayoutConstraint.Create(logoImageView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, logoImageView, NSLayoutAttribute.Width, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(logoImageView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .ToArray());

            buttonView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[bottomImageView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, buttonViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[transparentBackgroundView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-1-[searchButton]-1-[blogButton(searchButton)]-1-|", NSLayoutFormatOptions.DirectionLeftToRight, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-1-[ratesButton]-1-[settingsButton(ratesButton)]-1-|", NSLayoutFormatOptions.DirectionLeftToRight, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-1-[feedbackButton]-1-[shareButton(feedbackButton)]-1-|", NSLayoutFormatOptions.DirectionLeftToRight, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[bottomImageView]|", NSLayoutFormatOptions.AlignAllTop, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[transparentBackgroundView]|", NSLayoutFormatOptions.AlignAllTop, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-1-[searchButton]-1-[ratesButton(searchButton)]-1-[feedbackButton(searchButton)]-1-|", NSLayoutFormatOptions.AlignAllTop, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-1-[blogButton]-1-[settingsButton(blogButton)]-1-[shareButton(blogButton)]-1-|", NSLayoutFormatOptions.AlignAllTop, null, buttonViews))
                .ToArray());

            // search button
            this.BindCommand(ViewModel, x => x.SearchCommand, x => x._buttons[0]);

            this.WhenActivated(d =>
            {
                // HACK: Clean this up with proper navigation
                ViewModel.OnShow(new Dictionary <string, object>());
            });
        }
コード例 #17
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var titleView = new UIView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, 44));

            this.NavigationItem.TitleView = titleView;

            var subTitleLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Text          = "Match Day Management",
                Font          = UIFont.FromName("Helvetica", 12f),
                TextColor     = UIColor.FromRGB(105, 105, 105),
            };

            var titleLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Font          = UIFont.FromName("Alfa Slab One", 20f),
                TextColor     = UIColor.FromRGB(60, 60, 59),
            };

            _timeRemainingTitleLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Text          = "Time Remaining",
                Font          = UIFont.FromName("Helvetica", 12f),
                TextColor     = UIColor.FromRGB(105, 105, 105),
            };

            _timeRemainingLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Font          = UIFont.FromName("Alfa Slab One", 20f),
                TextColor     = UIColor.FromRGB(60, 60, 59),
            };

            var imageView = new UIImageView(UIImage.FromFile("afl_logo.png"))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode            = UIViewContentMode.ScaleAspectFit,
                UserInteractionEnabled = true
            };

            UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(() =>
            {
                NavigationController.PopViewController(true);
            });

            imageView.AddGestureRecognizer(tapGesture);

            var views = new DictionaryViews()
            {
                { "subTitleLabel", subTitleLabel },
                { "titleLabel", titleLabel },
                { "imageView", imageView },
                { "timeRemainingTitleLabel", _timeRemainingTitleLabel },
                { "timeRemainingLabel", _timeRemainingLabel },
            };

            titleView.Add(subTitleLabel);
            titleView.Add(_titleLabel);
            titleView.Add(imageView);
            titleView.Add(_timeRemainingTitleLabel);
            titleView.Add(_timeRemainingLabel);

            titleView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-5-[subTitleLabel(15)][titleLabel(18)]", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-5-[timeRemainingTitleLabel(15)][timeRemainingLabel(18)]", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[imageView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[subTitleLabel]", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[titleLabel]", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[imageView(40)]", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[timeRemainingTitleLabel]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[timeRemainingLabel]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(new[] { NSLayoutConstraint.Create(subTitleLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, titleView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(titleLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, titleView, NSLayoutAttribute.CenterX, 1f, 0) })
                .ToArray());

            this.WhenActivated(d =>
            {
                // We need to bind the ViewModel property to the DataContext in order to be able to
                // use WPF Bindings. Let's use WPF bindings for the UserName property.
                this.Bind(ViewModel, vm => vm.Title, v => v._titleLabel.Text);
                //OnAppear(new Dictionary<string, object>());
            });

            NavigationItem.SetHidesBackButton(true, false);

            UITextAttributes myTextAttrib = new UITextAttributes();

            myTextAttrib.Font      = UIFont.FromName("Alfa Slab One", 20);
            myTextAttrib.TextColor = UIColor.FromRGB(105, 105, 105);

            UINavigationBar.Appearance.SetTitleTextAttributes(myTextAttrib);
        }
コード例 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:MatchDayManagement.iOS.InjurySearchResultTableViewCell"/> class.
        /// </summary>
        /// <param name="handle">Handle.</param>
        protected EReactiveUIAroundMeListItemTableViewCell(IntPtr handle) : base(handle)
        {
            _nameLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.FromName("Helvetica", 16f),
                TextColor = UIColor.Clear.FromHex("#444444"),
            };

            _addressLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.FromName("Helvetica", 12f),
                TextColor = UIColor.Clear.FromHex("#666666")
            };

            _distanceLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font          = UIFont.FromName("Helvetica", 12f),
                TextColor     = UIColor.Clear.FromHex("#666666"),
                TextAlignment = UITextAlignment.Right,
            };

            _arrowImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
            };

            _leftView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear.FromHex("#ca505d")
            };

            var views = new DictionaryViews()
            {
                { "nameLabel", _nameLabel },
                { "addressLabel", _addressLabel },
                { "distanceLabel", _distanceLabel },
                { "arrowImageView", _arrowImageView },
            };

            ContentView.Add(_nameLabel);
            ContentView.Add(_addressLabel);
            ContentView.Add(_distanceLabel);
            ContentView.Add(_arrowImageView);

            ContentView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-10-[nameLabel][addressLabel]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-10-[arrowImageView(20)][distanceLabel]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-18-[nameLabel]-5-[arrowImageView(20)]-15-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-18-[addressLabel]-5-[distanceLabel(60)]-15-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            // selected view
            SelectedBackgroundView = new UIView(ContentView.Bounds)
            {
                BackgroundColor = UIColor.Clear.FromHex("#fefafa"),
            };

            SelectedBackgroundView.Add(_leftView);

            var selectedViews = new DictionaryViews()
            {
                { "leftView", _leftView }
            };

            SelectedBackgroundView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[leftView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, selectedViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[leftView(3)]", NSLayoutFormatOptions.AlignAllTop, null, selectedViews))
                .ToArray());
        }