public ChatView()
        {
            InitializeComponent();

            BindingContext = new ChatPageViewModel();

            ScrollListCommand = new Command(() =>
            {
                Device.BeginInvokeOnMainThread(() =>
                                               ChatList.ScrollTo((this.BindingContext as ChatPageViewModel).Messages.Last(), ScrollToPosition.End, true)
                                               );
            });
        }
Ejemplo n.º 2
0
        public ChatPage(ChatRoomLoader _chatRoomLoader)
        {
            InitializeComponent();
            titleLabel.Text = $"{_chatRoomLoader.Title} Room";
            current_context = new ChatPageViewModel()
            {
                Room_ID = _chatRoomLoader.Id
            };
            this.BindingContext = current_context;
            chatRoomLoader      = _chatRoomLoader;
            Settings_Label.Text = Constants.FontAwe.Cog;

            ScrollListCommand = new Command(() =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    if ((this.BindingContext as ChatPageViewModel).Messages.Count > 0)
                    {
                        ChatList.ScrollTo((this.BindingContext as ChatPageViewModel).Messages.LastOrDefault(), ScrollToPosition.End, false);
                    }
                });
            });

            FocusCommand = new Command(() =>
            {
                chatInput.FocusEntry();
            });

            GetPhotoCommand = new Command(async() =>
            {
                await Navigation.PushModalAsync(new CameraPage(chatRoomLoader));
                chatInput.UnFocusEntry();
            });
            MessagingCenter.Subscribe <object>(this, Constants.go_back, (sender) =>
            {
                Navigation.PopModalAsync();
            });

            MessagingCenter.Subscribe <object>(this, Constants.scroll_chat, (sender) =>
            {
                ScrollListCommand.Execute(null);
            });
        }
Ejemplo n.º 3
0
        public ChatPage()
        {
            InitializeComponent();
            viewModel           = new ChatRoomViewModel();
            this.BindingContext = viewModel;
            ScrollListCommand   = new Command(() =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    try
                    {
                        ChatList.ScrollTo((this.BindingContext as ChatRoomViewModel).Messages.Last(), ScrollToPosition.End, false);
                    }
                    catch (Exception)
                    {
                    }
                }


                                               );
            });
        }
Ejemplo n.º 4
0
        private void scrollToBottom()
        {
            var target = chatModels[chatModels.Count - 1];

            ChatList.ScrollTo(target, ScrollToPosition.End, true);
        }
Ejemplo n.º 5
0
        private void NewMessagge(string obj)
        {
            var last = ChatList.ItemsSource.Cast <object>().LastOrDefault();

            ChatList.ScrollTo(last, ScrollToPosition.MakeVisible, true);
        }
Ejemplo n.º 6
0
        public ChatPage(SelectedUser ob, string IdInfo, RequestSpecs requestSpecs)
        {
            InitializeComponent();

            if (requestSpecs.DeliveredAt == "1")
            {
                ReserveItemObj RO          = new ReserveItemObj();
                ApiService     _apiService = new ApiService();

                requestSpecs.DeliveredAt = "0";
                RO.requestSpecs          = requestSpecs;
                _apiService.UpdateItemFTravel(RO);
            }
            else
            {
            }
            if (IdInfo.Contains("-1"))
            {
                Back.IsVisible  = false;
                rowone.Height   = 1;
                Title           = "Chat";
                chaterName.Text = IdInfo.Replace("-1", "");
            }
            else
            {
                chaterName.Text = IdInfo;
            }


            ImageURL.Source = ob.image;



            this.BindingContext = viewModel = new ChatUIViewModel();
            viewModel.travelID  = ob.travelerSpecs.Id;
            viewModel.requesID  = requestSpecs.Id;
            viewModel.traveler  = ob.travelerSpecs.Email;
            viewModel.sender    = requestSpecs.Email;
            ScrollListCommand   = new Command(() =>
            {
                Device.BeginInvokeOnMainThread(() =>
                                               ChatList.ScrollTo((this.BindingContext as ChatUIViewModel).Messages, ScrollToPosition.End, true)
                                               );
            });

            MessagingCenter.Subscribe <ChatIntpuBarView, string>(this, "ScrollList", (obj, Item) => {
                if (Item == "Done")
                {
                    ScrollListCommand.Execute(null);
                }
            });


            MessagingCenter.Subscribe <App, string>(this, "ChatUpdate", async(obj, item) => {
                if (item == "Update")
                {
                    await viewModel.ExecuteLoadItemsCommand();
                }
            });

            lb_backFunc();
            void lb_backFunc()
            {
                try
                {
                    Back.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(() =>
                        {
                            Navigation.PopModalAsync();
                        })
                    });
                }
                catch (Exception ex) { Debug.WriteLine(ex); }
            }
        }
Ejemplo n.º 7
0
        private void ScrollToEnd()
        {
            var v = ChatList.ItemsSource.Cast <object>().LastOrDefault();

            ChatList.ScrollTo(v, ScrollToPosition.End, true);
        }