Skip to content

Instantly share code, notes, and snippets.

@brunoportess
Created November 4, 2017 13:13
Show Gist options
  • Save brunoportess/9f7f5edffd84e758c650b6d610120d03 to your computer and use it in GitHub Desktop.
Save brunoportess/9f7f5edffd84e758c650b6d610120d03 to your computer and use it in GitHub Desktop.
Meu switch tem o Toogle na propriedade EnviaOrcamento do meu objeto e essa propriedade é booleana (bool)
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
x:Class="Cliente.Views.Orcamento.OrcamentoEmpresas"
Title="Enviar para...">
<ListView
x:Name="ListCompanies"
CachingStrategy="RecycleElement"
ItemsSource="{Binding ListCompanies}"
SeparatorVisibility="None"
HasUnevenRows="true">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout
Orientation="Horizontal"
Margin="5"
BackgroundColor="{Binding BgColor}">
<Image
WidthRequest="100"
HeightRequest="100"
Aspect="AspectFill"
Source="{Binding UrlImagem, StringFormat='http://tcc.devsistemas.com.br{0}'}"/>
<StackLayout
Orientation="Vertical"
HorizontalOptions="FillAndExpand"
Margin="15,0,0,0">
<Label
HorizontalOptions="Center"
FontAttributes="Bold"
VerticalTextAlignment="Center"
TextColor="{Binding TextColor}"
Text="{Binding Nome}"
FontSize="{Binding FontSize}"/>
<StackLayout
Orientation="Horizontal">
<Image
VerticalOptions="Center"
WidthRequest="100"
HeightRequest="30"
Source="star.png" />
<Label
Text="{Binding Nota}"
VerticalTextAlignment="Center"/>
</StackLayout>
</StackLayout>
<Switch IsToggled="{Binding EnviaOrcamento}"></Switch>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
private async void ExecuteEnviaOrcamentoCommand()
{
/*
ASSIM QUE CLICO NO COMMAND PRA "FILTRAR" EU CAPTURO SOMENTE DA MINHA LISTA OS ITEMS ONDE A PROPRIEDADE
"ENVIAORCAMENTO" QUE COMO DISSE, É BOOLEANA, TIVER SIDO MARCADA/ATIVADA
*/
var empresas = ListCompanies.Where(l => l.EnviaOrcamento).Select(l => l.Id);
var enumerable = empresas as int[] ?? empresas.ToArray();
if (!enumerable.Any())
{
await _dialogService.DisplayAlertAsync("Oops", "Selecione alguma empresa", "OK");
return;
}
var obj = new
{
usuarionome = Nome,
mensagem = Mensagem,
prazo = Prazo,
valormaximo = ValorMaximo,
empresas = enumerable,
usuarioemail = Settings.UserEmailSettings
};
await _restOrcamento.PostEnviaOrcamento(obj);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment