Untitled
unknown
plain_text
a year ago
2.0 kB
16
Indexable
private async void btnmainimage_Clicked(object sender, EventArgs e)
{
//var fileResult = await FilePicker.PickAsync();
//var fileToUpload = await fileResult!.OpenReadAsync();
//var stream = await fileResult.OpenReadAsync();
//mainimage.Source = ImageSource.FromStream(() => stream);
//await DisplayAlert("DD", lessorkey, "OK");
////start uploading the mainimage
//var firebaseStorage = await new FirebaseStorage("irentmertdb.appspot.com")
// .Child($"Images/LessorsImages/{lessorkey}")
// .PutAsync(fileToUpload);
var result = await FilePicker.PickAsync(new PickOptions
{
PickerTitle = "Select main image",
FileTypes = FilePickerFileType.Images
});
if (result == null) return;
FileInfo fi = new(result.FullPath);
var size = fi.Length;
if (size > 524288)
{
var snackbarOptions = new SnackbarOptions
{
BackgroundColor = Color.FromRgb(32, 32, 40),
TextColor = Colors.WhiteSmoke,
ActionButtonTextColor = Colors.White,
CornerRadius = new CornerRadius(10),
Font = Font.SystemFontOfSize(10),
ActionButtonFont = Font.SystemFontOfSize(10)
};
const string text = "The image you have selected is more than 0.50MB please ensure that the size of the image is less than the maximum size. Thank you!";
const string actionButtonText = "Got it!";
var duration = TimeSpan.FromSeconds(10);
var snackbar = Snackbar.Make(text, null, actionButtonText, duration, snackbarOptions);
await snackbar.Show(cancellationTokenSource.Token);
return;
}
var stream = await result.OpenReadAsync();
_mainimgResult = result;
mainimage.Source = ImageSource.FromStream(() => stream);
}Editor is loading...
Leave a Comment