private async void OnAddClicked(object sender, EventArgs e)
{
string type = typePicker.SelectedItem?.ToString();
string number = numberEntry.Text;
string country = countryEntry.Text;
string description = descriptionEditor.Text;
string date = datePicker.Date.ToString("dd.MM.yyyy");
if (string.IsNullOrWhiteSpace(type) ||
string.IsNullOrWhiteSpace(number) ||
string.IsNullOrWhiteSpace(country))
{
await DisplayAlert("Ошибка", "Заполните все поля", "OK");
return;
}
Label infoLabel = new Label
{
Text =
$"Тип: {type}\n" +
$"Номер: {number}\n" +
$"Страна: {country}\n" +
$"Дата: {date}\n\n" +
description,
FontSize = 16,
TextColor = Colors.Black
};
Button deleteButton = new Button
{
Text = "Удалить",
BackgroundColor = Colors.Red,
TextColor = Colors.White
};
VerticalStackLayout layout = new VerticalStackLayout
{
Spacing = 10
};
layout.Children.Add(infoLabel);
layout.Children.Add(deleteButton);
Frame card = new Frame
{
BackgroundColor = Colors.White,
CornerRadius = 20,
Padding = 15,
HasShadow = true,
Content = layout
};
deleteButton.Clicked += (s, args) =>
{
documentsLayout.Children.Remove(card);
};
documentsLayout.Children.Add(card);
typePicker.SelectedIndex = -1;
numberEntry.Text = "";
countryEntry.Text = "";
descriptionEditor.Text = "";
}