Skip to content

Commit

Permalink
Merge pull request #14 from DevElkami/Dev
Browse files Browse the repository at this point in the history
Licence update
  • Loading branch information
DevElkami committed Apr 7, 2023
2 parents 84aacff + 5827d6a commit e21056b
Show file tree
Hide file tree
Showing 22 changed files with 455 additions and 134 deletions.
24 changes: 24 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>
11 changes: 8 additions & 3 deletions MauiPasswordVault/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
namespace MauiPasswordVault
using MauiPasswordVault.View;

namespace MauiPasswordVault
{
public partial class App : Application
{
public App()
public App(SearchPage searchPage)
{
if (Application.Current != null)
Application.Current.UserAppTheme = AppTheme.Dark;

InitializeComponent();

MainPage = new AppShell();
MainPage = new NavigationPage(searchPage);
}
}
}
26 changes: 0 additions & 26 deletions MauiPasswordVault/AppShell.xaml

This file was deleted.

15 changes: 0 additions & 15 deletions MauiPasswordVault/AppShell.xaml.cs

This file was deleted.

4 changes: 4 additions & 0 deletions MauiPasswordVault/MauiPasswordVault.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<!-- Display name -->
<ApplicationTitle>Password Vault</ApplicationTitle>
Expand Down Expand Up @@ -81,6 +82,9 @@
<MauiXaml Update="View\CheckPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\ErrorPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\SearchPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
Expand Down
12 changes: 9 additions & 3 deletions MauiPasswordVault/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MauiPasswordVault.View;
using MauiPasswordVault.Service;
using MauiPasswordVault.View;
using MauiPasswordVault.ViewModel;
using Microsoft.Extensions.Logging;
using VaultCore;
Expand All @@ -11,7 +12,7 @@ public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
Expand All @@ -20,8 +21,10 @@ public static MauiApp CreateMauiApp()
fonts.AddFont("AwesomeRegular.otf", "AwesomeRegular");
fonts.AddFont("AwesomeSolid.otf", "AwesomeSolid");
});

builder.Services.AddSingleton<MyVault>();
builder.Services.AddSingleton<NavigationService>();
builder.Services.AddSingleton<ErrorService>();

builder.Services.AddTransient<InitPage>();
builder.Services.AddTransient<InitViewModel>();
Expand All @@ -31,6 +34,9 @@ public static MauiApp CreateMauiApp()

builder.Services.AddTransient<SearchPage>();
builder.Services.AddTransient<SearchViewModel>();

builder.Services.AddTransient<ErrorPage>();
builder.Services.AddTransient<ErrorViewModel>();
#if DEBUG
builder.Logging.AddDebug();
#endif
Expand Down
8 changes: 8 additions & 0 deletions MauiPasswordVault/Service/ErrorService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace MauiPasswordVault.Service;

public class ErrorService
{
public String LastErrorMessage { get; set; } = null!;
public String LastErrorFull { get; set; } = null!;
public bool CriticalError { get; set; } = false;
}
49 changes: 49 additions & 0 deletions MauiPasswordVault/Service/NavigationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.Diagnostics;

namespace MauiPasswordVault.Service;

public class NavigationService
{
readonly IServiceProvider services;

public NavigationService(IServiceProvider services)
{
this.services = services;
}

public Task NavigateToPage<T>() where T : Page
{
var page = ResolvePage<T>();
if (page is not null)
return Navigation.PushAsync(page, true);
throw new InvalidOperationException($"Unable to resolve type {typeof(T).FullName}");
}

public Task NavigateBack()
{
if (Navigation.NavigationStack.Count > 1)
return Navigation.PopAsync();
throw new InvalidOperationException("No pages to navigate back to!");
}

protected INavigation Navigation
{
get
{
INavigation? navigation = Application.Current?.MainPage?.Navigation;
if (navigation is not null)
return navigation;
else
{
if (Debugger.IsAttached)
Debugger.Break();
throw new Exception("Can't get navigation.");
}
}
}

private T? ResolvePage<T>() where T : Page
{
return services.GetService<T>();
}
}
56 changes: 50 additions & 6 deletions MauiPasswordVault/View/CheckPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,54 @@
x:Class="MauiPasswordVault.View.CheckPage"
Title="Your password">

<VerticalStackLayout>
<Label
Text="Check page"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">

<Image
Source="logo.png"
SemanticProperties.Description="Password vault logo"
HeightRequest="200"
HorizontalOptions="Center" />

<Label
Text="Password vault check"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />

<HorizontalStackLayout
Spacing="25"
Padding="30,0"
HorizontalOptions="Center">

<Label
Text="Check page"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
VerticalOptions="Center" />

<Editor Text="{Binding VaultKey}" AutoSize="Disabled" MinimumWidthRequest="80"></Editor>

</HorizontalStackLayout>

<Label
Text="Check page"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />

<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Initialize Vault"
Command="{Binding CheckCommand}"
HorizontalOptions="Center" />

</VerticalStackLayout>
</ScrollView>
</ContentPage>
22 changes: 19 additions & 3 deletions MauiPasswordVault/View/CheckPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
using MauiPasswordVault.Service;
using MauiPasswordVault.ViewModel;

namespace MauiPasswordVault.View;

public partial class CheckPage : ContentPage
{
public CheckPage(CheckViewModel checkViewModel)
private readonly NavigationService navigationService;
private readonly ErrorService errorService;

public CheckPage(NavigationService navigationService, ErrorService errorService, CheckViewModel checkViewModel)
{
this.navigationService = navigationService;
this.errorService = errorService;
BindingContext = checkViewModel;
InitializeComponent();
}

protected async override void OnAppearing()
{
if (!((CheckViewModel)BindingContext).IsInitialized())
await Shell.Current.GoToAsync(nameof(InitPage));
try
{
if (!((CheckViewModel)BindingContext).IsInitialized())
await navigationService.NavigateToPage<InitPage>();
}
catch (Exception exception)
{
this.errorService.LastErrorMessage = exception.Message;
this.errorService.LastErrorFull = exception.ToString();
this.errorService.CriticalError = true;
await this.navigationService.NavigateToPage<ErrorPage>();
}
}
}
24 changes: 24 additions & 0 deletions MauiPasswordVault/View/ErrorPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiPasswordVault.View.ErrorPage"
Title="ErrorPage">
<VerticalStackLayout>
<Label
Text="Error page"
VerticalOptions="Center"
HorizontalOptions="Center" />

<Label
Text="{Binding LastErrorMessage}"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />

<Button
Text="Click me"
SemanticProperties.Hint="Error page"
Command="{Binding AcceptCommand}"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>
12 changes: 12 additions & 0 deletions MauiPasswordVault/View/ErrorPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using MauiPasswordVault.ViewModel;

namespace MauiPasswordVault.View;

public partial class ErrorPage : ContentPage
{
public ErrorPage(ErrorViewModel errorViewModel)
{
BindingContext = errorViewModel;
InitializeComponent();
}
}
Loading

0 comments on commit e21056b

Please sign in to comment.