コード例 #1
0
 public void AdicionarPergunta(Pergunta pergunta)
 {
     this.Pergunta = pergunta;
 }
コード例 #2
0
		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);
		}
コード例 #3
0
        public CompartilharFBPage(Pergunta pergunta, string textoNoticia)
        {
            this.textoNoticia = textoNoticia;
            this.pergunta = pergunta;

            var lblTexto = new Label
            {
                Text = "Digite abaixo o que você está pensando",
                FontSize = 18,
                YAlign = TextAlignment.Center,
                HorizontalOptions = LayoutOptions.Start
            };

            txtTexto = new Editor
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HeightRequest = 70,
                WidthRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth,
            };

            var btnCompartilhar = new Button
            {
                Text = "Concluir"
            };
            btnCompartilhar.Clicked += async (sender, e) =>
            {
                var dbFacebook = new Repositorio<FacebookInfos>();
                var userToken = await dbFacebook.RetornarTodos();

                if (userToken == null)
                {
                    await Acr.UserDialogs.UserDialogs.Instance.AlertAsync("Erro na autenticação com o Facebook, tente novamente!");
                    return;
                }

                var postou = await DependencyService.Get<IFacebook>().PostToWall(msg, userToken.First().access_token);

                if (postou)
                {
                    await Acr.UserDialogs.UserDialogs.Instance.AlertAsync("Postagem concluída com sucesso!");
                    await this.Navigation.PushModalAsync(new MainPage());
                }
                else
                    await Acr.UserDialogs.UserDialogs.Instance.AlertAsync("Erro ao postar, tente novamente!");
            };

            var mainlayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Spacing = 5,
                Children =
                {
                    lblTexto,
                    txtTexto,
                    btnCompartilhar
                }
            };

            this.Content = mainlayout;
        }
コード例 #4
0
        public VotoSalvoQuizPage(Pergunta p)
        {
            this.pergunta = p;

            var voltarStack = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Padding = new Thickness(3, Device.OnPlatform(20, 0, 0), 0, 0),
                BackgroundColor = Color.White,
                HeightRequest = 40,
                Children =
                {
                    new Image
                    {
                        Source = ImageSource.FromResource(RetornaCaminhoImagem.GetImagemCaminho("voltar.png")),
                        VerticalOptions = LayoutOptions.Start
                    },
                    new Label
                    { 
                        Text = AppResources.TextoVoltar, 
                        TextColor = Color.Black, 
                        YAlign = TextAlignment.Center,
                        FontSize = 18,
                        VerticalOptions = LayoutOptions.StartAndExpand
                    }
                }
            };

            var voltarStack_Click = new TapGestureRecognizer();
            voltarStack_Click.Tapped += async (sender, e) => await this.Navigation.PushModalAsync(new MainPage());
            voltarStack.GestureRecognizers.Add(voltarStack_Click);

            var aviso = new Label
            {
                Style = Estilos._estiloFonteSucessoRespostaQuiz,
                Text = p.correta ? "Parabéns, certa resposta! Em breve seu próximo Quiz estará disponível." :
                        "Infelizmente você não acertou. Aguarde o próximo Quiz.",
                XAlign = TextAlignment.Center
            };

            var sucesso = new Label
            {
                Style = Estilos._estiloFonteSucessoResposta,
                Text = AppResources.TextoSucesso
            };

            var imagem = new Image
            {
                Source = ImageSource.FromResource(RetornaCaminhoImagem.GetImagemCaminho("enqueteresp.png"))
            };

            var imagem_Click = new TapGestureRecognizer();
            imagem_Click.Tapped += async (sender, e) => await this.Navigation.PushModalAsync(new MainPage());
            imagem.GestureRecognizers.Add(imagem_Click);

            var overlayUP = new StackLayout { BackgroundColor = Colors._defaultColorFromHex, /*Children = { voltarStack }*/  };

            btnCompartilhar = new Button
            {
                Text = "Compartilhar",
                Style = Estilos._estiloPadraoButton
            };
            btnCompartilhar.Clicked += async (sender, e) =>
            {

                try
                {
                    var dbResposta = new Repositorio<Resposta>();
                    var _resposta = await dbResposta.RetornarPorId(this.pergunta.Respostas.First(x => x.Respondida).Id);

                    var msg = String.Format("Eu votei na enquete {0} com {1}"
                            , this.pergunta.TextoPergunta);

                    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(msg, string.Empty, link);
                }
                catch (Exception ex)
                {
                    Insights.Report(ex);
                }

                //await this.Navigation.PushModalAsync(new CompartilharFBPage(this.pergunta, string.Empty));
            };

            var absLayout = new AbsoluteLayout { HeightRequest = 400 };

            AbsoluteLayout.SetLayoutFlags(overlayUP, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(overlayUP, new Rectangle(1, 0, 1, 0.55));

            AbsoluteLayout.SetLayoutFlags(sucesso, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(sucesso, new Rectangle(0.5, 0.15, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            AbsoluteLayout.SetLayoutFlags(aviso, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(aviso, new Rectangle(0.5, 0.20, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            AbsoluteLayout.SetLayoutFlags(imagem, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(imagem, new Rectangle(0.5, 0.55, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            AbsoluteLayout.SetLayoutFlags(btnCompartilhar, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(btnCompartilhar, new Rectangle(0.5, 0.9, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            absLayout.Children.Add(overlayUP);
//            absLayout.Children.Add(sucesso);
            absLayout.Children.Add(aviso);
            absLayout.Children.Add(imagem);
            absLayout.Children.Add(btnCompartilhar);

            this.Content = absLayout;
        }
コード例 #5
0
        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);
            }
        }