Skip to content

Commit

Permalink
DisplayAlert
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Ángel Barrera committed Sep 9, 2021
1 parent 4551bc8 commit 9c98656
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 68 deletions.
34 changes: 22 additions & 12 deletions RickAndMortySample/RickAndMortySample/Pages/EpisodesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,29 @@
SelectedItem="{Binding SelectedEpisode}">
<CollectionView.ItemTemplate>
<DataTemplate>
<HorizontalStackLayout Spacing="8" Margin="4" Padding="8,0">
<VerticalStackLayout
Spacing="4"
Margin="6"
Padding="8,0">
<HorizontalStackLayout
Spacing="8" >
<Label
Text="{Binding episode}"
TextColor="Black"
FontSize="18"
FontAttributes="Bold"/>
<Label
Text="{Binding Name}"
TextColor="Black"
FontSize="18"
FontAttributes="Bold"/>
</HorizontalStackLayout>

<Label
Text="{Binding episode}"
TextColor="Black"
FontSize="18"
FontAttributes="Bold"/>
<Label
Text="{Binding Name}"
TextColor="Black"
FontSize="18"
FontAttributes="Bold"/>
</HorizontalStackLayout>

Text="{Binding Air_date}"
TextColor="Gray"
GridLayout.Row="1"/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Character SelectedCharacter
{
selectedCharacter = value;
OnPropertyChanged();
NavigateToCharacterDetail();
ShowAlert();
}
}

Expand All @@ -46,14 +46,14 @@ private async void FetchAsync()
Characters = await rickAndMortyService.GetCharactersAsync();
}

private async void NavigateToCharacterDetail()
private async void ShowAlert()
{
if (selectedCharacter == null)
{
return;
}

await App.Current.MainPage.DisplayAlert("Nice!!", $"You select {selectedCharacter.Name}", "Close");
await App.Current.MainPage.DisplayAlert("Nice!!", $"You tap {selectedCharacter.Name}", "Close");

SelectedCharacter = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Episode SelectedEpisode
{
selectedEpisode = value;
OnPropertyChanged();
NavigateToEpisode();
ShowAlert();
}
}

Expand All @@ -46,14 +46,14 @@ private async void FetchAsync()
Episodes = await episodesService.GetEpisodesAsync();
}

private void NavigateToEpisode()
private async void ShowAlert()
{
if (SelectedEpisode == null)
{
return;
}

//App.Current.MainPage.Navigation.PushAsync(new EpisodeDetailPage(selectedEpisode));
await App.Current.MainPage.DisplayAlert("Nice!!", $"You tap {selectedEpisode.episode} {selectedEpisode.Name}", "Close");

SelectedEpisode = null;
}
Expand Down
24 changes: 0 additions & 24 deletions RickAndMortySample/RickAndMortySample/Views/NavView.xaml

This file was deleted.

26 changes: 0 additions & 26 deletions RickAndMortySample/RickAndMortySample/Views/NavView.xaml.cs

This file was deleted.

0 comments on commit 9c98656

Please sign in to comment.