Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
HorizontalAlignment="Stretch" />
<!--#endif-->
<Button Content="Login"
Command="{Binding Login}"
Command="{Binding DoLoginCommand}"
HorizontalAlignment="Stretch" />
</StackPanel>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public LoginPage()
new Button()
.Content("Login")
.HorizontalAlignment(HorizontalAlignment.Stretch)
.Command(() => vm.Login)))));
.Command(() => vm.DoLoginCommand)))));
#else
this.InitializeComponent();
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public LoginViewModel(
_dispatcher = dispatcher;
_navigator = navigator;
_authentication = authentication;
Login = new AsyncRelayCommand(DoLogin);
}


[RelayCommand]
private async Task DoLogin()
{
#if useCustomAuthentication
Expand All @@ -45,5 +45,4 @@ private async Task DoLogin()

public string Title { get; } = "Login";

public ICommand Login { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
PlaceholderText="Enter your name:" />
<Button Content="Go to Second Page"
AutomationProperties.AutomationId="SecondPageButton"
Command="{Binding GoToSecond}" />
Command="{Binding GoToSecondViewCommand}" />
<!--#if (useAuthentication)-->
<Button Content="Logout"
Command="{Binding Logout}" />
Command="{Binding DoLogoutCommand}" />
<!--#endif-->
</StackPanel>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//-:cnd:noEmit
//-:cnd:noEmit
namespace MyExtensionsApp._1.Presentation;

public sealed partial class MainPage : Page
Expand Down Expand Up @@ -40,13 +40,13 @@ public MainPage()
.Content("Go to Second Page")
.AutomationProperties(automationId: "SecondPageButton")
#if !useAuthentication
.Command(() => vm.GoToSecond)
.Command(() => vm.GoToSecondViewCommand)
#else
.Command(() => vm.GoToSecond),
.Command(() => vm.GoToSecondViewCommand),
new Button()
.Content("Logout")
.AutomationProperties(automationId: "LogoutButton")
.Command(() => vm.Logout)
.Command(() => vm.DoLogoutCommand)
#endif
))));
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,17 @@ public MainViewModel(
#endif
#if useConfiguration
Title += $" - {appInfo?.Value?.Environment}";
#endif
GoToSecond = new AsyncRelayCommand(GoToSecondView);
#if mauiEmbedding
Counter = new RelayCommand(OnCount);
#endif
#if useAuthentication
Logout = new AsyncRelayCommand(DoLogout);
#endif
}
public string? Title { get; }

public ICommand GoToSecond { get; }
#if mauiEmbedding

public ICommand Counter { get; }
#endif

#if useAuthentication
public ICommand Logout { get; }

#endif
[RelayCommand]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't remove the Authentication and mauiembedding scenarios

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corvinsz could you check on this? Would be cool if this enhancement you trying to add could get added also from my user POV :)

private async Task GoToSecondView()
{
await _navigator.NavigateViewModelAsync<SecondViewModel>(this, data: new Entity(Name!));
}

#if mauiEmbedding

[RelayCommand]
private void OnCount()
{
CounterText = ++count switch
Expand All @@ -80,6 +63,7 @@ private void OnCount()
}
#endif
#if useAuthentication
[RelayCommand]
public async Task DoLogout(CancellationToken token)
{
await _authentication.LogoutAsync(token);
Expand Down
Loading