Merge pull request 'xaml/my-list' (#34) from xaml/my-list into master
Reviewed-on: ShopNCook/ShopNCook#34pull/36/head
commit
62e47c04d0
@ -0,0 +1,66 @@
|
|||||||
|
<?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.Pages.MyListPage"
|
||||||
|
Title="MyList"
|
||||||
|
BackgroundColor="{StaticResource BackgroundPrimary}"
|
||||||
|
xmlns:views="clr-namespace:ShoopNCook.Views">
|
||||||
|
<Grid
|
||||||
|
RowDefinitions="Auto, *, Auto">
|
||||||
|
<!-- Header label and return button -->
|
||||||
|
<Grid
|
||||||
|
Grid.Row="0"
|
||||||
|
Padding="20, 40, 0, 30"
|
||||||
|
ColumnDefinitions="*"
|
||||||
|
MaximumHeightRequest="60">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
Grid.Column="0"
|
||||||
|
HeightRequest="50"
|
||||||
|
WidthRequest="50"
|
||||||
|
Source="arrow_back.svg"
|
||||||
|
HorizontalOptions="Start"/>
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Grid.Column="0"
|
||||||
|
FontSize="24"
|
||||||
|
TextColor="{StaticResource TextColorPrimary}"
|
||||||
|
Text="My Weekly List"
|
||||||
|
MaximumHeightRequest="60"
|
||||||
|
FontFamily="PoppinsBold"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
VerticalOptions="Center"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Favorite items -->
|
||||||
|
<ScrollView
|
||||||
|
Grid.Row="1">
|
||||||
|
<VerticalStackLayout
|
||||||
|
Padding="30, 0, 30, 0"
|
||||||
|
Spacing="12">
|
||||||
|
|
||||||
|
<views:StoredRecipeView Note="4.5" Title="Spaghetti Bolognese"/>
|
||||||
|
<views:StoredRecipeView Note="3" Title="Chickend Curry"/>
|
||||||
|
<views:StoredRecipeView Note="0.2" Title="Beef Stroganoff"/>
|
||||||
|
<views:StoredRecipeView Note="1.6" Title="Fish And Ships" />
|
||||||
|
<views:StoredRecipeView Note="5" Title="Caesar Salad"/>
|
||||||
|
<views:StoredRecipeView Note="3.5" Title="Vegetables"/>
|
||||||
|
<views:StoredRecipeView Note="4.6" Title="Guacamole"/>
|
||||||
|
<views:StoredRecipeView Note="4" Title="Pad Thai"/>
|
||||||
|
<views:StoredRecipeView Note="3" Title="French Toast"/>
|
||||||
|
<views:StoredRecipeView Note="2" Title="Margherita Pizza"/>
|
||||||
|
</VerticalStackLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<!-- Footer button -->
|
||||||
|
<Border
|
||||||
|
Margin="20, 0, 20, 5"
|
||||||
|
Grid.Row="2"
|
||||||
|
Style="{StaticResource SecondaryBorder}">
|
||||||
|
<Button
|
||||||
|
Style="{StaticResource UserButton}"
|
||||||
|
BackgroundColor="{StaticResource Selected}"
|
||||||
|
Text="Show Ingredient List"/>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</ContentPage>
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace ShoopNCook.Pages;
|
||||||
|
|
||||||
|
public partial class MyListPage : ContentPage
|
||||||
|
{
|
||||||
|
public MyListPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="ShoopNCook.Views.CounterView"
|
||||||
|
x:Name="Counter">
|
||||||
|
<Grid
|
||||||
|
ColumnDefinitions="*, Auto, *">
|
||||||
|
|
||||||
|
<Border
|
||||||
|
Grid.Column="0"
|
||||||
|
Stroke="Transparent"
|
||||||
|
StrokeShape="RoundRectangle 100"
|
||||||
|
BackgroundColor="{StaticResource Selected}">
|
||||||
|
<ImageButton
|
||||||
|
Source="minus.svg"
|
||||||
|
WidthRequest="40"
|
||||||
|
HeightRequest="40"
|
||||||
|
Clicked="OnMinus"/>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<HorizontalStackLayout
|
||||||
|
Grid.Column="1"
|
||||||
|
Spacing="3"
|
||||||
|
Margin="10, 0, 10, 0">
|
||||||
|
<Label
|
||||||
|
x:Name="CountLabel"
|
||||||
|
Text="{Binding Count, Source={x:Reference Counter}}"
|
||||||
|
TextColor="{StaticResource TextColorPrimary}"
|
||||||
|
VerticalTextAlignment="Center"
|
||||||
|
FontFamily="PoppinsMedium"/>
|
||||||
|
|
||||||
|
<Label
|
||||||
|
x:Name="CounterLabel"
|
||||||
|
Text="{Binding CounterText, Source={x:Reference Counter}}"
|
||||||
|
TextColor="{StaticResource TextColorPrimary}"
|
||||||
|
VerticalTextAlignment="Center"
|
||||||
|
FontFamily="PoppinsMedium"/>
|
||||||
|
</HorizontalStackLayout>
|
||||||
|
|
||||||
|
<Border
|
||||||
|
Grid.Column="2"
|
||||||
|
Stroke="Transparent"
|
||||||
|
StrokeShape="RoundRectangle 100"
|
||||||
|
BackgroundColor="{StaticResource Selected}">
|
||||||
|
<ImageButton
|
||||||
|
Source="plus.svg"
|
||||||
|
WidthRequest="40"
|
||||||
|
HeightRequest="40"
|
||||||
|
Clicked="OnPlus"/>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</ContentView>
|
@ -0,0 +1,51 @@
|
|||||||
|
namespace ShoopNCook.Views;
|
||||||
|
|
||||||
|
public partial class CounterView : ContentView
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly BindableProperty CountProperty =
|
||||||
|
BindableProperty.Create(nameof(CountLabel), typeof(uint), typeof(CounterView), default(uint) + 1);
|
||||||
|
|
||||||
|
private readonly BindableProperty CounterLabelProperty =
|
||||||
|
BindableProperty.Create(nameof(CounterLabel), typeof(string), typeof(CounterView), default(string));
|
||||||
|
|
||||||
|
public CounterView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
CountLabel.BindingContext = this;
|
||||||
|
CountLabel.SetBinding(Label.TextProperty, nameof(Count));
|
||||||
|
|
||||||
|
CounterLabel.BindingContext = this;
|
||||||
|
CounterLabel.SetBinding(Label.TextProperty, nameof(CounterText));
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Count
|
||||||
|
{
|
||||||
|
get => (uint)GetValue(CountProperty);
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetValue(CountProperty, value <= 1 ? 1 : uint.Parse(value.ToString()));
|
||||||
|
OnPropertyChanged(nameof(Count));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string CounterText
|
||||||
|
{
|
||||||
|
get => (string)GetValue(CounterLabelProperty);
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetValue(CounterLabelProperty, value);
|
||||||
|
OnPropertyChanged(nameof(CounterText));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPlus(object o, EventArgs e)
|
||||||
|
{
|
||||||
|
Count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMinus(object o, EventArgs e)
|
||||||
|
{
|
||||||
|
Count -= 1;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="ShoopNCook.Views.StoredRecipeView"
|
||||||
|
xmlns:views="clr-namespace:ShoopNCook.Views">
|
||||||
|
|
||||||
|
<Border
|
||||||
|
Style="{StaticResource SecondaryBorderShadow}"
|
||||||
|
StrokeShape="RoundRectangle 30">
|
||||||
|
|
||||||
|
<Grid
|
||||||
|
BackgroundColor="{StaticResource BackgroundSecondary}"
|
||||||
|
Padding="10"
|
||||||
|
MinimumHeightRequest="250"
|
||||||
|
MinimumWidthRequest="150"
|
||||||
|
RowDefinitions="*, Auto">
|
||||||
|
<Border
|
||||||
|
Grid.Row="0"
|
||||||
|
Stroke="Transparent"
|
||||||
|
StrokeShape="RoundRectangle 20"
|
||||||
|
BackgroundColor="AliceBlue">
|
||||||
|
<Grid>
|
||||||
|
<Image />
|
||||||
|
<HorizontalStackLayout
|
||||||
|
x:Name="Stars"
|
||||||
|
VerticalOptions="End"
|
||||||
|
HorizontalOptions="End"
|
||||||
|
Margin="0, 0, 15, 2">
|
||||||
|
<Image
|
||||||
|
WidthRequest="15"
|
||||||
|
Source="star_full.svg"/>
|
||||||
|
<Image
|
||||||
|
WidthRequest="15"
|
||||||
|
Source="star_full.svg"/>
|
||||||
|
<Image
|
||||||
|
WidthRequest="15"
|
||||||
|
Source="star_full.svg"/>
|
||||||
|
<Image
|
||||||
|
WidthRequest="15"
|
||||||
|
Source="star_full.svg"/>
|
||||||
|
<Image
|
||||||
|
WidthRequest="15"
|
||||||
|
Source="star_full.svg"/>
|
||||||
|
</HorizontalStackLayout>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<VerticalStackLayout
|
||||||
|
HorizontalOptions="Start"
|
||||||
|
Grid.Row="1">
|
||||||
|
<Label
|
||||||
|
TextColor="{StaticResource TextColorPrimary}"
|
||||||
|
x:Name="TitleLabel"/>
|
||||||
|
<Grid></Grid>
|
||||||
|
<views:CounterView CounterText="pers"/>
|
||||||
|
</VerticalStackLayout>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</ContentView>
|
@ -0,0 +1,41 @@
|
|||||||
|
namespace ShoopNCook.Views;
|
||||||
|
|
||||||
|
public partial class StoredRecipeView : ContentView
|
||||||
|
{
|
||||||
|
|
||||||
|
public StoredRecipeView() : this(5, "Title")
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public StoredRecipeView(float note, string title)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
Note = note;
|
||||||
|
Title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float Note
|
||||||
|
{
|
||||||
|
set => SetNote(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Title
|
||||||
|
{
|
||||||
|
set => TitleLabel.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…
Reference in new issue