diff --git a/src/Maui/Bitwarden/App.xaml.cs b/src/Maui/Bitwarden/App.xaml.cs index 21daf9229..c1882d975 100644 --- a/src/Maui/Bitwarden/App.xaml.cs +++ b/src/Maui/Bitwarden/App.xaml.cs @@ -18,6 +18,7 @@ using Bit.Core.Utilities; using Microsoft.Maui.Controls.Xaml; using Microsoft.Maui.Controls; using Microsoft.Maui; +using Bit.App.Handlers; [assembly: XamlCompilation(XamlCompilationOptions.Compile)] namespace Bit.App @@ -51,6 +52,7 @@ namespace Bit.App public App(AppOptions appOptions) { + App.SetupHandlers(); Options = appOptions ?? new AppOptions(); if (Options.IosExtension) { @@ -200,6 +202,21 @@ namespace Bit.App }); } + private static void SetupHandlers() + { + new EntryHandlerMappings().Setup(); + new EditorHandlerMappings().Setup(); + new LabelHandlerMappings().Setup(); + new PickerHandlerMappings().Setup(); + new SearchBarHandlerMappings().Setup(); + new SwitchHandlerMappings().Setup(); + new DatePickerHandlerMappings().Setup(); + new SliderHandlerMappings().Setup(); + new StepperHandlerMappings().Setup(); + new TimePickerHandlerMappings().Setup(); + new ButtonHandlerMappings().Setup(); + } + private async Task CheckPasswordlessLoginRequestsAsync() { if (!_isResumed) diff --git a/src/Maui/Bitwarden/Bitwarden.csproj b/src/Maui/Bitwarden/Bitwarden.csproj index 3f4fde0cf..6b2b490ba 100644 --- a/src/Maui/Bitwarden/Bitwarden.csproj +++ b/src/Maui/Bitwarden/Bitwarden.csproj @@ -304,6 +304,8 @@ + + @@ -316,6 +318,8 @@ + + diff --git a/src/Maui/Bitwarden/Controls/HybridWebView.cs b/src/Maui/Bitwarden/Controls/HybridWebView.cs index 801d9b2f6..d292f7498 100644 --- a/src/Maui/Bitwarden/Controls/HybridWebView.cs +++ b/src/Maui/Bitwarden/Controls/HybridWebView.cs @@ -1,8 +1,4 @@ -using System; -using Microsoft.Maui.Controls; -using Microsoft.Maui; - -namespace Bit.App.Controls +namespace Bit.App.Controls { public class HybridWebView : View { diff --git a/src/Maui/Bitwarden/Controls/IconButton.cs b/src/Maui/Bitwarden/Controls/IconButton.cs index faa4ab8ed..0c9d106b2 100644 --- a/src/Maui/Bitwarden/Controls/IconButton.cs +++ b/src/Maui/Bitwarden/Controls/IconButton.cs @@ -1,6 +1,4 @@ using Bit.App.Effects; -using Microsoft.Maui.Controls; -using Microsoft.Maui; namespace Bit.App.Controls { @@ -9,17 +7,7 @@ namespace Bit.App.Controls public IconButton() { Padding = 0; - // 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) - { - case Device.iOS: - FontFamily = "bwi-font"; - break; - case Device.Android: - FontFamily = "bwi-font"; - break; - } - + FontFamily = "bwi-font"; Effects.Add(new RemoveFontPaddingEffect()); } } diff --git a/src/Maui/Bitwarden/Controls/IconLabel.cs b/src/Maui/Bitwarden/Controls/IconLabel.cs index 3df6881ec..404e491e3 100644 --- a/src/Maui/Bitwarden/Controls/IconLabel.cs +++ b/src/Maui/Bitwarden/Controls/IconLabel.cs @@ -1,6 +1,4 @@ using Bit.App.Effects; -using Microsoft.Maui.Controls; -using Microsoft.Maui; namespace Bit.App.Controls { @@ -10,17 +8,7 @@ namespace Bit.App.Controls public IconLabel() { - // 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) - { - case Device.iOS: - FontFamily = "bwi-font"; - break; - case Device.Android: - FontFamily = "bwi-font"; - break; - } - + FontFamily = "bwi-font"; Effects.Add(new RemoveFontPaddingEffect()); } } diff --git a/src/Maui/Bitwarden/Controls/MiButton.cs b/src/Maui/Bitwarden/Controls/MiButton.cs index a181ab177..0618475d0 100644 --- a/src/Maui/Bitwarden/Controls/MiButton.cs +++ b/src/Maui/Bitwarden/Controls/MiButton.cs @@ -1,23 +1,15 @@ -using Microsoft.Maui.Controls; -using Microsoft.Maui; - -namespace Bit.App.Controls +namespace Bit.App.Controls { public class MiButton : Button { public MiButton() { Padding = 0; - // 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) - { - case Device.iOS: - FontFamily = "Material Icons"; - break; - case Device.Android: - FontFamily = "MaterialIcons_Regular"; - break; - } +#if ANDROID + FontFamily = "MaterialIcons_Regular"; +#else + FontFamily = "Material Icons"; +#endif } } } diff --git a/src/Maui/Bitwarden/Effects/FixedSizeEffect.cs b/src/Maui/Bitwarden/Effects/FixedSizeEffect.cs index 7cfb83e97..7ca5beca7 100644 --- a/src/Maui/Bitwarden/Effects/FixedSizeEffect.cs +++ b/src/Maui/Bitwarden/Effects/FixedSizeEffect.cs @@ -20,7 +20,7 @@ namespace Bit.App.Effects { if (Element is Label label && Control is TextView textView) { - textView.SetTextSize(Android.Util.ComplexUnitType.Pt, (float)label.FontSize); + textView.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)label.FontSize); } } diff --git a/src/Maui/Bitwarden/Handlers/ButtonHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/ButtonHandlerMappings.cs new file mode 100644 index 000000000..a5a83001e --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/ButtonHandlerMappings.cs @@ -0,0 +1,9 @@ +namespace Bit.App.Handlers +{ + public partial class ButtonHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} diff --git a/src/Maui/Bitwarden/Handlers/DatePickerHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/DatePickerHandlerMappings.cs new file mode 100644 index 000000000..ebfc65a73 --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/DatePickerHandlerMappings.cs @@ -0,0 +1,9 @@ +namespace Bit.App.Handlers +{ + public partial class DatePickerHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} diff --git a/src/Maui/Bitwarden/Handlers/EditorHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/EditorHandlerMappings.cs new file mode 100644 index 000000000..f98d21941 --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/EditorHandlerMappings.cs @@ -0,0 +1,10 @@ +namespace Bit.App.Handlers +{ + public partial class EditorHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} + diff --git a/src/Maui/Bitwarden/Handlers/EntryHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/EntryHandlerMappings.cs new file mode 100644 index 000000000..63a998490 --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/EntryHandlerMappings.cs @@ -0,0 +1,9 @@ +namespace Bit.App.Handlers +{ + public partial class EntryHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} diff --git a/src/Maui/Bitwarden/Handlers/LabelHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/LabelHandlerMappings.cs new file mode 100644 index 000000000..4ef02c802 --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/LabelHandlerMappings.cs @@ -0,0 +1,9 @@ +namespace Bit.App.Handlers +{ + public partial class LabelHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} diff --git a/src/Maui/Bitwarden/Handlers/PickerHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/PickerHandlerMappings.cs new file mode 100644 index 000000000..d293cfcab --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/PickerHandlerMappings.cs @@ -0,0 +1,9 @@ +namespace Bit.App.Handlers +{ + public partial class PickerHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} diff --git a/src/Maui/Bitwarden/Handlers/SearchBarHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/SearchBarHandlerMappings.cs new file mode 100644 index 000000000..4bef2add2 --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/SearchBarHandlerMappings.cs @@ -0,0 +1,10 @@ +namespace Bit.App.Handlers +{ + public partial class SearchBarHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} + diff --git a/src/Maui/Bitwarden/Handlers/SliderHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/SliderHandlerMappings.cs new file mode 100644 index 000000000..f630ed52f --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/SliderHandlerMappings.cs @@ -0,0 +1,9 @@ +namespace Bit.App.Handlers +{ + public partial class SliderHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} diff --git a/src/Maui/Bitwarden/Handlers/StepperHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/StepperHandlerMappings.cs new file mode 100644 index 000000000..0e5f67058 --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/StepperHandlerMappings.cs @@ -0,0 +1,10 @@ +namespace Bit.App.Handlers +{ + public partial class StepperHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} + diff --git a/src/Maui/Bitwarden/Handlers/SwitchHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/SwitchHandlerMappings.cs new file mode 100644 index 000000000..9b0067d69 --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/SwitchHandlerMappings.cs @@ -0,0 +1,9 @@ +namespace Bit.App.Handlers +{ + public partial class SwitchHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} diff --git a/src/Maui/Bitwarden/Handlers/TimePickerHandlerMappings.cs b/src/Maui/Bitwarden/Handlers/TimePickerHandlerMappings.cs new file mode 100644 index 000000000..7d9b952ce --- /dev/null +++ b/src/Maui/Bitwarden/Handlers/TimePickerHandlerMappings.cs @@ -0,0 +1,9 @@ +namespace Bit.App.Handlers +{ + public partial class TimePickerHandlerMappings + { + public void Setup() => SetupPlatform(); + + partial void SetupPlatform(); + } +} diff --git a/src/Maui/Bitwarden/Pages/Settings/SettingsPage/SettingsPageListItem.cs b/src/Maui/Bitwarden/Pages/Settings/SettingsPage/SettingsPageListItem.cs index fb0d8d862..9817fcdac 100644 --- a/src/Maui/Bitwarden/Pages/Settings/SettingsPage/SettingsPageListItem.cs +++ b/src/Maui/Bitwarden/Pages/Settings/SettingsPage/SettingsPageListItem.cs @@ -19,8 +19,8 @@ namespace Bit.App.Pages public Func ExecuteAsync { get; set; } public bool SubLabelTextEnabled => SubLabel == AppResources.On; - public string LineBreakMode => SubLabel == null ? "TailTruncation" : ""; - public bool ShowSubLabel => SubLabel.Length != 0; + public LineBreakMode LineBreakMode => SubLabel == null ? LineBreakMode.TailTruncation : LineBreakMode.NoWrap; + public bool ShowSubLabel => SubLabel != null && SubLabel.Length != 0; public bool ShowTimeInput => Time != null; public Color SubLabelColor => SubLabelTextEnabled ? ThemeManager.GetResourceColor("SuccessColor") : diff --git a/src/Maui/Bitwarden/Pages/Vault/CipherAddEditPage.xaml b/src/Maui/Bitwarden/Pages/Vault/CipherAddEditPage.xaml index 717d4133f..8160df3d8 100644 --- a/src/Maui/Bitwarden/Pages/Vault/CipherAddEditPage.xaml +++ b/src/Maui/Bitwarden/Pages/Vault/CipherAddEditPage.xaml @@ -132,7 +132,7 @@ AutomationProperties.Name="{u:I18n Name}" AutomationId="ItemNameEntry" /> - + @@ -308,10 +308,11 @@ AutomationProperties.Name="{u:I18n ScanQrTitle}" /> - - + + +