flower-story/FlowerApp/MainPage.xaml.cs
2023-07-19 21:01:19 +08:00

49 lines
1.2 KiB
C#

using Blahblah.FlowerApp.Data;
using Microsoft.Extensions.Logging;
namespace Blahblah.FlowerApp;
public partial class MainPage : ContentPage
{
int count = 0;
readonly FlowerDatabase database;
readonly ILogger logger;
public MainPage(FlowerDatabase database, ILogger<MainPage> logger)
{
this.database = database;
this.logger = logger;
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
Task.Run(async () =>
{
try
{
var list = await database.GetFlowers();
logger.LogInformation("got {count} flowers.", list.Length);
}
catch (Exception ex)
{
logger.LogError("error occurs in MainPage, {exception}", ex);
}
});
}
//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);
//}
}