/// <summary>
        /// Ons the create.
        /// </summary>
        /// <returns>The create.</returns>
        /// <param name="bundle">Bundle.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.ChatView);

            var metrics = Resources.DisplayMetrics;

            _width = (int)((metrics.WidthPixels) / Resources.DisplayMetrics.Density);

            _scrollViewInnerLayout = FindViewById <LinearLayout>(Resource.Id.scrollViewInnerLayout);
            _editText = FindViewById <EditText>(Resource.Id.chatField);

            var sendButton = FindViewById <Button>(Resource.Id.sendButton);

            sendButton.Touch += HandleSendButton;

            var app = ChatApplication.GetApplication(this);

            app.CurrentActivity = this;

            _presenter = app.Presenter as ChatPresenter;
            _presenter.SetView(this);
            app.CurrentActivity = this;
        }
Esempio n. 2
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());
        }