Przeprowadzka
This commit is contained in:
Executable
+19
@@ -0,0 +1,19 @@
|
||||
<?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="HomePantry.Views.AddProductPage">
|
||||
<VerticalStackLayout Spacing="12" Padding="20">
|
||||
<Label FontSize="24" FontAttributes="Bold" Text="Nowy produkt w spiżarni"/>
|
||||
<Entry Placeholder="np. Mleko 3,2%" x:Name="entNazwa" />
|
||||
<Entry Placeholder="np. 2" Keyboard="Numeric" x:Name="entIlosc" />
|
||||
<Entry Placeholder="np. szt., 1, kg" x:Name="entJednostka" />
|
||||
<Picker x:Name="pickKategoria" Title="Wybierz kategorię" />
|
||||
<DatePicker x:Name="dpWaznosc" />
|
||||
<Editor AutoSize="TextChanges" HeightRequest="80" Placeholder="np. przechowywać w lodówce" x:Name="edtUwagi" />
|
||||
<HorizontalStackLayout>
|
||||
<Switch x:Name="swOtwarte" />
|
||||
<Label Text="Produkt otwarty" />
|
||||
</HorizontalStackLayout>
|
||||
<Button x:Name="btnDodaj" Text="Dodaj do spiżarni" />
|
||||
</VerticalStackLayout>
|
||||
</ContentPage>
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
using System.Windows.Input;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.ObjectModel;
|
||||
using Microsoft.Maui.Controls;
|
||||
|
||||
namespace HomePantry.Views;
|
||||
|
||||
public partial class AddProductPage : ContentPage
|
||||
{
|
||||
|
||||
public ICommand ButtonCommand { get; }
|
||||
public AddProductPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
pickKategoria.ItemsSource = new List<string>
|
||||
{
|
||||
"Nabiał", "Pieczywo", "Mięso i wędliny", "Warzywa i owoce", "Napoje", "Inne"
|
||||
};
|
||||
dpWaznosc.MinimumDate = DateTime.Now;
|
||||
|
||||
ButtonCommand = new Command(async() => await btnDodaj_Clicked());
|
||||
btnDodaj.Command = ButtonCommand;
|
||||
}
|
||||
|
||||
private async Task btnDodaj_Clicked()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(entNazwa.Text) && !string.IsNullOrEmpty(entIlosc.Text) && !string.IsNullOrEmpty(entJednostka.Text))
|
||||
{
|
||||
string otwarty = swOtwarte.IsToggled ? "Tak" : "Nie";
|
||||
await DisplayAlertAsync("Spiżarnia", $"Produkt: {entNazwa.Text}\nIlość: {entIlosc.Text} {entJednostka.Text}\nKategoria: {pickKategoria.SelectedItem?.ToString() ?? "brak"}\nWażność: {dpWaznosc.Date}\nOtwarty: {otwarty}\nUwagi: {edtUwagi.Text ?? "brak"}", "OK");
|
||||
}
|
||||
else
|
||||
{
|
||||
await DisplayAlertAsync("Spiżarnia", "Należy uzupełnić wszystkie wymagane pola!", "OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
<?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="HomePantry.Views.CategoriesPage"
|
||||
Title="Kategorie">
|
||||
<VerticalStackLayout Spacing="10" Padding="20">
|
||||
<Label Text="Kategorie produktów" FontSize="24" FontAttributes="Bold" />
|
||||
<Button Text="🥛 Mleko 3,2% - Nabiał" Clicked="OnProductClicked" ClassId="mleko" />
|
||||
<Button Text="🍞 Chleb żytni - Pieczywo" Clicked="OnProductClicked" ClassId="chleb" />
|
||||
<Button Text="🥩 Pierś z kurczaka - Mięso" Clicked="OnProductClicked" ClassId="kurczak" />
|
||||
<Button Text="🍎 Jabłka Gala - Owoce" Clicked="OnProductClicked" ClassId="jablka" />
|
||||
</VerticalStackLayout>
|
||||
</ContentPage>
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
namespace HomePantry.Views;
|
||||
|
||||
public partial class CategoriesPage : ContentPage
|
||||
{
|
||||
public CategoriesPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void OnProductClicked(object sender, EventArgs e)
|
||||
{
|
||||
var button = (Button)sender;
|
||||
await Shell.Current.GoToAsync($"productdetail?name={button.ClassId}");
|
||||
}
|
||||
}
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
<?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="HomePantry.Views.Controls.ProductCard"
|
||||
x:Name="this">
|
||||
<Border StrokeShape="RoundRectangle 10" Padding="10" Margin="0,5">
|
||||
<Grid RowDefinitions="auto, auto, auto">
|
||||
<BoxView Color="{StaticResource PantryGreen}" HeightRequest="40" />
|
||||
<Label Text="{Binding ProductName, Source={x:Reference this}}" TextColor="White" FontAttributes="Bold" FontSize="16" VerticalOptions="Center" Margin="12,0" />
|
||||
<Label Grid.Row="1" Text="{Binding ProductInfo, Source={x:Reference this}}" FontSize="14" Margin="12,8,12,4" />
|
||||
<Label Grid.Row="2" Text="{Binding ExpiryDate, Source={x:Reference this}}" TextColor="Gray" FontSize="12" Margin="12,0,12,8" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</ContentView>
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
namespace HomePantry.Views.Controls;
|
||||
|
||||
public partial class ProductCard : ContentView
|
||||
{
|
||||
public static readonly BindableProperty ProductNameProperty = BindableProperty.Create(nameof(ProductName), typeof(string), typeof(ProductCard), string.Empty);
|
||||
public string ProductName
|
||||
{
|
||||
get => (string)GetValue(ProductNameProperty);
|
||||
set => SetValue(ProductNameProperty, value);
|
||||
}
|
||||
public static readonly BindableProperty ProductInfoProperty = BindableProperty.Create(nameof(ProductInfo), typeof(string), typeof(ProductCard), string.Empty);
|
||||
public string ProductInfo
|
||||
{
|
||||
get => (string)GetValue(ProductInfoProperty);
|
||||
set => SetValue(ProductInfoProperty, value);
|
||||
}
|
||||
public static readonly BindableProperty ExpiryDateProperty = BindableProperty.Create(nameof(ExpiryDate), typeof(string), typeof(ProductCard), string.Empty);
|
||||
public string ExpiryDate
|
||||
{
|
||||
get => (string)GetValue(ExpiryDateProperty);
|
||||
set => SetValue(ExpiryDateProperty, value);
|
||||
}
|
||||
|
||||
public ProductCard()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
<?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="HomePantry.Views.MainPage">
|
||||
|
||||
<ScrollView>
|
||||
<VerticalStackLayout
|
||||
Padding="30,0"
|
||||
Spacing="25">
|
||||
<Image
|
||||
Source="dotnet_bot.png"
|
||||
HeightRequest="185"
|
||||
Aspect="AspectFit"
|
||||
SemanticProperties.Description="dot net bot in a submarine number ten" />
|
||||
|
||||
<Label
|
||||
Text="Hello, World!"
|
||||
Style="{StaticResource Headline}"
|
||||
SemanticProperties.HeadingLevel="Level1" />
|
||||
|
||||
<Label
|
||||
Text="Welcome to .NET Multi-platform App UI"
|
||||
Style="{StaticResource SubHeadline}"
|
||||
SemanticProperties.HeadingLevel="Level2"
|
||||
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
|
||||
|
||||
<Button
|
||||
x:Name="CounterBtn"
|
||||
Text="Click me"
|
||||
SemanticProperties.Hint="Counts the number of times you click"
|
||||
Clicked="OnCounterClicked"
|
||||
HorizontalOptions="Fill" />
|
||||
</VerticalStackLayout>
|
||||
</ScrollView>
|
||||
|
||||
</ContentPage>
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
namespace HomePantry.Views;
|
||||
|
||||
public partial class MainPage : ContentPage
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnCounterClicked(object? sender, EventArgs e)
|
||||
{
|
||||
count++;
|
||||
|
||||
if (count == 1)
|
||||
CounterBtn.Text = $"Clicked {count} time";
|
||||
else
|
||||
CounterBtn.Text = $"Clicked {count} times";
|
||||
|
||||
SemanticScreenReader.Announce(CounterBtn.Text);
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
<?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"
|
||||
xmlns:controls="clr-namespace:HomePantry.Views.Controls"
|
||||
x:Class="HomePantry.Views.PantryPage">
|
||||
<ScrollView>
|
||||
<VerticalStackLayout>
|
||||
<Grid ColumnDefinitions="*, *" RowDefinitions="auto, auto, auto, auto, auto" Padding="20" RowSpacing="15">
|
||||
<Label Text="{Binding AppTitle}" FontSize="28" FontAttributes="Bold" Grid.ColumnSpan="2" HorizontalTextAlignment="Center" />
|
||||
<Image Source="dotnet_bot.png" Grid.Column="0" Grid.Row="1" WidthRequest="100" Aspect="AspectFit" />
|
||||
<Label Text="{Binding Subtitle}" Grid.Row="1" Grid.Column="1" FontSize="16" VerticalOptions="Center" />
|
||||
<Label Text="{Binding CurrentDate}" Grid.Row="2" Grid.ColumnSpan="2" />
|
||||
<Label Text="{Binding TotalProducts, StringFormat='Produktów: {0}'}" Grid.Row="3" />
|
||||
<Label Text="{Binding ExpiredProducts, StringFormat='Przeterminowanych: {0}'}" Grid.Row="3" Grid.Column="1" />
|
||||
<Button Text="Dodaj pierwszy produkt" Grid.ColumnSpan="2" Grid.Row="4" x:Name="Przycisk" Clicked="Button_Clicked" />
|
||||
</Grid>
|
||||
<controls:ProductCard ProductName="🥛 Mleko 3,2%" ProductInfo="2 l | Nabiał" ExpiryDate="Ważność: 12.03.2026" />
|
||||
<controls:ProductCard ProductName="🍞 Chleb żytni" ProductInfo="1 szt. | Pieczywo" ExpiryDate="Ważność: 10.03.2026" />
|
||||
<controls:ProductCard ProductName="🥩 Pierś z kurczaka" ProductInfo="0.5 kg | Mięso i wędliny" ExpiryDate="Ważność: 08.03.2026" />
|
||||
<controls:ProductCard ProductName="🍎 Jabłka Gala" ProductInfo="1 kg | Warzywa i owoce" ExpiryDate="Ważność: 20.03.2026" />
|
||||
</VerticalStackLayout>
|
||||
</ScrollView>
|
||||
</ContentPage>
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
using System.Windows.Input;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.ObjectModel;
|
||||
using Microsoft.Maui.Controls;
|
||||
using HomePantry.ViewModels;
|
||||
|
||||
namespace HomePantry.Views;
|
||||
|
||||
public partial class PantryPage : ContentPage
|
||||
{
|
||||
public PantryPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
BindingContext = new PantryInfo();
|
||||
}
|
||||
|
||||
private async void Button_Clicked(object? sender, EventArgs e)
|
||||
{
|
||||
await DisplayAlertAsync("Spiżarnia", "Funkcja dodawania produktów zostanie zaimplementowana w kolejnym zadaniu.", "OK");
|
||||
}
|
||||
}
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
<?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="HomePantry.Views.ProductDetailPage"
|
||||
Title="Szczegóły produktu">
|
||||
<Border StrokeShape="RoundRectangle 12" Margin="15" Padding="20" Shadow="">
|
||||
<Grid RowDefinitions="*,*,*,*,*,*,*">
|
||||
<Label FontSize="22" FontAttributes="Bold" x:Name="lblNazwa" />
|
||||
<Label Grid.Row="1" x:Name="lblKategoria" />
|
||||
<Label Grid.Row="2" x:Name="lblIlosc" />
|
||||
<Label Grid.Row="3" x:Name="lblWaznosc" />
|
||||
<Label Grid.Row="4" x:Name="lblStatus" />
|
||||
<Label Grid.Row="5" x:Name="lblUwagi" LineBreakMode="WordWrap" />
|
||||
<Button Text="Powrót do kategorii" Margin="0,20,0,0" Clicked="Button_Clicked" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</ContentPage>
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
namespace HomePantry.Views;
|
||||
|
||||
[QueryProperty(nameof(ProductName), "name")]
|
||||
public partial class ProductDetailPage : ContentPage
|
||||
{
|
||||
private readonly Dictionary<string, (string Nazwa, string Kategoria, string Ilosc, string Waznosc, string Status, string Uwagi)> _products = new()
|
||||
{
|
||||
["mleko"] = ("Mleko 3,2%", "Nabiał", "2 l", "12.03.2026", "Otwarty", "Przechowywać w lodówce, po otwarciu zużyć w 3 dni"),
|
||||
["chleb"] = ("Chleb żytni", "Pieczywo", "1 szt.", "10.03.2026", "Otwarty", "Przechowywać w chlebaku"),
|
||||
["kurczak"] = ("Pierś z kurczaka", "Mięso i wędliny", "0.5 kg", "08.03.2026", "Zamknięty", "Przechowywać w zamrażarce"),
|
||||
["jablka"] = ("Jabłka Gala", "Warzywa i owoce", "1 kg", "20.03.2026", "-", "Przechowywać w suchym, chłodnym miejscu")
|
||||
};
|
||||
private string productName;
|
||||
public string ProductName
|
||||
{
|
||||
get => productName;
|
||||
set
|
||||
{
|
||||
productName = value;
|
||||
if(_products.TryGetValue(value, out var p))
|
||||
{
|
||||
lblNazwa.Text = p.Nazwa;
|
||||
lblKategoria.Text = $"Kategoria: {p.Kategoria}";
|
||||
lblIlosc.Text = $"Ilość: {p.Ilosc}";
|
||||
lblWaznosc.Text = $"Ważność do: {p.Waznosc}";
|
||||
lblStatus.Text = $"Status: {p.Status}";
|
||||
lblUwagi.Text = p.Uwagi;
|
||||
}
|
||||
}
|
||||
}
|
||||
public ProductDetailPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void Button_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
await Shell.Current.GoToAsync("..");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user