Merge pull request 'xaml/favorites' (#27) from xaml/favorites into master

Reviewed-on: ShopNCook/ShopNCook#27
pull/28/head^2
Maxime BATISTA 2 years ago
commit d3b0799ca3

@ -28,9 +28,15 @@
Title="Register Page" Title="Register Page"
ContentTemplate="{DataTemplate views:RegisterPage}" ContentTemplate="{DataTemplate views:RegisterPage}"
Route="Register" /> Route="Register" />
<ShellContent <ShellContent
Title="Recipe Page" Title="Recipe Page"
ContentTemplate="{DataTemplate views:RecipePage}" ContentTemplate="{DataTemplate views:RecipePage}"
Route="Recipe" /> Route="Recipe" />
<ShellContent
Title="Favorites Page"
ContentTemplate="{DataTemplate views:FavoritesPage}"
Route="Favorites" />
</TabBar> </TabBar>
</Shell> </Shell>

@ -0,0 +1,104 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>ShoopNCook</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>ShoopNCook</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.companyname.shoopncook</ApplicationId>
<ApplicationIdGuid>bf17e1fe-a722-42f6-a24d-3327d351c924</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Fonts\Poppins-Bold.ttf" />
<None Remove="Resources\Fonts\Poppins-Medium.ttf" />
<None Remove="Resources\Images\email_icon.svg" />
<None Remove="Resources\Images\facebook_logo.svg" />
<None Remove="Resources\Images\hearth_off.svg" />
<None Remove="Resources\Images\hearth_on.svg" />
<None Remove="Resources\Images\minus.svg" />
<None Remove="Resources\Images\password_icon.svg" />
<None Remove="Resources\Images\plus.svg" />
<None Remove="Resources\Images\search_options.svg" />
<None Remove="Resources\Images\star_empty.svg" />
<None Remove="Resources\Images\star_full.svg" />
<None Remove="Resources\Images\user.svg" />
<None Remove="Resources\Images\visibility_off.svg" />
<None Remove="Resources\Images\visibility_on.svg" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Fonts\arrow_back_ios_FILL0_wght400_GRAD200_opsz48.svg" />
<None Remove="Resources\Images\default_profile_picture.png" />
</ItemGroup>
<ItemGroup>
<MauiFont Include="Resources\Images\arrow_back.svg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Views\IngredientView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\ProfilePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\RecipePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\RecipeView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\RegisterPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\SearchPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties XamarinHotReloadDebuggerTimeoutExceptionShoopNCookHideInfoBar="True" XamarinHotReloadUnhandledDeviceExceptionShoopNCookHideInfoBar="True" /></VisualStudio></ProjectExtensions>
</Project>

@ -49,18 +49,10 @@
<ItemGroup> <ItemGroup>
<None Remove="Resources\Fonts\Poppins-Bold.ttf" /> <None Remove="Resources\Fonts\Poppins-Bold.ttf" />
<None Remove="Resources\Fonts\Poppins-Medium.ttf" />
<None Remove="Resources\Images\email_icon.svg" /> <None Remove="Resources\Images\email_icon.svg" />
<None Remove="Resources\Images\facebook_logo.svg" /> <None Remove="Resources\Images\facebook_logo.svg" />
<None Remove="Resources\Images\hearth_off.svg" />
<None Remove="Resources\Images\hearth_on.svg" />
<None Remove="Resources\Images\minus.svg" />
<None Remove="Resources\Images\password_icon.svg" /> <None Remove="Resources\Images\password_icon.svg" />
<None Remove="Resources\Images\plus.svg" />
<None Remove="Resources\Images\search_options.svg" /> <None Remove="Resources\Images\search_options.svg" />
<None Remove="Resources\Images\star_empty.svg" />
<None Remove="Resources\Images\star_full.svg" />
<None Remove="Resources\Images\user.svg" />
<None Remove="Resources\Images\visibility_off.svg" /> <None Remove="Resources\Images\visibility_off.svg" />
<None Remove="Resources\Images\visibility_on.svg" /> <None Remove="Resources\Images\visibility_on.svg" />
</ItemGroup> </ItemGroup>
@ -79,21 +71,15 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<MauiXaml Update="Views\IngredientView.xaml"> <MauiXaml Update="Views\FavoritesPage.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
<MauiXaml Update="Views\ProfilePage.xaml"> <MauiXaml Update="Views\ProfilePage.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
<MauiXaml Update="Views\RecipePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\RecipeView.xaml"> <MauiXaml Update="Views\RecipeView.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
<MauiXaml Update="Views\RegisterPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\SearchPage.xaml"> <MauiXaml Update="Views\SearchPage.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ShoopNCook.Views.FavoritesPage"
Title="FavoritesPage"
xmlns:views="clr-namespace:ShoopNCook.Views"
BackgroundColor="{StaticResource BackgroundPrimary}">
<Grid
RowDefinitions="Auto, *">
<!-- Header label and return button -->
<Grid
Grid.Row="0"
ColumnDefinitions="Auto, *"
Padding="10, 20, 0, 30">
<ImageButton
Grid.Column="0"
HeightRequest="50"
WidthRequest="50"
Source="arrow_back.svg"/>
<Label
Grid.Column="1"
FontSize="24"
TextColor="{StaticResource TextColorPrimary}"
Text="Favorites recipes"
FontFamily="PoppinsBold"
HorizontalOptions="Center"/>
</Grid>
<!-- Favorite items -->
<ScrollView
Grid.Row="1">
<FlexLayout
JustifyContent="Center"
AlignItems="Start"
AlignContent="Start"
Direction="Row"
Wrap="Wrap">
<views:RecipeView Margin="5" Note="4.5" Title="Spaghetti Bolognese" Subtitle="30 min"/>
<views:RecipeView Margin="5" Note="3" Title="Chickend Curry" Subtitle="45 min"/>
<views:RecipeView Margin="5" Note="0.2" Title="Beef Stroganoff" Subtitle="10 min"/>
<views:RecipeView Margin="5" Note="1.6" Title="Fish And Ships" Subtitle="15 min"/>
<views:RecipeView Margin="5" Note="5" Title="Caesar Salad" Subtitle="20 min"/>
<views:RecipeView Margin="5" Note="3.5" Title="Vegetables" Subtitle="60 min"/>
<views:RecipeView Margin="5" Note="4.6" Title="Guacamole" Subtitle="90 min"/>
<views:RecipeView Margin="5" Note="4" Title="Pad Thai" Subtitle="10 min"/>
<views:RecipeView Margin="5" Note="3" Title="French Toast" Subtitle="5 min"/>
<views:RecipeView Margin="5" Note="2" Title="Margherita Pizza" Subtitle="2 min"/>
</FlexLayout>
</ScrollView>
</Grid>
</ContentPage>

@ -0,0 +1,9 @@
namespace ShoopNCook.Views;
public partial class FavoritesPage : ContentPage
{
public FavoritesPage()
{
InitializeComponent();
}
}

@ -3,13 +3,13 @@ namespace ShoopNCook.Views;
public partial class IngredientView : ContentView public partial class IngredientView : ContentView
{ {
public static readonly BindableProperty NameProperty = private readonly BindableProperty NameProperty =
BindableProperty.Create(nameof(Name), typeof(string), typeof(IngredientView), default(string)); BindableProperty.Create(nameof(Name), typeof(string), typeof(IngredientView), default(string));
public static readonly BindableProperty QuantityProperty = private readonly BindableProperty QuantityProperty =
BindableProperty.Create(nameof(Quantity), typeof(float), typeof(IngredientView), default(float)); BindableProperty.Create(nameof(Quantity), typeof(float), typeof(IngredientView), default(float));
public static readonly BindableProperty UnitProperty = private readonly BindableProperty UnitProperty =
BindableProperty.Create(nameof(Unit), typeof(string), typeof(IngredientView), default(string)); BindableProperty.Create(nameof(Unit), typeof(string), typeof(IngredientView), default(string));
public string Name public string Name

@ -108,26 +108,26 @@
x:Name="Stars" x:Name="Stars"
Spacing="2" Spacing="2"
Margin="10, 0, 0, 0"> Margin="10, 0, 0, 0">
<ImageButton <ImageButton
WidthRequest="30" WidthRequest="30"
Command="{Binding StarCommand, Source={x:Reference RecipeViewPage}}" Command="{Binding StarCommand, Source={x:Reference RecipeViewPage}}"
CommandParameter="1"/> CommandParameter="1"/>
<ImageButton <ImageButton
WidthRequest="30" WidthRequest="30"
Command="{Binding StarCommand, Source={x:Reference RecipeViewPage}}" Command="{Binding StarCommand, Source={x:Reference RecipeViewPage}}"
CommandParameter="2"/> CommandParameter="2"/>
<ImageButton <ImageButton
WidthRequest="30" WidthRequest="30"
Command="{Binding StarCommand, Source={x:Reference RecipeViewPage}}" Command="{Binding StarCommand, Source={x:Reference RecipeViewPage}}"
CommandParameter="3"/> CommandParameter="3"/>
<ImageButton <ImageButton
WidthRequest="30" WidthRequest="30"
Command="{Binding StarCommand, Source={x:Reference RecipeViewPage}}" Command="{Binding StarCommand, Source={x:Reference RecipeViewPage}}"
CommandParameter="4"/> CommandParameter="4"/>
<ImageButton <ImageButton
WidthRequest="30" WidthRequest="30"
Command="{Binding StarCommand, Source={x:Reference RecipeViewPage}}" Command="{Binding StarCommand, Source={x:Reference RecipeViewPage}}"
CommandParameter="5"/> CommandParameter="5"/>
</HorizontalStackLayout> </HorizontalStackLayout>
<Border <Border
Margin="12, 0, 0, 0" Margin="12, 0, 0, 0"

@ -19,16 +19,39 @@
Stroke="Transparent" Stroke="Transparent"
StrokeShape="RoundRectangle 20" StrokeShape="RoundRectangle 20"
BackgroundColor="AliceBlue"> BackgroundColor="AliceBlue">
<Image/> <Grid>
<Image />
<HorizontalStackLayout
x:Name="Stars"
VerticalOptions="End"
HorizontalOptions="End"
Margin="0, 0, 15, 2">
<Image
WidthRequest="10"
Source="star_full.svg"/>
<Image
WidthRequest="10"
Source="star_full.svg"/>
<Image
WidthRequest="10"
Source="star_full.svg"/>
<Image
WidthRequest="10"
Source="star_full.svg"/>
<Image
WidthRequest="10"
Source="star_full.svg"/>
</HorizontalStackLayout>
</Grid>
</Border> </Border>
<VerticalStackLayout Grid.Row="1"> <VerticalStackLayout Grid.Row="1">
<Label <Label
TextColor="{StaticResource TextColorPrimary}" TextColor="{StaticResource TextColorPrimary}"
Text="Recipe Name"/> x:Name="TitleLabel"/>
<Label <Label
TextColor="{StaticResource TextColorSecondary}" TextColor="{StaticResource TextColorSecondary}"
Text="Preparation time"/> x:Name="SubtitleLabel"/>
</VerticalStackLayout> </VerticalStackLayout>
</Grid> </Grid>
</Border> </Border>

@ -2,8 +2,46 @@ namespace ShoopNCook.Views;
public partial class RecipeView : ContentView public partial class RecipeView : ContentView
{ {
public RecipeView()
public RecipeView(): this(5, "Title", "Subtitle")
{}
public RecipeView(float note, string title, string subtitle)
{ {
InitializeComponent(); InitializeComponent();
Note = note;
Title = title;
Subtitle = subtitle;
} }
public float Note
{
set => SetNote(value);
}
public string Title
{
set => TitleLabel.Text = value;
}
public string Subtitle
{
set => SubtitleLabel.Text = value;
}
private void SetNote(float note)
{
int i = 1;
foreach (Image img in Stars.Children)
{
if (i <= note)
{
img.Opacity = 0;
i++;
}
else img.Opacity = 1;
}
}
} }
Loading…
Cancel
Save