home page for App

This commit is contained in:
2023-07-27 22:07:24 +08:00
parent 02ac33fc07
commit befbc7fc9b
40 changed files with 1175 additions and 398 deletions

View File

@@ -0,0 +1,59 @@
namespace Blahblah.FlowerApp;
public class AppContentPage : ContentPage
{
protected static string L(string key, string defaultValue = "")
{
return LocalizationResource.GetText(key, defaultValue);
}
protected static Task<T?> FetchAsync<T>(string url, CancellationToken cancellation = default)
{
return Extensions.FetchAsync<T>(url, cancellation);
}
protected T GetValue<T>(BindableProperty property)
{
return (T)GetValue(property);
}
protected Task AlertError(string error)
{
return Alert(LocalizationResource.GetText("error", "Error"), error);
}
protected Task Alert(string title, string message, string? cancel = null)
{
cancel ??= LocalizationResource.GetText("ok", "Ok");
if (MainThread.IsMainThread)
{
return DisplayAlert(title, message, cancel);
}
var taskSource = new TaskCompletionSource();
MainThread.BeginInvokeOnMainThread(async () =>
{
await DisplayAlert(title, message, cancel);
taskSource.TrySetResult();
});
return taskSource.Task;
}
protected Task<bool> Confirm(string title, string question, string? accept = null, string? cancel = null)
{
accept ??= LocalizationResource.GetText("yes", "Yes");
cancel ??= LocalizationResource.GetText("no", "No");
if (MainThread.IsMainThread)
{
return DisplayAlert(title, question, accept, cancel);
}
var taskSource = new TaskCompletionSource<bool>();
MainThread.BeginInvokeOnMainThread(async () =>
{
var result = await DisplayAlert(title, question, accept, cancel);
taskSource.TrySetResult(result);
});
return taskSource.Task;
}
}