protected async override void OnAppearing() { base.OnAppearing(); this.model = App.Container.Resolve<PerguntaViewModel>(); this.BindingContext = model; this.pergunta = model.Pergunta; this.model.ConfigurarNavigation(this.Navigation); var lblTitulo = new Label { FontSize = 28, FontFamily = Device.OnPlatform( iOS: "Helvetica", Android: "Roboto", WinPhone: "Segoe" ), FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, YAlign = TextAlignment.Center, XAlign = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap }; lblTitulo.SetBinding<PerguntaViewModel>(Label.TextProperty, x => x.Pergunta.TextoPergunta); var Imagem = new Image { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Aspect = Aspect.AspectFit, }; if (!String.IsNullOrEmpty(this.imagem)) Imagem.Source = ImageSource.FromFile(DependencyService.Get<ISaveAndLoadFile>().GetImage(this.imagem)); if (!String.IsNullOrEmpty(this.urlVideo)) { if (Device.OS == TargetPlatform.iOS) { webView = new WebView(); var htmlSource = new HtmlWebViewSource(); htmlSource.Html = BuildEmbedUrl(this.urlVideo); webView.Source = htmlSource; webView.HeightRequest = 200; webView.WidthRequest = 210; webView.VerticalOptions = LayoutOptions.Center; webView.HorizontalOptions = LayoutOptions.Center; } else { str = new Uri(this.urlVideo).Segments; App.UrlVideo = this.urlVideo; imgThumbVideo = new Image { Source = ImageSource.FromFile(DependencyService.Get<ISaveAndLoadFile>().GetImage(String.Concat(str[2], ".jpg"))), HeightRequest = 200, WidthRequest = 100 }; var imgThumbVideo_Click = new TapGestureRecognizer(); imgThumbVideo_Click.Tapped += (object sender, EventArgs e) => DependencyService.Get<IYoutubePlayer>().PlayVideo(this.urlVideo); imgThumbVideo.GestureRecognizers.Add(imgThumbVideo_Click); } } var tituloNoticia = new Label(); MessagingCenter.Subscribe<ListaRespostasView,List<Resposta>>(this, "Respondido", async (sender, respostas) => { this.model.AdicionaRespostasRespondidas(respostas, temVoucher); }); StackLayout perguntaLayout; if (!String.IsNullOrEmpty(this.urlVideo)) { if (Device.OS == TargetPlatform.Android) { perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2, HorizontalOptions = LayoutOptions.Start, Children = { imgThumbVideo, tituloNoticia }, Padding = 20 }; } else perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2, HorizontalOptions = LayoutOptions.Start, Children = { webView, tituloNoticia }, Padding = 20 }; } else if (!String.IsNullOrEmpty(this.imagem)) { perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2, HorizontalOptions = LayoutOptions.Start, Children = { Imagem, tituloNoticia }, Padding = 20 }; } else { perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2, HorizontalOptions = LayoutOptions.Start, Children = { tituloNoticia }, Padding = 20 }; } btnResponder.SetBinding(Button.CommandProperty, "btnGravar_Click"); this.mainLayout.Children.Add(lblTitulo); this.mainLayout.Children.Add(perguntaLayout); this.mainLayout.Children.Add(btnResponder); }
protected async override void OnAppearing() { try { base.OnAppearing(); this.model = App.Container.Resolve<PerguntaViewModel>(); this.BindingContext = model; model.AdicionaMensagem(await model.GetMensagem(enqueteID)); this.enquete = model.Mensagem; this.model.ConfigurarNavigation(this.Navigation); var lblTitulo = new Label { FontSize = 28, FontFamily = Device.OnPlatform( iOS: "Helvetica", Android: "Roboto", WinPhone: "Segoe" ), FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, YAlign = TextAlignment.Center, XAlign = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap }; lblTitulo.SetBinding<PerguntaViewModel>(Label.TextProperty, x => x.Mensagem.Titulo); var lblDescricao = new Label { FontSize = 22, FontFamily = Device.OnPlatform( iOS: "Helvetica", Android: "Roboto", WinPhone: "Segoe" ), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, YAlign = TextAlignment.Center, XAlign = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap }; lblDescricao.SetBinding<PerguntaViewModel>(Label.TextProperty, x => x.Mensagem.Descricao); var Imagem = new Image { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Aspect = Aspect.AspectFit, }; if (!String.IsNullOrEmpty(this.imagem)) Imagem.Source = ImageSource.FromFile(DependencyService.Get<ISaveAndLoadFile>().GetImage(this.imagem)); if (!String.IsNullOrEmpty(this.urlVideo)) { if (Device.OS == TargetPlatform.iOS) { webView = new WebView(); var htmlSource = new HtmlWebViewSource(); htmlSource.Html = BuildEmbedUrl(this.urlVideo); webView.Source = htmlSource; webView.HeightRequest = 320; webView.WidthRequest = 270; webView.VerticalOptions = LayoutOptions.Center; webView.HorizontalOptions = LayoutOptions.Center; } else { str = new Uri(this.urlVideo).Segments; App.UrlVideo = this.urlVideo; imgThumbVideo = new Image { Source = ImageSource.FromFile(DependencyService.Get<ISaveAndLoadFile>().GetImage(String.Concat(str[2], ".jpg"))), HeightRequest = 200, WidthRequest = 100 }; var imgThumbVideo_Click = new TapGestureRecognizer(); imgThumbVideo_Click.Tapped += (object sender, EventArgs e) => this.Navigation.PushModalAsync(new VideoPage()); imgThumbVideo.GestureRecognizers.Add(imgThumbVideo_Click); } } var btnCompartilhar = new Button { Text = "Compartilhar", Style = Estilos._estiloPadraoButton }; btnCompartilhar.Clicked += async (sender, e) => { try { string link = string.Empty; if (Device.OS == TargetPlatform.Android) link = "https://play.google.com/store/apps/details?id=com.aplicativo.mais&hl=pt_BR"; else link = "https://itunes.apple.com/us/app/mais-app/id1028918789?ls=1&mt=8"; DependencyService.Get<IShare>().ShareLink(this.enquete.Titulo, string.Empty, link); } catch (Exception ex) { Insights.Report(ex); } }; if (App.Current.Properties.ContainsKey("UsuarioLogado")) { var u = App.Current.Properties["UsuarioLogado"] as Usuario; var dbFacebook = new Repositorio<FacebookInfos>(); var dadosFacebook = await dbFacebook.ExisteRegistroFacebook(); if (dadosFacebook == null || String.IsNullOrEmpty(dadosFacebook.access_token)) btnCompartilhar.IsVisible = false; } StackLayout perguntaLayout; if (!String.IsNullOrEmpty(this.urlVideo)) { if (Device.OS == TargetPlatform.Android) { perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2, HorizontalOptions = LayoutOptions.Center, Children = { imgThumbVideo, btnCompartilhar }, Padding = 20 }; } else perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2, HorizontalOptions = LayoutOptions.Center, Children = { webView, btnCompartilhar }, Padding = 20 }; } else if (!String.IsNullOrEmpty(this.imagem)) { perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2, HorizontalOptions = LayoutOptions.Center, Children = { Imagem, btnCompartilhar }, Padding = 20 }; } else { perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2, HorizontalOptions = LayoutOptions.Center, Children = { btnCompartilhar }, Padding = 20 }; } btnResponder.SetBinding(Button.CommandProperty, "btnGravar_Click"); this.mainLayout.Children.Add(lblTitulo); this.mainLayout.Children.Add(lblDescricao); this.mainLayout.Children.Add(perguntaLayout); } catch (Exception ex) { throw ex; } }
protected async override void OnAppearing() { try { base.OnAppearing(); this.model = App.Container.Resolve<PerguntaViewModel>(); this.BindingContext = model; model.AdicionarPergunta(await model.GetPerguntaPorId(perguntaID)); this.pergunta = model.Pergunta; this.model.ConfigurarNavigation(this.Navigation); imgExcluir = new Image { Source = ImageSource.FromResource(RetornaCaminhoImagem.GetImagemCaminho("waste.png")), HorizontalOptions = LayoutOptions.EndAndExpand, HeightRequest = 40, WidthRequest = 44, IsVisible = ehInteresse }; var imgExcluir_Click = new TapGestureRecognizer(); imgExcluir_Click.Tapped += async (sender, e) => { var confirmConfig = new Acr.UserDialogs.ConfirmConfig(); confirmConfig.CancelText = "Cancelar"; confirmConfig.OkText = "OK"; confirmConfig.Message = "Tem certeza que deseja excluir esta enquete?"; var canRemove = await Acr.UserDialogs.UserDialogs.Instance.ConfirmAsync(confirmConfig); if (canRemove) { var dbEnquete = new Repositorio<Enquete>(); var enquete = await dbEnquete.RetornarPorId(enqueteId); enquete.AtivaNoFront = false; await dbEnquete.Atualizar(enquete); await this.Navigation.PushModalAsync(new MainPage(true)); } }; imgExcluir.GestureRecognizers.Add(imgExcluir_Click); var lblUsuarioCriador = new Label { Text = String.IsNullOrEmpty(UsuarioCriador) ? "Você" : UsuarioCriador, IsVisible = !String.IsNullOrEmpty(UsuarioCriador) && ehInteresse, FontFamily = Device.OnPlatform( iOS: "Helvetica", Android: "Roboto", WinPhone: "Segoe" ), FontSize = 12, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.EndAndExpand }; var lblTitulo = new Label { FontSize = 28, FontFamily = Device.OnPlatform( iOS: "Helvetica", Android: "Roboto", WinPhone: "Segoe" ), FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, YAlign = TextAlignment.Center, XAlign = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap }; lblTitulo.SetBinding<PerguntaViewModel>(Label.TextProperty, x => x.Pergunta.TextoPergunta); var Imagem = new Image { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Aspect = Aspect.AspectFit, }; if (!String.IsNullOrEmpty(this.imagem)) Imagem.Source = ImageSource.FromFile(DependencyService.Get<ISaveAndLoadFile>().GetImage(this.imagem)); if (!String.IsNullOrEmpty(this.urlVideo)) { if (Device.OS == TargetPlatform.iOS) { webView = new WebView(); var htmlSource = new HtmlWebViewSource(); htmlSource.Html = BuildEmbedUrl(this.urlVideo); webView.Source = htmlSource; webView.HeightRequest = 200; webView.WidthRequest = 210; webView.VerticalOptions = LayoutOptions.Center; webView.HorizontalOptions = LayoutOptions.Center; } else { str = new Uri(this.urlVideo).Segments; App.UrlVideo = this.urlVideo; imgThumbVideo = new Image { Source = ImageSource.FromFile(DependencyService.Get<ISaveAndLoadFile>().GetImage(String.Concat(str[2], ".jpg"))), HeightRequest = 200, WidthRequest = 100 }; var imgThumbVideo_Click = new TapGestureRecognizer(); imgThumbVideo_Click.Tapped += (object sender, EventArgs e) => this.Navigation.PushModalAsync(new VideoPage()); //DependencyService.Get<IYoutubePlayer> ().PlayVideo (this.urlVideo); imgThumbVideo.GestureRecognizers.Add(imgThumbVideo_Click); } } var listaRespostas = new ListaRespostasView(this.pergunta.Respostas); MessagingCenter.Subscribe<ListaRespostasView,List<Resposta>>(this, "Respondido", async (sender, respostas) => { this.model.AdicionaRespostasRespondidas(respostas, temVoucher); }); MessagingCenter.Subscribe<ListaRespostasEnqueteRespondidaViewCell,string>(this, "MostraImagem", async (sender, img) => { this.Navigation.PushModalAsync(new ExibeImagemResposta(img)); }); MessagingCenter.Subscribe<ListaRespostasViewCell,string>(this, "MostraImagem", async (sender, img) => { this.Navigation.PushModalAsync(new ExibeImagemResposta(img)); }); StackLayout perguntaLayout; if (!String.IsNullOrEmpty(this.urlVideo)) { if (Device.OS == TargetPlatform.Android) { perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenHeight * 2, HorizontalOptions = LayoutOptions.Start, Children = { lblUsuarioCriador, imgExcluir, imgThumbVideo, listaRespostas }, Padding = 20 }; } else perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenHeight * 2, HorizontalOptions = LayoutOptions.Start, Children = { lblUsuarioCriador, imgExcluir, webView, listaRespostas }, Padding = 20 }; } else if (!String.IsNullOrEmpty(this.imagem)) { perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenHeight * 2, HorizontalOptions = LayoutOptions.Start, Children = { lblUsuarioCriador, imgExcluir, Imagem, listaRespostas }, Padding = 20 }; } else { perguntaLayout = new StackLayout { HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenHeight * 2, HorizontalOptions = LayoutOptions.Start, Children = { lblUsuarioCriador, imgExcluir, listaRespostas }, Padding = 20 }; } btnResponder.SetBinding(Button.CommandProperty, "btnGravar_Click"); this.mainLayout.Children.Add(lblTitulo); this.mainLayout.Children.Add(perguntaLayout); this.mainLayout.Children.Add(btnResponder); } catch (Exception ex) { Insights.Report(ex); } }