the issue that I have is the fact that I need to create flyout menu based on roles or at least set Visibility to false.
Forn example this is my flyout.
<ShellContent
ContentTemplate="{DataTemplate view:LoginPage}"
Route="LoginPage"
Shell.FlyoutBehavior="Disabled"
Shell.FlyoutItemIsVisible="False" />
<FlyoutItem Title="Home">
<ShellContent
ContentTemplate="{DataTemplate view:HomePage}"
Route="HomePage" />
</FlyoutItem>
<FlyoutItem Title="New lecture">
<ShellContent
ContentTemplate="{DataTemplate view:NewLecturePage}"
Route="NewLecturePage" />
</FlyoutItem>
<FlyoutItem Title="New test">
<ShellContent
ContentTemplate="{DataTemplate view:NewTestPage}"
Route="NewTestPage" />
</FlyoutItem>
<FlyoutItem Title="Schedule lecture">
<ShellContent
ContentTemplate="{DataTemplate view:ScheduleLecturePage}"
Route="ScheduleLecturePage" />
</FlyoutItem>
<FlyoutItem Title="Schedule test">
<ShellContent
ContentTemplate="{DataTemplate view:ScheduleTestPage}"
Route="ScheduleLecturePage" />
</FlyoutItem>
<FlyoutItem Title="Manage participants">
<ShellContent
ContentTemplate="{DataTemplate view:ContactPage}"
Route="ContactPage" />
</FlyoutItem>
<FlyoutItem Title="Manage courses">
<ShellContent
ContentTemplate="{DataTemplate view:CoursesPage}"
Route="CoursesPage" />
</FlyoutItem>
The admin, only can access "Manage Participant" and "Manage Course"
but the problem that I have is that in order to do that, when I received the object in my ShellViewModel, I need to do a switch case and set Booleans to true or false depending on the case.
I received my object in my shell, when I log in.
[RelayCommand]
async Task Login() {
IsBusy = true;
//var user = await authenticationService.LoginWithEmailAndPassword(User.Email, User.Password);
var user = await authenticationService.LoginWithEmailAndPassword("******@admin.com", "111111");
if (user != null) {
var currentUser = await dataService.GetByUidAsync<User>("Users", user.Uid);
if (currentUser != null) {
appShellViewModel.User = currentUser;
}
await appService.NavigateTo($"//{nameof(HomePage)}", true);
}
IsBusy = false;
}
[RelayCommand]
async Task Register() {
var IsFilled = await VerifyUserAsync(User);
if (IsFilled) {
IsBusy = true;
var user = await authenticationService.RegisterWithEmailAndPassword(User.Email, User.Password);
if (user != null) {
IsPopOpen = false;
User.Uid = user.Uid;
User.Id = User.GenerateRandomNumberString();
User.Name = User.Name;
User.Email = User.Email;
User.Password = BCrypt.Net.BCrypt.HashPassword(User.Password);
User.Role = User.Role;
var currentUser = await dataService.GetByUidAsync<User>("Users", user.Uid);
if (currentUser != null) {
appShellViewModel.User = currentUser;
}
await appService.NavigateTo($"//{nameof(HomePage)}", true);
}
}
IsBusy = false;
}
the problem is that I dont know to perform the check.
public partial class AppShellViewModel(IAuthenticationService authenticationService, IAppService appService) : BaseViewModel {
[ObservableProperty]
User? user;
[RelayCommand]
async Task SignOut() {
authenticationService.SignOut();
await appService.NavigateTo($"//{nameof(LoginPage)}", true);
}
}
if I bind a method to the appeared command (Using the Maui toolkit) I can't because the shell is my entry point
App
https://github.com/eduardoagr/DemyAI