From 8be8abb8fe6748efcfb9a62fdd997465e093945d Mon Sep 17 00:00:00 2001 From: Dinis Vieira Date: Fri, 20 Oct 2023 00:04:19 +0100 Subject: [PATCH] PM-3350 Migrated some Device to DeviceInfo and added temporary workaround with some comments to be able to see the Generated Password on iOS --- src/Core/Controls/MonoLabel.cs | 23 +++++++++---------- src/Core/Utilities/GeneratedValueFormatter.cs | 11 +++------ 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/Core/Controls/MonoLabel.cs b/src/Core/Controls/MonoLabel.cs index 09c760b53..35a26fd02 100644 --- a/src/Core/Controls/MonoLabel.cs +++ b/src/Core/Controls/MonoLabel.cs @@ -1,21 +1,20 @@ -using Microsoft.Maui.Controls; -using Microsoft.Maui; - -namespace Bit.App.Controls +namespace Bit.App.Controls { public class MonoLabel : Label { public MonoLabel() { - // 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 - switch (Device.RuntimePlatform) + if (DeviceInfo.Platform == DevicePlatform.iOS) { - case Device.iOS: - FontFamily = "Menlo-Regular"; - break; - case Device.Android: - FontFamily = "RobotoMono_Regular.ttf"; - break; + FontFamily = "Menlo-Regular"; + + //[MAUI-Migration] Temporary Workaround for the Text to appear in iOS. + // A proper solution needs to be found to be able to have html text with different colors or alternatively use Label FormattedString Spans + TextColor = Colors.Black; + } + else if (DeviceInfo.Platform == DevicePlatform.Android) + { + FontFamily = "RobotoMono_Regular.ttf"; } } } diff --git a/src/Core/Utilities/GeneratedValueFormatter.cs b/src/Core/Utilities/GeneratedValueFormatter.cs index 6f0199ea4..20f2d12aa 100644 --- a/src/Core/Utilities/GeneratedValueFormatter.cs +++ b/src/Core/Utilities/GeneratedValueFormatter.cs @@ -1,7 +1,4 @@ -using System; -using System.Web; -using Microsoft.Maui.Controls; -using Microsoft.Maui; +using System.Web; namespace Bit.App.Utilities { @@ -39,8 +36,7 @@ namespace Bit.App.Utilities // iOS won't hide the zero-width space char without these div attrs, but Android won't respect // display:inline-block and adds a newline after the password/username. Hence, only iOS gets the div. - // 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 (Device.RuntimePlatform == Device.iOS) + if (DeviceInfo.Platform == DevicePlatform.iOS) { result += "
"; } @@ -114,8 +110,7 @@ namespace Bit.App.Utilities } // Close off iOS div - // 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 (Device.RuntimePlatform == Device.iOS) + if (DeviceInfo.Platform == DevicePlatform.iOS) { result += "
"; }