Пример #1
0
        async void sendMessage()
        {
            try
            {
                string message = EntryMess.Text;
                //if (string.IsNullOrWhiteSpace(message))
                //{
                //    EntryMess.Text = string.Empty;
                //    return;
                //}
                //var anim = new Task(async () =>
                //{
                //    IconViewSend.Scale = 0.7;
                //    await Task.Delay(TimeSpan.FromSeconds(0.5));
                //    IconViewSend.Scale = 1;
                //});
                //anim.Start();
                if (!string.IsNullOrWhiteSpace(message))
                {
                    progress.IsVisible     = true;
                    IconViewSend.IsVisible = false;
                    CommonResult result = await _server.AddMessage(message, _requestInfo.ID.ToString());

                    if (result.Error == null)
                    {
                        EntryMess.Text = "";
                        // await ShowToast(AppResources.MessageSent);
                        //await RefreshData();

                        //var lastChild = baseForApp.Children.LastOrDefault();
                        //if (lastChild != null)
                        //    await MethodWithDelayAsync(600);

                        await RefreshData();

                        //Device.BeginInvokeOnMainThread(async () => await scrollFroAppMessages.ScrollToAsync(lastChild, ScrollToPosition.End, true));
                    }
                }
                else
                {
                    await ShowToast(AppResources.ErrorMessageEmpty);
                }

                progress.IsVisible     = false;
                IconViewSend.IsVisible = true;
            }
            catch (Exception e)
            {
                await ShowToast(AppResources.MessageNotSent);


                progress.IsVisible     = false;
                IconViewSend.IsVisible = true;
            }
        }