diff --git a/src/Core/Controls/AccountViewCell/AccountViewCell.xaml b/src/Core/Controls/AccountViewCell/AccountViewCell.xaml index 05071fb4b..6cf828773 100644 --- a/src/Core/Controls/AccountViewCell/AccountViewCell.xaml +++ b/src/Core/Controls/AccountViewCell/AccountViewCell.xaml @@ -11,10 +11,10 @@ - + + LongPressCommandParameter="{Binding BindingContext, Source={x:Reference _accountView}}" /> diff --git a/src/Core/Controls/AvatarImageSource.cs b/src/Core/Controls/AvatarImageSource.cs index a4ec525eb..9f3ee89cb 100644 --- a/src/Core/Controls/AvatarImageSource.cs +++ b/src/Core/Controls/AvatarImageSource.cs @@ -48,7 +48,7 @@ namespace Bit.App.Controls private Task GetStreamAsync(CancellationToken userToken = new CancellationToken()) { - // TODO: [MAUI-Migration] [Critical] now methods are private protected so cannot be used here, figure out workaround + // TODO: [MAUI-Avatar] now methods are private protected so cannot be used here, figure out workaround //OnLoadingStarted(); //userToken.Register(CancellationTokenSource.Cancel); var result = Draw(); diff --git a/src/Core/Controls/ExtendedGrid.cs b/src/Core/Controls/ExtendedGrid.cs index 5e2208dec..f7d221ad1 100644 --- a/src/Core/Controls/ExtendedGrid.cs +++ b/src/Core/Controls/ExtendedGrid.cs @@ -6,16 +6,15 @@ namespace Bit.App.Controls { public ExtendedGrid() { +#if ANDROID // Add Android Ripple effect. Eventually we should be able to replace this with the Maui Community Toolkit implementation. (https://github.com/CommunityToolkit/Maui/issues/86) - // [MAUI-Migration] When this TouchBehavior is replaced we can delete the existing TouchBehavior support files (which is all the files and folders inside "Core.Behaviors.PlatformBehaviors.MCTTouch.*") - if (DeviceInfo.Platform == DevicePlatform.Android) + // TODO: [TouchEffect] When this TouchBehavior is replaced we can delete the existing TouchBehavior support files (which is all the files and folders inside "Core.Behaviors.PlatformBehaviors.MCTTouch.*") + var touchBehavior = new TouchBehavior() { - var touchBehavior = new TouchBehavior() - { - NativeAnimation = true - }; - Behaviors.Add(touchBehavior); - } + NativeAnimation = true + }; + Behaviors.Add(touchBehavior); +#endif } } } diff --git a/src/Core/Controls/ExtendedStackLayout.cs b/src/Core/Controls/ExtendedStackLayout.cs index 5709e0a97..6cb6c4343 100644 --- a/src/Core/Controls/ExtendedStackLayout.cs +++ b/src/Core/Controls/ExtendedStackLayout.cs @@ -6,16 +6,15 @@ namespace Bit.App.Controls { public ExtendedStackLayout() { +#if ANDROID // Add Android Ripple effect. Eventually we should be able to replace this with the Maui Community Toolkit implementation. (https://github.com/CommunityToolkit/Maui/issues/86) - // [MAUI-Migration] When this TouchBehavior is replaced we can delete the existing TouchBehavior support files (which is all the files and folders inside "Core.Behaviors.PlatformBehaviors.MCTTouch.*") - if (DeviceInfo.Platform == DevicePlatform.Android) + // TODO: [TouchEffect] When this TouchBehavior is replaced we can delete the existing TouchBehavior support files (which is all the files and folders inside "Core.Behaviors.PlatformBehaviors.MCTTouch.*") + var touchBehavior = new TouchBehavior() { - var touchBehavior = new TouchBehavior() - { - NativeAnimation = true - }; - Behaviors.Add(touchBehavior); - } + NativeAnimation = true + }; + Behaviors.Add(touchBehavior); +#endif } } } diff --git a/src/Core/Pages/Send/SendAddEditPage.xaml b/src/Core/Pages/Send/SendAddEditPage.xaml index 5580b1d5f..c858234e2 100644 --- a/src/Core/Pages/Send/SendAddEditPage.xaml +++ b/src/Core/Pages/Send/SendAddEditPage.xaml @@ -248,7 +248,6 @@ AutomationId="SendHideTextByDefaultToggle" /> - + @@ -35,7 +35,6 @@ #175DDC #efeff4 - #ffffff #b5b5b5 #175DDC diff --git a/src/Core/Services/Logging/Logger.cs b/src/Core/Services/Logging/Logger.cs index bb2566687..7b9a7f5c8 100644 --- a/src/Core/Services/Logging/Logger.cs +++ b/src/Core/Services/Logging/Logger.cs @@ -64,7 +64,7 @@ namespace Bit.Core.Services _userId = await ServiceContainer.Resolve("stateService").GetActiveUserIdAsync(); _appId = await ServiceContainer.Resolve("appIdService").GetAppIdAsync(); - // TODO: [MAUI-Migration] [Critical] + // TODO: [Error-Reporting] //switch (device) //{ // case Enums.DeviceType.Android: diff --git a/src/Core/Services/Logging/LoggerHelper.cs b/src/Core/Services/Logging/LoggerHelper.cs index f0873af3e..c8dad80e8 100644 --- a/src/Core/Services/Logging/LoggerHelper.cs +++ b/src/Core/Services/Logging/LoggerHelper.cs @@ -22,7 +22,7 @@ namespace Bit.Core.Services #if !FDROID // just in case the caller throws the exception in a moment where the logger can't be resolved // we need to track the error as well - // [MAUI-Migration] [Critical] + // TODO: [Error-Reporting] //Microsoft.AppCenter.Crashes.Crashes.TrackError(ex); #endif diff --git a/src/Core/Utilities/AccountManagement/AccountsManager.cs b/src/Core/Utilities/AccountManagement/AccountsManager.cs index 7d84e024a..34a4df975 100644 --- a/src/Core/Utilities/AccountManagement/AccountsManager.cs +++ b/src/Core/Utilities/AccountManagement/AccountsManager.cs @@ -1,14 +1,10 @@ -using System; -using System.Threading.Tasks; -using Bit.App.Abstractions; +using Bit.App.Abstractions; using Bit.App.Models; -using Bit.Core.Resources.Localization; using Bit.Core.Abstractions; using Bit.Core.Enums; using Bit.Core.Models.Domain; +using Bit.Core.Resources.Localization; using Bit.Core.Utilities; -using Microsoft.Maui.Controls; -using Microsoft.Maui; namespace Bit.App.Utilities.AccountManagement { @@ -145,7 +141,7 @@ namespace Bit.App.Utilities.AccountManagement switch (message.Command) { case AccountsManagerMessageCommands.LOCKED: - await Device.InvokeOnMainThreadAsync(() => LockedAsync(message.Data as Tuple)); + await MainThread.InvokeOnMainThreadAsync(() => LockedAsync(message.Data as Tuple)); break; case AccountsManagerMessageCommands.LOCK_VAULT: await _vaultTimeoutService.LockAsync(true); @@ -155,7 +151,7 @@ namespace Bit.App.Utilities.AccountManagement var userId = extras?.Item1; var userInitiated = extras?.Item2 ?? true; var expired = extras?.Item3 ?? false; - await Device.InvokeOnMainThreadAsync(() => LogOutAsync(userId, userInitiated, expired)); + await MainThread.InvokeOnMainThreadAsync(() => LogOutAsync(userId, userInitiated, expired)); break; case AccountsManagerMessageCommands.LOGGED_OUT: // Clean up old migrated key if they ever log out. @@ -192,7 +188,7 @@ namespace Bit.App.Utilities.AccountManagement var autoPromptBiometric = !userInitiated; // TODO Xamarin.Forms.Device.RuntimePlatform is no longer supported. Use Microsoft.Maui.Devices.DeviceInfo.Platform instead. For more details see https://learn.microsoft.com/en-us/dotnet/maui/migration/forms-projects#device-changes - if (autoPromptBiometric && Device.RuntimePlatform == Device.iOS) + if (autoPromptBiometric && DeviceInfo.Platform == DevicePlatform.iOS) { var vaultTimeout = await _stateService.GetVaultTimeoutAsync(); if (vaultTimeout == 0) @@ -203,13 +199,13 @@ namespace Bit.App.Utilities.AccountManagement await _accountsManagerHost.SetPreviousPageInfoAsync(); - await Device.InvokeOnMainThreadAsync(() => _accountsManagerHost.Navigate(NavigationTarget.Lock, new LockNavigationParams(autoPromptBiometric))); + await MainThread.InvokeOnMainThreadAsync(() => _accountsManagerHost.Navigate(NavigationTarget.Lock, new LockNavigationParams(autoPromptBiometric))); } private async Task AddAccountAsync() { await AppHelpers.ClearServiceCacheAsync(); - await Device.InvokeOnMainThreadAsync(() => + await MainThread.InvokeOnMainThreadAsync(() => { Options.HideAccountSwitcher = false; _accountsManagerHost.Navigate(NavigationTarget.HomeLogin); @@ -234,7 +230,7 @@ namespace Bit.App.Utilities.AccountManagement private async Task SwitchedAccountAsync() { await AppHelpers.OnAccountSwitchAsync(); - await Device.InvokeOnMainThreadAsync(async () => + await MainThread.InvokeOnMainThreadAsync(async () => { if (await _vaultTimeoutService.ShouldTimeoutAsync()) { diff --git a/src/Core/Utilities/ObservableRangeCollection.cs b/src/Core/Utilities/ObservableRangeCollection.cs index 7eaf9d786..ae4503c1c 100644 --- a/src/Core/Utilities/ObservableRangeCollection.cs +++ b/src/Core/Utilities/ObservableRangeCollection.cs @@ -8,7 +8,8 @@ using System.ComponentModel; namespace Bit.Core.Utilities { - // TODO: [MAUI-Migration] CHECK WHEN MIGRATION IS DONE + // TODO: Review this from time to time in case this gets added to MAUI or some toolkit, for now the api/feature + // has been rejected: https://github.com/CommunityToolkit/dotnet/issues/256 /// /// Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed. diff --git a/src/iOS.Core/Effects/ScrollEnabledEffect.cs b/src/iOS.Core/Effects/ScrollEnabledEffect.cs deleted file mode 100644 index 214473d74..000000000 --- a/src/iOS.Core/Effects/ScrollEnabledEffect.cs +++ /dev/null @@ -1,27 +0,0 @@ -// TODO: [MAUI-Migration] Check if moving this to the main project works for extensions. - -//using Bit.iOS.Core.Effects; -//using UIKit; -//using Xamarin.Forms; -//using Xamarin.Forms.Platform.iOS; - -//[assembly: ResolutionGroupName("Bitwarden")] -//[assembly: ExportEffect(typeof(ScrollEnabledEffect), "ScrollEnabledEffect")] -//namespace Bit.iOS.Core.Effects -//{ -// public class ScrollEnabledEffect : PlatformEffect -// { -// protected override void OnAttached() -// { -// // this can be for any view that inherits from UIScrollView like UITextView. -// if (Element != null && Control is UIScrollView scrollView) -// { -// scrollView.ScrollEnabled = App.Effects.ScrollEnabledEffect.GetIsScrollEnabled(Element); -// } -// } - -// protected override void OnDetached() -// { -// } -// } -//} diff --git a/src/iOS.Core/Effects/ScrollViewContentInsetAdjustmentBehaviorEffect.cs b/src/iOS.Core/Effects/ScrollViewContentInsetAdjustmentBehaviorEffect.cs deleted file mode 100644 index 91167367c..000000000 --- a/src/iOS.Core/Effects/ScrollViewContentInsetAdjustmentBehaviorEffect.cs +++ /dev/null @@ -1,39 +0,0 @@ -// TODO: [MAUI-Migration] Check if moving this to the main project works for extensions. - -//using Bit.iOS.Core.Effects; -//using UIKit; -//using Xamarin.Forms; -//using Xamarin.Forms.Platform.iOS; - -//[assembly: ExportEffect(typeof(ScrollViewContentInsetAdjustmentBehaviorEffect), nameof(ScrollViewContentInsetAdjustmentBehaviorEffect))] -//namespace Bit.iOS.Core.Effects -//{ -// public class ScrollViewContentInsetAdjustmentBehaviorEffect : PlatformEffect -// { -// protected override void OnAttached() -// { -// if (Element != null && Control is UIScrollView scrollView) -// { -// switch (App.Effects.ScrollViewContentInsetAdjustmentBehaviorEffect.GetContentInsetAdjustmentBehavior(Element)) -// { -// case App.Effects.ScrollContentInsetAdjustmentBehavior.Automatic: -// scrollView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Automatic; -// break; -// case App.Effects.ScrollContentInsetAdjustmentBehavior.ScrollableAxes: -// scrollView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.ScrollableAxes; -// break; -// case App.Effects.ScrollContentInsetAdjustmentBehavior.Never: -// scrollView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Never; -// break; -// case App.Effects.ScrollContentInsetAdjustmentBehavior.Always: -// scrollView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Always; -// break; -// } -// } -// } - -// protected override void OnDetached() -// { -// } -// } -//} diff --git a/src/iOS.Core/Utilities/AccountSwitchingOverlayHelper.cs b/src/iOS.Core/Utilities/AccountSwitchingOverlayHelper.cs index e4dafacdc..7171e9f34 100644 --- a/src/iOS.Core/Utilities/AccountSwitchingOverlayHelper.cs +++ b/src/iOS.Core/Utilities/AccountSwitchingOverlayHelper.cs @@ -21,7 +21,7 @@ namespace Bit.iOS.Core.Utilities _logger = ServiceContainer.Resolve("logger"); } - public async Task CreateAvatarImageAsync() + public async Task CreateAvatarImageAsync() { try { @@ -66,11 +66,11 @@ namespace Bit.iOS.Core.Utilities overlay.BindingContext = vm; overlay.IsVisible = false; - // TODO: [MAUI-Migration] [Critical] check how to create a native view here. - //var renderer = Platform.CreateRenderer(overlay.Content); - //renderer.SetElementSize(new Size(containerView.Frame.Size.Width, containerView.Frame.Size.Height)); + if (MauiContextSingleton.Instance.MauiContext is null) + { + throw new ArgumentNullException("Maui context should be set to create the account switching overlay view"); + } - //var view = renderer.NativeView; var view = overlay.ToPlatform(MauiContextSingleton.Instance.MauiContext); view.TranslatesAutoresizingMaskIntoConstraints = false; diff --git a/src/iOS.Core/Utilities/FontElementExtensions.cs b/src/iOS.Core/Utilities/FontElementExtensions.cs index 2481d0211..a3fd70a77 100644 --- a/src/iOS.Core/Utilities/FontElementExtensions.cs +++ b/src/iOS.Core/Utilities/FontElementExtensions.cs @@ -4,8 +4,6 @@ namespace Bit.iOS.Core.Utilities { public static class FontElementExtensions { - // TODO: [MAUI-Migration] [Critical] Compiling but big untested change - public static UIFont ToUIFont(this Microsoft.Maui.Font font) { var fontSize = font.Size; diff --git a/src/iOS.Core/Utilities/ThemeHelpers.cs b/src/iOS.Core/Utilities/ThemeHelpers.cs index 4acfcfe77..4c389b931 100644 --- a/src/iOS.Core/Utilities/ThemeHelpers.cs +++ b/src/iOS.Core/Utilities/ThemeHelpers.cs @@ -1,64 +1,64 @@ using Bit.App.Utilities; -using Microsoft.Maui.Controls.Compatibility.Platform.iOS; +using Microsoft.Maui.Platform; using UIKit; namespace Bit.iOS.Core.Utilities { public static class ThemeHelpers { - public static bool LightTheme = true; + public static bool LightTheme { get; private set; } = true; public static UIColor SplashBackgroundColor { - get => ThemeManager.GetResourceColor("SplashBackgroundColor").ToUIColor(); + get => ThemeManager.GetResourceColor("SplashBackgroundColor").ToPlatform(); } public static UIColor BackgroundColor { - get => ThemeManager.GetResourceColor("BackgroundColor").ToUIColor(); + get => ThemeManager.GetResourceColor("BackgroundColor").ToPlatform(); } public static UIColor MutedColor { - get => ThemeManager.GetResourceColor("MutedColor").ToUIColor(); + get => ThemeManager.GetResourceColor("MutedColor").ToPlatform(); } public static UIColor SuccessColor { - get => ThemeManager.GetResourceColor("SuccessColor").ToUIColor(); + get => ThemeManager.GetResourceColor("SuccessColor").ToPlatform(); } public static UIColor DangerColor { - get => ThemeManager.GetResourceColor("DangerColor").ToUIColor(); + get => ThemeManager.GetResourceColor("DangerColor").ToPlatform(); } public static UIColor PrimaryColor { - get => ThemeManager.GetResourceColor("PrimaryColor").ToUIColor(); + get => ThemeManager.GetResourceColor("PrimaryColor").ToPlatform(); } public static UIColor TextColor { - get => ThemeManager.GetResourceColor("TextColor").ToUIColor(); + get => ThemeManager.GetResourceColor("TextColor").ToPlatform(); } public static UIColor SeparatorColor { - get => ThemeManager.GetResourceColor("SeparatorColor").ToUIColor(); + get => ThemeManager.GetResourceColor("SeparatorColor").ToPlatform(); } public static UIColor ListHeaderBackgroundColor { - get => ThemeManager.GetResourceColor("ListHeaderBackgroundColor").ToUIColor(); + get => ThemeManager.GetResourceColor("ListHeaderBackgroundColor").ToPlatform(); } public static UIColor NavBarBackgroundColor { - get => ThemeManager.GetResourceColor("NavigationBarBackgroundColor").ToUIColor(); + get => ThemeManager.GetResourceColor("NavigationBarBackgroundColor").ToPlatform(); } public static UIColor NavBarTextColor { - get => ThemeManager.GetResourceColor("NavigationBarTextColor").ToUIColor(); + get => ThemeManager.GetResourceColor("NavigationBarTextColor").ToPlatform(); } public static UIColor TabBarBackgroundColor { - get => ThemeManager.GetResourceColor("TabBarBackgroundColor").ToUIColor(); + get => ThemeManager.GetResourceColor("TabBarBackgroundColor").ToPlatform(); } public static UIColor TabBarItemColor { - get => ThemeManager.GetResourceColor("TabBarItemColor").ToUIColor(); + get => ThemeManager.GetResourceColor("TabBarItemColor").ToPlatform(); } public static void SetAppearance(string theme, bool osDarkModeEnabled) @@ -75,8 +75,7 @@ namespace Bit.iOS.Core.Utilities public static UIFont GetDangerFont() { - // TODO: [MAUI-Migration] [Deprecated] NamedSizes are deprecated on MAUI - return Microsoft.Maui.Font.SystemFontOfSize(Device.GetNamedSize(NamedSize.Small, typeof(UILabel)), FontWeight.Bold).ToUIFont(); + return Microsoft.Maui.Font.SystemFontOfSize(14, FontWeight.Bold).ToUIFont(); } private static void SetThemeVariables(string theme, bool osDarkModeEnabled)