diff --git a/src/BolWallet/App.xaml.cs b/src/BolWallet/App.xaml.cs index ddfb6216..030a975a 100644 --- a/src/BolWallet/App.xaml.cs +++ b/src/BolWallet/App.xaml.cs @@ -7,8 +7,9 @@ namespace BolWallet; public partial class App : Application, IRecipient { private readonly INetworkPreferences _networkPreferences; + private ILogExtractor _logExtractor = null!; - public App(PreloadPage preloadPage, INetworkPreferences networkPreferences, IMessenger messenger) + public App(INetworkPreferences networkPreferences, IMessenger messenger) { _networkPreferences = networkPreferences; InitializeComponent(); @@ -40,15 +41,16 @@ public App(PreloadPage preloadPage, INetworkPreferences networkPreferences, IMes handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None; #endif }); - - MainPage = new NavigationPage(preloadPage); } protected override Window CreateWindow(IActivationState activationState) { - Window window = base.CreateWindow(activationState); - window.Title = CreateWindowTitle(); - return window; + // initialize singleton services which may not be used as dependencies but should exist. + // For example to listen to messages. + _logExtractor = activationState!.Context.Services.GetRequiredService(); + + var preloadPage = activationState.Context.Services.GetRequiredService(); + return new Window { Title = CreateWindowTitle(), Page = new NavigationPage(preloadPage) }; } #if WINDOWS @@ -77,7 +79,7 @@ private static void MapHorizontalOptions(IViewHandler handler, IView view) #endif public void Receive(TargetNetworkChangedMessage message) { - MainThread.BeginInvokeOnMainThread(() => Current.MainPage.Window.Title = CreateWindowTitle()); + MainThread.BeginInvokeOnMainThread(() => Current.Windows[0].Page.Window.Title = CreateWindowTitle()); } private string CreateWindowTitle() => _networkPreferences.IsMainNet diff --git a/src/BolWallet/BolWallet.csproj b/src/BolWallet/BolWallet.csproj index 97d5fe1e..9d7b7f5d 100644 --- a/src/BolWallet/BolWallet.csproj +++ b/src/BolWallet/BolWallet.csproj @@ -1,15 +1,15 @@  - net8.0-android; - $(TargetFrameworks);net8.0-windows10.0.19041.0 - $(TargetFrameworks);net8.0-maccatalyst;net8.0-ios + net9.0-android; + $(TargetFrameworks);net9.0-windows10.0.19041.0 + $(TargetFrameworks);net9.0-maccatalyst;net9.0-ios Exe BolWallet true - 8.0.92 + 9.0.0 true enable @@ -24,19 +24,20 @@ 1.0 1 - 14.2 - 14.0 + 15.0 + 15.0 24.0 10.0.17763.0 10.0.17763.0 6.5 + android-arm;android-arm64;android-x86;android-x64 en-US - + - + iPhone Developer true @@ -44,20 +45,20 @@ Automatic - + - + - + r8 - + true Automatic @@ -65,7 +66,7 @@ Platforms\iOS\Entitlements.plist - + SdkOnly true @@ -77,7 +78,7 @@ Platforms\MacCatalyst\Entitlements.plist - + @@ -213,15 +214,14 @@ - + - - + - + diff --git a/src/BolWallet/Constants.cs b/src/BolWallet/Constants.cs index d7cffa62..066d289c 100644 --- a/src/BolWallet/Constants.cs +++ b/src/BolWallet/Constants.cs @@ -19,6 +19,7 @@ internal class Constants public static readonly WalletClosedMessage WalletClosedMessage = new(); public static readonly WalletCreatedMessage WalletCreatedMessage = new(); public static readonly WalletCleanupCompletedMessage WalletCleanupCompletedMessage = new(); + public static readonly SaveLogfileMessage SaveLogfileMessage = new(); public static readonly JsonSerializerOptions WalletJsonSerializerDefaultOptions = new() { diff --git a/src/BolWallet/Extensions/LoggingExtensions.cs b/src/BolWallet/Extensions/LoggingExtensions.cs index f2bc2465..388ae6c2 100644 --- a/src/BolWallet/Extensions/LoggingExtensions.cs +++ b/src/BolWallet/Extensions/LoggingExtensions.cs @@ -67,7 +67,7 @@ public static IServiceCollection ConfigureSerilog(this IServiceCollection servic Log.Logger.Information("App Info: {@AppInfo}", appInfo); services.AddLogging(configure => configure.AddSerilog(dispose: true)); - + services.AddTransient(); return services; } } diff --git a/src/BolWallet/MauiProgram.cs b/src/BolWallet/MauiProgram.cs index 3ce2beb4..dc3efb62 100644 --- a/src/BolWallet/MauiProgram.cs +++ b/src/BolWallet/MauiProgram.cs @@ -35,6 +35,7 @@ public static MauiApp CreateMauiApp() fonts.AddFont("MaterialIcons-Regular.ttf", "MaterialIconsRegular"); }); + builder.Services.AddSingleton(); builder.Services.AddMauiBlazorWebView(); builder.Services.AddMudServices(); @@ -45,10 +46,18 @@ public static MauiApp CreateMauiApp() #else builder.AddConfiguration("BolWallet.appsettings.json"); #endif + +#if IOS || MACCATALYST +builder.ConfigureMauiHandlers(handlers => +{ + handlers.AddHandler(); +}); +#endif var services = builder.Services; // Register Services + services.AddSingleton(TimeProvider.System); services.AddScoped(_ => new Repository(BlobCache.UserAccount)); services.AddScoped(); services.AddSingleton(); diff --git a/src/BolWallet/Models/Messages/SaveLogfileMessage.cs b/src/BolWallet/Models/Messages/SaveLogfileMessage.cs new file mode 100644 index 00000000..4e74a18d --- /dev/null +++ b/src/BolWallet/Models/Messages/SaveLogfileMessage.cs @@ -0,0 +1,3 @@ +namespace BolWallet.Models.Messages; + +public record SaveLogfileMessage; diff --git a/src/BolWallet/Pages/CitizenshipPage.razor b/src/BolWallet/Pages/CitizenshipPage.razor index 2bbb2197..7fbabfb7 100644 --- a/src/BolWallet/Pages/CitizenshipPage.razor +++ b/src/BolWallet/Pages/CitizenshipPage.razor @@ -108,6 +108,6 @@ return; } - await App.Current.MainPage.Navigation.PushAsync(new Views.EcryptedCitizenshipPage()); + await Application.Current.Windows[0].Page.Navigation.PushAsync(new Views.EcryptedCitizenshipPage()); } } \ No newline at end of file diff --git a/src/BolWallet/Pages/MenuPanel.razor b/src/BolWallet/Pages/MenuPanel.razor index acdeeeee..becab5ea 100644 --- a/src/BolWallet/Pages/MenuPanel.razor +++ b/src/BolWallet/Pages/MenuPanel.razor @@ -1,7 +1,10 @@ @using Bol.Core.Model +@using CommunityToolkit.Mvvm.Messaging @inject INavigationService NavigationService @inject IBolService bolService; @inject ICloseWalletService closeWalletService; +@inject IAppVersion AppVersion; +@inject IMessenger Messenger; @@ -12,7 +15,10 @@ - Bol Menu + + BOL Wallet + @(AppVersion.GetVersion()) + @@ -29,19 +35,20 @@ @if (!BolAccount.IsCertifier) { - Become a Certifier + Become a Certifier } else { Certify a CodeName Whitelist a Main Address - Submit a Multiple Citizenship - Set Your Fee + Submit a Multiple Citizenship + Set Your Fee Unregister as Certifier } History + Save Logfile @* Explore Blockchain Monitor Seeds *@ @* Unload Wallet *@ @@ -83,7 +90,7 @@ { try { - bool confirmed = await App.Current.MainPage.DisplayAlert("Confirm", "Are you sure you want to unregister as a certifier?", "Yes", "No"); + bool confirmed = await App.Current.Windows[0].Page.DisplayAlert("Confirm", "Are you sure you want to unregister as a certifier?", "Yes", "No"); if (confirmed) { await bolService.UnRegisterAsCertifier(); diff --git a/src/BolWallet/Pages/WalletCreationInfo.razor b/src/BolWallet/Pages/WalletCreationInfo.razor index 2eeef63e..e41ae816 100644 --- a/src/BolWallet/Pages/WalletCreationInfo.razor +++ b/src/BolWallet/Pages/WalletCreationInfo.razor @@ -56,7 +56,7 @@ { if (!IsNavigationDisabled) { - await App.Current.MainPage.Navigation.PushAsync(new Views.CitizenshipPage()); + await App.Current.Windows[0].Page.Navigation.PushAsync(new Views.CitizenshipPage()); } } } diff --git a/src/BolWallet/Platforms/Android/AndroidManifest.xml b/src/BolWallet/Platforms/Android/AndroidManifest.xml index c5f6b687..f4af5db8 100644 --- a/src/BolWallet/Platforms/Android/AndroidManifest.xml +++ b/src/BolWallet/Platforms/Android/AndroidManifest.xml @@ -1,10 +1,9 @@  - + - diff --git a/src/BolWallet/Platforms/MacCatalyst/Info.plist b/src/BolWallet/Platforms/MacCatalyst/Info.plist index ffc46407..abd9901e 100644 --- a/src/BolWallet/Platforms/MacCatalyst/Info.plist +++ b/src/BolWallet/Platforms/MacCatalyst/Info.plist @@ -31,9 +31,9 @@ processing CFBundleVersion - 2024.1105.2230 + 2024.1113.0540 CFBundleShortVersionString - 2.3.3 + 3.0.0 CFBundleDevelopmentRegion en NSHumanReadableCopyright @@ -44,5 +44,7 @@ The app can use the microphone to record your voice and use it when creating a new wallet. NSPhotoLibraryUsageDescription The app can use the photo library to select photos from your library and use them when creating a new wallet. + ITSAppUsesNonExemptEncryption + diff --git a/src/BolWallet/Platforms/Windows/Package.appxmanifest b/src/BolWallet/Platforms/Windows/Package.appxmanifest index 6a5fe8f0..cfb9a3dc 100644 --- a/src/BolWallet/Platforms/Windows/Package.appxmanifest +++ b/src/BolWallet/Platforms/Windows/Package.appxmanifest @@ -6,7 +6,7 @@ xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap rescap"> - + diff --git a/src/BolWallet/Platforms/iOS/Info.plist b/src/BolWallet/Platforms/iOS/Info.plist index 5e3c399c..95155551 100644 --- a/src/BolWallet/Platforms/iOS/Info.plist +++ b/src/BolWallet/Platforms/iOS/Info.plist @@ -7,7 +7,7 @@ UIDeviceFamily 1 - 2 + 2 UIRequiredDeviceCapabilities @@ -29,18 +29,20 @@ XSAppIconAssets Assets.xcassets/appicon.appiconset NSCameraUsageDescription - The app can use the camera to take a photo of a document and use it when creating a new wallet. + The app can use the camera to take a photo of a document and use it when creating a new wallet. NSMicrophoneUsageDescription - The app can use the microphone to record your voice and use it when creating a new wallet. - NSPhotoLibraryUsageDescription - The app can use the photo library to select photos from your library and use them when creating a new wallet. - CFBundleVersion - 2024.1105.2230 - CFBundleShortVersionString - 2.3.3 - CFBundleDevelopmentRegion - en - NSHumanReadableCopyright - 1bol.org © 2024 + The app can use the microphone to record your voice and use it when creating a new wallet. + NSPhotoLibraryUsageDescription + The app can use the photo library to select photos from your library and use them when creating a new wallet. + CFBundleVersion + 2024.1113.0540 + CFBundleShortVersionString + 3.0.0 + CFBundleDevelopmentRegion + en + NSHumanReadableCopyright + 1bol.org © 2024 + ITSAppUsesNonExemptEncryption + diff --git a/src/BolWallet/Resources/Images/zip.svg b/src/BolWallet/Resources/Images/zip.svg new file mode 100644 index 00000000..a8c1cb65 --- /dev/null +++ b/src/BolWallet/Resources/Images/zip.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/BolWallet/Services/Abstractions/IAppVersion.cs b/src/BolWallet/Services/Abstractions/IAppVersion.cs new file mode 100644 index 00000000..6fff037a --- /dev/null +++ b/src/BolWallet/Services/Abstractions/IAppVersion.cs @@ -0,0 +1,6 @@ +namespace BolWallet.Services.Abstractions; + +public interface IAppVersion +{ + string GetVersion(); +} diff --git a/src/BolWallet/Services/Abstractions/ILogExtractor.cs b/src/BolWallet/Services/Abstractions/ILogExtractor.cs new file mode 100644 index 00000000..bc5320ba --- /dev/null +++ b/src/BolWallet/Services/Abstractions/ILogExtractor.cs @@ -0,0 +1,6 @@ +namespace BolWallet.Services.Abstractions; + +public interface ILogExtractor +{ + Task ExtractLog(CancellationToken token = default); +} diff --git a/src/BolWallet/Services/AppVersion.cs b/src/BolWallet/Services/AppVersion.cs new file mode 100644 index 00000000..7315451f --- /dev/null +++ b/src/BolWallet/Services/AppVersion.cs @@ -0,0 +1,6 @@ +namespace BolWallet.Services; + +public class AppVersion : IAppVersion +{ + public string GetVersion() => $"{AppInfo.Current.VersionString} ({AppInfo.Current.BuildString})"; +} diff --git a/src/BolWallet/Services/CloseWalletService.cs b/src/BolWallet/Services/CloseWalletService.cs index d4ca3c56..8a12a5d3 100644 --- a/src/BolWallet/Services/CloseWalletService.cs +++ b/src/BolWallet/Services/CloseWalletService.cs @@ -21,7 +21,7 @@ public async Task CloseWallet() logger.LogInformation("Close wallet requested..."); - var confirm = await App.Current.MainPage.DisplayAlert( + var confirm = await App.Current.Windows[0].Page.DisplayAlert( "Close Wallet", "Closing your wallet will clear all user data, ensure you have saved your wallet and certification files first!", "I understand, close my wallet!", diff --git a/src/BolWallet/Services/LogExtractor.cs b/src/BolWallet/Services/LogExtractor.cs new file mode 100644 index 00000000..6d47dfe1 --- /dev/null +++ b/src/BolWallet/Services/LogExtractor.cs @@ -0,0 +1,48 @@ +using System.IO.Compression; +using BolWallet.Models.Messages; +using CommunityToolkit.Maui.Alerts; +using CommunityToolkit.Maui.Storage; +using CommunityToolkit.Mvvm.Messaging; + +namespace BolWallet.Services; + +public class LogExtractor : ILogExtractor, IRecipient +{ + private readonly TimeProvider _timeProvider; + private readonly IFileSaver _fileSaver; + + public LogExtractor( + IMessenger messenger, + TimeProvider timeProvider, + IFileSaver fileSaver) + { + messenger.Register(this); + + _timeProvider = timeProvider; + _fileSaver = fileSaver; + } + + public async Task ExtractLog(CancellationToken token = default) + { + var zipFileName = $"BolWalletLogs_{_timeProvider.GetUtcNow():yyyyMMddHHmmss}.zip"; + var logDirectory = Path.Combine(FileSystem.AppDataDirectory, + "Logs", + AppInfo.Current.Name, + AppInfo.Current.VersionString); + + using var stream = new MemoryStream(); + ZipFile.CreateFromDirectory(logDirectory, stream); + + var result = await _fileSaver.SaveAsync(zipFileName, stream, token); + + if (result.IsSuccessful) + { + await Toast.Make($"File '{zipFileName}' saved successfully!").Show(token); + } + } + + public void Receive(SaveLogfileMessage message) + { + MainThread.BeginInvokeOnMainThread(() => _ = ExtractLog()); + } +} diff --git a/src/BolWallet/Services/NavigationService.cs b/src/BolWallet/Services/NavigationService.cs index dc8fad99..37b3312a 100644 --- a/src/BolWallet/Services/NavigationService.cs +++ b/src/BolWallet/Services/NavigationService.cs @@ -16,7 +16,7 @@ private static INavigation Navigation { get { - var navigation = Application.Current?.MainPage?.Navigation; + var navigation = Application.Current?.Windows[0].Page?.Navigation; if (navigation is not null) { diff --git a/src/BolWallet/Services/PermissionServices/BasePermissionService.cs b/src/BolWallet/Services/PermissionServices/BasePermissionService.cs index 72bc5dca..222846a4 100644 --- a/src/BolWallet/Services/PermissionServices/BasePermissionService.cs +++ b/src/BolWallet/Services/PermissionServices/BasePermissionService.cs @@ -38,7 +38,7 @@ public abstract class BasePermissionService : IPermissionService { var permissionName = typeof(T).Name; - var accepted = await Application.Current.MainPage.DisplayAlert( + var accepted = await Application.Current.Windows[0].Page.DisplayAlert( "Permission Required", $"To continue, please give {permissionName} permissions for this app in your device settings.", "Open Settings", diff --git a/src/BolWallet/ViewModels/BolCommunityViewModel.cs b/src/BolWallet/ViewModels/BolCommunityViewModel.cs index fcfb0af8..9e616936 100644 --- a/src/BolWallet/ViewModels/BolCommunityViewModel.cs +++ b/src/BolWallet/ViewModels/BolCommunityViewModel.cs @@ -53,13 +53,13 @@ private async Task NavigateToWhitelistAndCertifyPage() [RelayCommand] private async Task NavigateToRegisterAsCertifierPage() { - await App.Current.MainPage.Navigation.PushAsync(new Views.RegisterAsCertifierPage()); + await App.Current.Windows[0].Page.Navigation.PushAsync(new Views.RegisterAsCertifierPage()); } [RelayCommand] private async Task NavigateToAddMultiCitizenship() { - await App.Current.MainPage.Navigation.PushAsync(new Views.AddMultiCitizenship()); + await App.Current.Windows[0].Page.Navigation.PushAsync(new Views.AddMultiCitizenship()); } [RelayCommand] @@ -79,6 +79,6 @@ private async Task UnRegisterAsCertifier(CancellationToken token) [RelayCommand] private async Task CompleteBolLoginChallenge() { - await App.Current.MainPage.Navigation.PushAsync(new Views.CompleteBolLoginChallengePage()); + await App.Current.Windows[0].Page.Navigation.PushAsync(new Views.CompleteBolLoginChallengePage()); } } diff --git a/src/BolWallet/ViewModels/GetCertifiedViewModel.cs b/src/BolWallet/ViewModels/GetCertifiedViewModel.cs index 23438d6c..0aacab31 100644 --- a/src/BolWallet/ViewModels/GetCertifiedViewModel.cs +++ b/src/BolWallet/ViewModels/GetCertifiedViewModel.cs @@ -1,6 +1,8 @@ using Bol.Core.Abstractions; using Bol.Core.Model; +using BolWallet.Models.Messages; using CommunityToolkit.Maui.Alerts; +using CommunityToolkit.Mvvm.Messaging; namespace BolWallet.ViewModels; public partial class GetCertifiedViewModel : BaseViewModel @@ -9,18 +11,21 @@ public partial class GetCertifiedViewModel : BaseViewModel private readonly IBolService _bolService; private readonly IFileDownloadService _fileDownloadService; private readonly ICloseWalletService _closeWalletService; + private readonly IMessenger _messenger; public GetCertifiedViewModel( INavigationService navigationService, ISecureRepository secureRepository, IBolService bolService, IFileDownloadService fileDownloadService, - ICloseWalletService closeWalletService) : base(navigationService) + ICloseWalletService closeWalletService, + IMessenger messenger) : base(navigationService) { _secureRepository = secureRepository; _bolService = bolService; _fileDownloadService = fileDownloadService; _closeWalletService = closeWalletService; + _messenger = messenger; } [ObservableProperty] @@ -290,6 +295,12 @@ private async Task DownloadBolWalletAsync(CancellationToken cancellationToken = [RelayCommand] private async Task CloseWallet() => await _closeWalletService.CloseWallet(); + + [RelayCommand] + private void SaveLogfile() + { + _ = _messenger.Send(Constants.SaveLogfileMessage); + } } public class CertifierListItem diff --git a/src/BolWallet/ViewModels/MainViewModel.cs b/src/BolWallet/ViewModels/MainViewModel.cs index b2e4abbd..00b18f8a 100644 --- a/src/BolWallet/ViewModels/MainViewModel.cs +++ b/src/BolWallet/ViewModels/MainViewModel.cs @@ -1,4 +1,5 @@ using Bol.Core.Abstractions; +using BolWallet.Models.Messages; using CommunityToolkit.Maui.Alerts; using CommunityToolkit.Maui.Views; using CommunityToolkit.Mvvm.Messaging; @@ -61,7 +62,7 @@ private async Task TrySetBolContractHash() [RelayCommand] private async Task SwitchNetwork() { - var prompt = await Application.Current.MainPage.DisplayPromptAsync( + var prompt = await Application.Current.Windows[0].Page.DisplayPromptAsync( "Network Change", $"You are currently connected to {_networkPreferences.Name}." + $"{Environment.NewLine}{Environment.NewLine}" + @@ -73,7 +74,7 @@ private async Task SwitchNetwork() if (string.IsNullOrWhiteSpace(prompt) || !prompt.Equals(_networkPreferences.AlternativeName)) { - await Application.Current.MainPage.DisplayAlert("Network Change", + await Application.Current.Windows[0].Page.DisplayAlert("Network Change", $"{_networkPreferences.AlternativeName} network name wasn't verified, no switch will occur.", "OK"); @@ -91,7 +92,7 @@ await Application.Current.MainPage.DisplayAlert("Network Change", LoadingText = string.Empty; IsLoading = false; - await Application.Current.MainPage.DisplayAlert("Network Change", + await Application.Current.Windows[0].Page.DisplayAlert("Network Change", $"Switch to {_networkPreferences.Name} network completed successfully.", "OK"); } @@ -105,7 +106,7 @@ private async Task NavigateToCodenameCompanyPage() [RelayCommand] private async Task NavigateToWalletCreationInfoPage() { - await App.Current.MainPage.Navigation.PushAsync(new Views.WalletCreationInfo()); + await App.Current.Windows[0].Page.Navigation.PushAsync(new Views.WalletCreationInfo()); } [RelayCommand] @@ -131,19 +132,40 @@ private async Task ImportYourWallet() var jsonString = await File.ReadAllTextAsync(pickResult.FullPath); - var passwordPopup = new PasswordPopup(); - await Application.Current.MainPage.ShowPopupAsync(passwordPopup); - var password = await passwordPopup.TaskCompletionSource.Task; - - if (string.IsNullOrEmpty(password)) return; + // var passwordPopup = new PasswordPopup(); + // await Application.Current.MainPage.ShowPopupAsync(passwordPopup); + // var password = await passwordPopup.TaskCompletionSource.Task; + string password; + while(true) + { + password = await Application.Current.Windows[0].Page.DisplayPromptAsync( + "Unlock Wallet", + "Type your password to unlock your wallet.", + keyboard: Keyboard.Password, + initialValue: "", + accept: "OK, unlock my wallet!", + cancel: "Cancel"); + + if (password is null) + { + return; + } + + password = password.Trim(); + if (password is { Length: > 0 } ) + { + break; + } + } + IsLoading = true; LoadingText = "Unlocking your wallet... Please wait."; var validPassword = await Task.Run(() => _walletService.CheckWalletPassword(jsonString, password)); if (!validPassword) { - await Application.Current.MainPage.DisplayAlert( + await Application.Current.Windows[0].Page.DisplayAlert( "Incorrect Password", "Please provide a valid password.", "OK"); @@ -169,6 +191,12 @@ await Application.Current.MainPage.DisplayAlert( LoadingText = String.Empty; } } + + [RelayCommand] + private void SaveLogfile() + { + _ = _messenger.Send(Constants.SaveLogfileMessage); + } private void SetTitleMessage() { diff --git a/src/BolWallet/ViewModels/MainWithAccountViewModel.cs b/src/BolWallet/ViewModels/MainWithAccountViewModel.cs index a705380f..c1e5577c 100644 --- a/src/BolWallet/ViewModels/MainWithAccountViewModel.cs +++ b/src/BolWallet/ViewModels/MainWithAccountViewModel.cs @@ -2,7 +2,9 @@ using Bol.Core.Abstractions; using Bol.Core.Model; using Bol.Core.Rpc.Model; +using BolWallet.Models.Messages; using CommunityToolkit.Maui.Alerts; +using CommunityToolkit.Mvvm.Messaging; namespace BolWallet.ViewModels; public partial class MainWithAccountViewModel : BaseViewModel, IDisposable @@ -13,7 +15,8 @@ public partial class MainWithAccountViewModel : BaseViewModel, IDisposable private readonly IAddressTransformer _addressTransformer; private readonly INetworkPreferences _networkPreferences; private readonly ICloseWalletService _closeWalletService; - + private readonly IMessenger _messenger; + private readonly CancellationTokenSource _cts = new(); public string WelcomeText => "Welcome"; @@ -65,7 +68,8 @@ public MainWithAccountViewModel( IDeviceDisplay deviceDisplay, IAddressTransformer addressTransformer, INetworkPreferences networkPreferences, - ICloseWalletService closeWalletService) + ICloseWalletService closeWalletService, + IMessenger messenger) : base(navigationService) { _secureRepository = secureRepository; @@ -74,6 +78,7 @@ public MainWithAccountViewModel( _addressTransformer = addressTransformer; _networkPreferences = networkPreferences; _closeWalletService = closeWalletService; + _messenger = messenger; } [RelayCommand] @@ -261,13 +266,19 @@ private async Task NavigateToAccountPage() { await NavigationService.NavigateTo(true); } + + [RelayCommand] + private void SaveLogfile() + { + _ = _messenger.Send(Constants.SaveLogfileMessage); + } [RelayCommand] private async Task CloseWallet() { await _cts.CancelAsync(); await _closeWalletService.CloseWallet(); - } + } public void Dispose() { diff --git a/src/BolWallet/ViewModels/PasswordPopup.cs b/src/BolWallet/ViewModels/PasswordPopup.cs index c510b2ec..bb9498f5 100644 --- a/src/BolWallet/ViewModels/PasswordPopup.cs +++ b/src/BolWallet/ViewModels/PasswordPopup.cs @@ -8,6 +8,8 @@ public sealed class PasswordPopup : Popup public PasswordPopup() { + CanBeDismissedByTappingOutsideOfPopup = false; + Color primaryBlue = Color.FromArgb("#0078D7"); Color accentBlue = Color.FromArgb("#0052CC"); @@ -97,33 +99,25 @@ public PasswordPopup() var container = new AbsoluteLayout { - HorizontalOptions = LayoutOptions.CenterAndExpand, - VerticalOptions = LayoutOptions.CenterAndExpand, - Margin = new Thickness(20, 100), - WidthRequest = 300, - HeightRequest = 400, Children = - { - boxView, - new VerticalStackLayout { - Children = { titleLabel, stackLayout }, - Spacing = 10, - Padding = new Thickness(12) + boxView, + new VerticalStackLayout + { + Children = { titleLabel, stackLayout }, + Spacing = 10, + Padding = new Thickness(12), + HorizontalOptions = LayoutOptions.CenterAndExpand, + VerticalOptions = LayoutOptions.CenterAndExpand, + Margin = new Thickness(20, 100), + WidthRequest = 300, + HeightRequest = 400, + } } - } }; Content = container; } - - protected override Task OnDismissedByTappingOutsideOfPopup(CancellationToken token) - { - base.OnDismissedByTappingOutsideOfPopup(token); - - TaskCompletionSource.TrySetResult(null); - return Task.CompletedTask; - } } diff --git a/src/BolWallet/ViewModels/PreloadViewModel.cs b/src/BolWallet/ViewModels/PreloadViewModel.cs index 31824bab..6203cc44 100644 --- a/src/BolWallet/ViewModels/PreloadViewModel.cs +++ b/src/BolWallet/ViewModels/PreloadViewModel.cs @@ -55,11 +55,11 @@ async Task LoadAndNavigate() if (userData?.BolWallet == null) { - await NavigationService.NavigateTo(changeRoot: true); + await NavigationService.NavigateTo(); } else { - await NavigationService.NavigateTo(changeRoot: true); + await NavigationService.NavigateTo(); } } } diff --git a/src/BolWallet/Views/BolCommunityPage.xaml b/src/BolWallet/Views/BolCommunityPage.xaml index ce84a7f6..6476f1f3 100644 --- a/src/BolWallet/Views/BolCommunityPage.xaml +++ b/src/BolWallet/Views/BolCommunityPage.xaml @@ -22,7 +22,6 @@