Skip to content

Commit

Permalink
Change restaurants to food places
Browse files Browse the repository at this point in the history
  • Loading branch information
Mantas330BJ committed Sep 29, 2021
1 parent 5fc8069 commit 4ff6348
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Wasted/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
</StackLayout>
</DataTemplate>

<DataTemplate x:Key="RestaurantsCollectionViewTemplate">
<DataTemplate x:Key="FoodPlacesCollectionViewTemplate">
<StackLayout>
<Frame Style="{StaticResource CardView}">
<StackLayout>
Expand Down
4 changes: 2 additions & 2 deletions Wasted/Dummy API/HashMaps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public static Dictionary<int, FoodPlace> FoodPlacesHashMap
}

/// <summary>
/// Adds restaurants from which deals came from by using hashmaps.
/// Adds food places from which deals came from by using hashmaps.
/// !!! Deals must be created before for this function to work
/// </summary>
public static void AddRestaurantsToDeals(List<FoodPlace> AllFoodPlaces)
public static void AddFoodPlacesToDeals(List<FoodPlace> AllFoodPlaces)
{
foreach (FoodPlace foodPlace in AllFoodPlaces)
{
Expand Down
20 changes: 10 additions & 10 deletions Wasted/HomePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<ScrollView>
<StackLayout>

<!--#region Nearby restaurants-->
<!--#region Nearby food places-->

<Label Text="Restaurants near you" Style="{StaticResource SectionTitle}"></Label>
<Label Text="Food places near you" Style="{StaticResource SectionTitle}"></Label>

<CollectionView x:Name="nearbyRestaurantsCollectionView" Style="{StaticResource HorizontalCollectionView}"
SelectionChanged="RestaurantsCollectionViewListSelectionChanged"
ItemTemplate="{StaticResource RestaurantsCollectionViewTemplate}">
<CollectionView x:Name="nearbyFoodPlacesCollectionView" Style="{StaticResource HorizontalCollectionView}"
SelectionChanged="FoodPlacesCollectionViewListSelectionChanged"
ItemTemplate="{StaticResource FoodPlacesCollectionViewTemplate}">

<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Horizontal" />
Expand Down Expand Up @@ -41,13 +41,13 @@

<!--#endregion-->

<!--#region Popular restaurants-->
<!--#region Popular food places-->

<Label Text="Popular restaurants" Style="{StaticResource SectionTitle}"></Label>
<Label Text="Popular food places" Style="{StaticResource SectionTitle}"></Label>

<CollectionView x:Name="popularRestaurantsCollectionView" Style="{StaticResource HorizontalCollectionView}"
SelectionChanged="RestaurantsCollectionViewListSelectionChanged"
ItemTemplate="{StaticResource RestaurantsCollectionViewTemplate}">
<CollectionView x:Name="popularFoodPlacesCollectionView" Style="{StaticResource HorizontalCollectionView}"
SelectionChanged="FoodPlacesCollectionViewListSelectionChanged"
ItemTemplate="{StaticResource FoodPlacesCollectionViewTemplate}">

<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Horizontal" />
Expand Down
14 changes: 7 additions & 7 deletions Wasted/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,32 @@ public HomePage()
}

/// <summary>
/// Puts restaurants from json file to collectionView.
/// Puts food places from json file to collectionView.
/// </summary>
protected override void OnAppearing()
{
base.OnAppearing();
AllFoodPlaces = new List<FoodPlace>(DummyDataProvider.GetFoodPlacesList());
AllDeals = new List<Deal>(DummyDataProvider.GetDealsList());
HashMaps.AddRestaurantsToDeals(AllFoodPlaces);
HashMaps.AddFoodPlacesToDeals(AllFoodPlaces);

nearbyRestaurantsCollectionView.ItemsSource = AllFoodPlaces;
nearbyFoodPlacesCollectionView.ItemsSource = AllFoodPlaces;
specialOffersCollectionView.ItemsSource = AllDeals;

popularRestaurantsCollectionView.ItemsSource = AllFoodPlaces;
popularFoodPlacesCollectionView.ItemsSource = AllFoodPlaces;
}

/// <summary>
/// Function is called when user selects food place from nearby restaurants collectionView. Called from xaml file.
/// Function is called when user selects food place from nearby food places collectionView. Called from xaml file.
/// </summary>
void RestaurantsCollectionViewListSelectionChanged(object sender, SelectionChangedEventArgs e)
void FoodPlacesCollectionViewListSelectionChanged(object sender, SelectionChangedEventArgs e)
{
FoodPlace selectedPlace = e.CurrentSelection.FirstOrDefault() as FoodPlace;
Navigation.PushAsync(new FoodPlacesPage(selectedPlace));
}

/// <summary>
/// Function is called when user selects deal from nearby restaurants collectionView. Called from xaml file.
/// Function is called when user selects deal from nearby food places collectionView. Called from xaml file.
/// </summary>
void DealsCollectionViewListSelectionChanged(object sender, SelectionChangedEventArgs e)
{
Expand Down
4 changes: 2 additions & 2 deletions Wasted/SearchPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public SearchPage()
}

/// <summary>
/// Puts restaurants from json file to collectionView.
/// Puts food places from json file to collectionView.
/// </summary>
protected override void OnAppearing()
{
base.OnAppearing();
AllFoodPlaces = new List<FoodPlace>(DummyDataProvider.GetFoodPlacesList());
DummyDataProvider.GetDealsList(); //Adds deals to hashmap.
HashMaps.AddRestaurantsToDeals(AllFoodPlaces);
HashMaps.AddFoodPlacesToDeals(AllFoodPlaces);

allPlacesCollectionView.ItemsSource = AllFoodPlaces;
}
Expand Down

0 comments on commit 4ff6348

Please sign in to comment.