Open ziomek64 opened 11 months ago
Hi @ziomek64,
thanks for informing me about the issue. Where exactly do you call SimpleToolkit.SimpleShell.SimpleShell.Current.GoToAsync($"//main");
? Does the app crash even if this call is commented out?
It happens in OnAppearing for my login page. The app doesn't crash when its commented or with normal shell
protected override async void OnAppearing()
{
var token = Preferences.Get("token", "default_value");
bool validation = true;
try
{
validation = false;
if (token != "default_value")
{
IJsonSerializer serializer = new JsonNetSerializer();
var provider = new UtcDateTimeProvider();
IJwtValidator validator = new JwtValidator(serializer, provider);
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtAlgorithm algorithm = new HMACSHA256Algorithm(); // symmetric
IJwtDecoder decoder = new JwtDecoder(serializer, validator, urlEncoder, algorithm);
//TODO decoding z login taska i sprawdzanie expiry w ten sposob
//var json = decoder.Decode(token);
validation = true;
}
}
catch (TokenExpiredException)
{
Preferences.Set("token", "default_value");
}
catch (SignatureVerificationException)
{
Preferences.Set("token", "default_value");
}
catch (InvalidTokenPartsException)
{
Preferences.Set("token", "default_value");
}
catch (HttpRequestException httpRequestException)
{
Debug.WriteLine(httpRequestException.Message);
MainThread.BeginInvokeOnMainThread(() =>
{
var toast = Toast.Make("No internet.", duration, fontSize);
toast.Show(cancellationTokenSource.Token);
});
}
catch (Exception e)
{
Debug.WriteLine(e);
if (e.Message.Contains("Unable to resolve host"))
{
MainThread.BeginInvokeOnMainThread(() =>
{
//DependencyService.Get<Toast>().Show("Unexpected error happened");
var toast = Toast.Make("No internet.", duration, fontSize);
toast.Show(cancellationTokenSource.Token);
});
}
else
{
MainThread.BeginInvokeOnMainThread(() =>
{
//DependencyService.Get<Toast>().Show("Unexpected error happened");
var toast = Toast.Make("Unexpected error happened.", duration, fontSize);
toast.Show(cancellationTokenSource.Token);
});
}
}
finally
{
if (validation)
{
await SimpleToolkit.SimpleShell.SimpleShell.Current.GoToAsync($"//main");
}
}
}
Should simple shell be installed in platform specific projects too or not?
Hi @ziomek64,
I have finally tried to take a look at this issue. However, I probably will not be able to fix it because of the way how creating a handler for a ShellItem
works.
A workaround to this issue is to delay the navigation using Task.Delay()
a bit:
await Task.Delay(100);
await Shell.Current.GoToAsync($"//main");
The delay is needed only on the first navigation to the initial page. On subsequent navigations to that page and on other pages it should not be needed.
And by the way, I currently do not plan to continue developing the SimpleToolkit.SimpleShell.Controls package, so I do not recommend using that.
Hello, I've just stumbled upon your SimpleToolkit and I wanted to implement it. It looks awesome, has some stuff that I need and also Material3 TabBar in Controls.
Right now I'm getting unhandled exception:
Java.Lang.IllegalArgumentException: 'No view found for id 0x5 (unknown) for fragment SimpleFragment{acb1dc6} (0b7617ee-9aaa-4da3-88ab-d0e65a35f48c id=0x5)'
I'm trying to follow the guide to have basic implementation for starters and I swapped everything for SimpleShell. So I'm gonna give you a tour over it. MauiProgram.cs
App.xaml.cs
AppShell.xaml. I have login page route and the main one with tab bar.
When I'm loading the app on that login page, it checks for token on apperance etc and goes to main route. I'm pointing this out now that I've also tried with just Shell
This is the only Shell and navigation stuff that happens and I'm crashing. When I'm swapping everything back to Shell it will load my app. So I've need some help, because maybe I'm missing something. Are all toolkit nugets supposed to be installed on platform specific projects too? Because I didn't get an option to do so. Just the main one. Which might be the problem..
From my main project file:
I don't have 34 after android like in nuget requirements. But yeah it's targetting 34. I don't have 34 because the app just wouldn't start with numbera after android, after .net 8 upgrade.