private void inicializarComponente() { _palavraChaveSearchBar = new SearchBar { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Placeholder = "Buscar endereço...", SearchCommand = new Command(() => { executarBusca(_palavraChaveSearchBar.Text, IdBairro); }) }; _EnderecoListView = new ListView { HasUnevenRows = true, RowHeight = -1, SeparatorVisibility = SeparatorVisibility.Default, SeparatorColor = Estilo.Current.PrimaryColor, ItemTemplate = new DataTemplate(typeof(LogradouroCell)) }; _EnderecoListView.SetBinding(ListView.ItemsSourceProperty, new Binding(".")); _EnderecoListView.ItemTapped += (sender, e) => { if (e == null) { return; } var endereco = (EnderecoInfo)((ListView)sender).SelectedItem; _EnderecoListView.SelectedItem = null; AoSelecionar?.Invoke(this, endereco); }; }
private async void pegarEnderecoPorCep(string cep) { UserDialogs.Instance.ShowLoading("Buscando..."); try { var regraCep = CepFactory.create(); var endereco = await regraCep.pegarPorCep(cep); UserDialogs.Instance.HideLoading(); if (endereco != null) { AoSelecionar?.Invoke(this, endereco); } else { string mensagem = string.Format("Nenhum endereço encontrado com o CEP {0}.", cep); await DisplayAlert("Aviso", mensagem, "Fechar"); } } catch (Exception erro) { UserDialogs.Instance.HideLoading(); //UserDialogs.Instance.Alert(erro.Message, "Erro", "Fechar"); await DisplayAlert("Erro", erro.Message, "Fechar"); } }
private void inicializarComponente() { _CadastroButton = new Button() { Margin = new Thickness(0, 10, 0, 0), Text = "CRIAR CONTA", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Fill, Style = Estilo.Current[Estilo.BTN_PRINCIPAL] }; _CadastroButton.Clicked += (sender, e) => { var cadastroPage = UsuarioFormPageFactory.create(); cadastroPage.Title = "Cria sua conta"; cadastroPage.Usuario = Usuario; cadastroPage.Gravar = true; cadastroPage.AoCadastrar += (s2, usuario) => { AoSelecionar?.Invoke(this, usuario); }; Navigation.PushAsync(cadastroPage); }; _LoginButton = new Button() { Margin = new Thickness(0, 10, 0, 0), Text = "JÁ POSSUO UM CONTA", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Fill, Style = Estilo.Current[Estilo.BTN_SUCESSO] }; _LoginButton.Clicked += (sender, e) => { var loginPage = new LoginPage { Title = "Entre com sua conta" }; loginPage.AoLogar += (s2, usuario) => { AoSelecionar?.Invoke(this, usuario); }; Navigation.PushAsync(loginPage); }; _SenhaButton = new Button() { Margin = new Thickness(0, 10, 0, 0), Text = "ESQUECI/ALTERAR MINHA SENHA", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Fill, Style = Estilo.Current[Estilo.BTN_PADRAO] }; _SenhaButton.Clicked += (sender, e) => { Navigation.PushAsync(new EmailSenhaPage()); }; }
private void inicializarComponente() { _diaEntregaPicker = new DatePicker { VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.FillAndExpand, MinimumDate = DateTime.Today }; _diaEntregaPicker.DateSelected += (sender, e) => { if (_horarios != null && _horarios.Count() == 0) { AoSelecionar?.Invoke(this, string.Empty); } }; _horarioLabel = new Label { Text = "Selecione o horário de entrega:", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.LABEL_CONTROL], }; _horarioListView = new ListView { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, HasUnevenRows = true, RowHeight = -1, SeparatorVisibility = SeparatorVisibility.Default, ItemTemplate = new DataTemplate(typeof(PedidoHorarioCell)) }; _horarioListView.SetBinding(ListView.ItemsSourceProperty, new Binding(".")); _horarioListView.ItemTapped += (sender, e) => { if (e == null) { return; } if (!(_diaEntregaPicker.Date >= DateTime.Today)) { _horarioListView.SelectedItem = null; UserDialogs.Instance.AlertAsync("Aviso", "Selecione uma data maior que hoje.", "Entendi"); return; } var horario = (PedidoHorarioInfo)((ListView)sender).SelectedItem; //_horarioListView.SelectedItem = null; AoSelecionar?.Invoke(this, horario.Horario); }; }
/* * public void excluir(PedidoInfo pedido) { * if (_pedidos != null) * { * _pedidoListView.ItemsSource = null; * _pedidos.Remove(pedido); * _pedidoListView.ItemsSource = _pedidos; * AoAtualizar?.Invoke(this, _pedidos); * } * } */ private void inicializarComponente() { _pedidoListView = new ListView { HasUnevenRows = true, RowHeight = -1, SeparatorVisibility = SeparatorVisibility.None, ItemTemplate = new DataTemplate(typeof(PedidoCell)) }; _pedidoListView.SetBinding(ListView.ItemsSourceProperty, new Binding(".")); _pedidoListView.ItemTapped += (sender, e) => { if (e == null) { return; } var pedido = (PedidoInfo)((ListView)sender).SelectedItem; _pedidoListView.SelectedItem = null; AoSelecionar?.Invoke(this, pedido); }; }
private void inicializarComponente() { _UfListView = new ListView { HasUnevenRows = true, RowHeight = -1, SeparatorVisibility = SeparatorVisibility.Default, SeparatorColor = Estilo.Current.PrimaryColor, ItemTemplate = new DataTemplate(typeof(UfCell)) }; _UfListView.SetBinding(ListView.ItemsSourceProperty, new Binding(".")); _UfListView.ItemTapped += (sender, e) => { if (e == null) { return; } var estado = (UfInfo)((ListView)sender).SelectedItem; _UfListView.SelectedItem = null; AoSelecionar?.Invoke(this, estado); }; }
private void inicializarComponente() { _enderecoForm = new EnderecoForm { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill }; _avancarButton = new Button { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.End, Style = Estilo.Current[Estilo.BTN_PRINCIPAL], Text = "Avançar" }; _avancarButton.Clicked += async(sender, e) => { var endereco = this.Endereco; if (string.IsNullOrEmpty(endereco.Numero)) { await DisplayAlert("Aviso", "Preencha o número.", "Entendi"); return; } AoSelecionar?.Invoke(this, Endereco); }; }
private void inicializarComponente() { _mainLayout = new AbsoluteLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; _mapaLayout = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Spacing = 0 }; AbsoluteLayout.SetLayoutBounds(_mapaLayout, new Rectangle(0, 0, 1, 1)); AbsoluteLayout.SetLayoutFlags(_mapaLayout, AbsoluteLayoutFlags.All); _mainLayout.Children.Add(_mapaLayout); _barraLateralLayout = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, Spacing = 4, //BackgroundColor = Color.Green }; AbsoluteLayout.SetLayoutBounds(_barraLateralLayout, new Rectangle(0.98, 0.5, 0.2, 0.6)); AbsoluteLayout.SetLayoutFlags(_barraLateralLayout, AbsoluteLayoutFlags.All); _mainLayout.Children.Add(_barraLateralLayout); _palavraChaveSearchBar = new SearchBar() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Start, BackgroundColor = Color.White, Placeholder = "Pesquisar...", FontSize = 20, HeightRequest = 42 }; _palavraChaveSearchBar.SearchButtonPressed += async(sender, e) => { await buscarLocalporPalavraChave(_palavraChaveSearchBar.Text); }; _mapaLayout.Children.Add(_palavraChaveSearchBar); _mapaLayout.Children.Add(new BoxView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Start, BackgroundColor = Estilo.Current.PrimaryColor, HeightRequest = 1 }); _resultadoBuscaListView = new ListView { HasUnevenRows = true, RowHeight = -1, //SeparatorVisibility = SeparatorVisibility.None, SeparatorVisibility = SeparatorVisibility.Default, SeparatorColor = Estilo.Current.PrimaryColor, ItemTemplate = new DataTemplate(typeof(ResultadoBuscaCell)) }; _resultadoBuscaListView.SetBinding(ListView.ItemsSourceProperty, new Binding(".")); _resultadoBuscaListView.ItemTapped += resultadoBuscaItemTapped; _Mapa = new CustomMap() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, IsShowingUser = false }; _Mapa.aoClicar += (sender, e) => { try { fixarPontoNoMapa(new Pin { Type = PinType.Place, Position = e.Position, Label = TituloPadrao, Address = TituloPadrao }); } catch (Exception erro) { UserDialogs.Instance.Alert(erro.Message, "Erro", "Entendi"); } }; _mapaLayout.Children.Add(_Mapa); _excluirPontoButton = new CircleIconButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, BackgroundColor = Estilo.Current.DangerColor, TextColor = Color.White, WidthRequest = 50, HeightRequest = 50, FontSize = 22, BorderRadius = 50, Text = "fa-remove" }; _excluirPontoButton.Clicked += (sender, e) => { try { if (_Mapa.Pins.Count() > 0) { var pins = new List <Pin>(); foreach (var pin in _Mapa.Pins) { pins.Add(pin); } pins.RemoveAt(pins.Count() - 1); if (pins.Count() > 0) { var pin = pins[pins.Count() - 1]; _Mapa.MoveToRegion(MapSpan.FromCenterAndRadius(pin.Position, Distance.FromMiles(0.5))); } _Mapa.Pins.Clear(); foreach (var pin in pins) { _Mapa.Pins.Add(pin); } _Mapa.Polyline = Polyline; } } catch (Exception erro) { UserDialogs.Instance.Alert(erro.Message, "Erro", "Entendi"); } }; _barraLateralLayout.Children.Add(_excluirPontoButton); _limparButton = new CircleIconButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, BackgroundColor = Estilo.Current.WarningColor, TextColor = Color.White, WidthRequest = 50, HeightRequest = 50, FontSize = 22, BorderRadius = 50, Text = "fa-trash" }; _limparButton.Clicked += async(sender, e) => { if (await UserDialogs.Instance.ConfirmAsync("Deseja limpar a rota?", "Aviso", "Sim", "Não")) { try { _Mapa.Pins.Clear(); _Mapa.Polyline = Polyline; } catch (Exception erro) { UserDialogs.Instance.Alert(erro.Message, "Erro", "Entendi"); } } }; _barraLateralLayout.Children.Add(_limparButton); _visualizarButton = new CircleIconButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, BackgroundColor = Estilo.Current.SuccessColor, TextColor = Color.White, WidthRequest = 50, HeightRequest = 50, FontSize = 22, BorderRadius = 50, Text = "fa-eye" }; _visualizarButton.Clicked += (sender, e) => { try { _Mapa.zoomPolyline(true); } catch (Exception erro) { UserDialogs.Instance.Alert(erro.Message, "Erro", "Entendi"); } }; _barraLateralLayout.Children.Add(_visualizarButton); _confirmarButton = new Button { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.End, BackgroundColor = Estilo.Current.PrimaryColor, TextColor = Color.White, BorderRadius = 45, Text = "Confirmar" }; _confirmarButton.Pressed += (sender, e) => { if (_Mapa.Pins.Count() >= 2) { AoSelecionar?.Invoke(this, Polyline); } else { DisplayAlert("Atenção", "Você precisa selecionar pelomenos uma origem e um destino.", "Entendi"); } }; AbsoluteLayout.SetLayoutBounds(_confirmarButton, new Rectangle(0.5, 0.98, 0.5, 0.1)); AbsoluteLayout.SetLayoutFlags(_confirmarButton, AbsoluteLayoutFlags.All); _mainLayout.Children.Add(_confirmarButton); }