-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from DevEddy/develop
Develop into main
- Loading branch information
Showing
7 changed files
with
87 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
using CommunityToolkit.Mvvm.Input; | ||
using Resolved.It.Maui.App.Services; | ||
using Resolved.It.Maui.App.Views; | ||
using Resolved.It.Maui.Core.Extensions; | ||
using Resolved.It.Maui.Core.Validations; | ||
using Resolved.It.Maui.Core.Validations.Rules; | ||
|
||
|
@@ -28,6 +29,14 @@ public LoginPageViewModel( | |
Email.Value = "[email protected]"; | ||
} | ||
|
||
public override void ApplyQueryAttributes(IDictionary<string, object> query) | ||
{ | ||
base.ApplyQueryAttributes(query); | ||
|
||
if (query!.ValueAsBool("Logout")) | ||
LogoutCommand.ExecuteAsync(null); | ||
} | ||
|
||
private bool IsInputValid() => IsValid; | ||
|
||
[RelayCommand(CanExecute = nameof(IsInputValid))] | ||
|
@@ -42,7 +51,17 @@ await IsBusyFor( | |
await NavigationService.NavigateToAsync($"//{nameof(MainPage)}"); | ||
}); | ||
} | ||
|
||
|
||
[RelayCommand] | ||
private Task LogoutAsync() | ||
{ | ||
_settingsService.AuthAccessToken = string.Empty; | ||
|
||
Email.Value = string.Empty; | ||
Password.Value = string.Empty; | ||
return Task.CompletedTask; | ||
} | ||
|
||
private void CheckValidation() | ||
{ | ||
var isEmailValid = Email.IsValid; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Resolved.It.Maui.Core/Extensions/DictionaryExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Resolved.It.Maui.Core.Extensions; | ||
|
||
public static class DictionaryExtensions | ||
{ | ||
public static bool ValueAsBool(this IDictionary<string, object?> dictionary, string key, bool defaultValue = false) => | ||
dictionary.TryGetValue(key, out var value) && value is bool dictValue | ||
? dictValue | ||
: defaultValue; | ||
|
||
public static int ValueAsInt(this IDictionary<string, object?> dictionary, string key, int defaultValue = 0) => | ||
dictionary.TryGetValue(key, out var value) && value is int intValue | ||
? intValue | ||
: defaultValue; | ||
} |