From 455c3a257cc41bf7a0a55120bc8b42e1b2bdf9e3 Mon Sep 17 00:00:00 2001 From: Dinis Vieira Date: Tue, 17 Oct 2023 22:23:04 +0100 Subject: [PATCH] PM-3350 Migrated the CustomViewCellRenderer for iOS --- .../Handlers/CustomNavigationHandler.cs | 2 +- .../Handlers/CustomViewCellHandler.cs | 26 +++++++++++++++++++ src/iOS.Core/Utilities/iOSCoreHelpers.cs | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/iOS.Core/Handlers/CustomViewCellHandler.cs diff --git a/src/iOS.Core/Handlers/CustomNavigationHandler.cs b/src/iOS.Core/Handlers/CustomNavigationHandler.cs index cc2919480..5b4769eba 100644 --- a/src/iOS.Core/Handlers/CustomNavigationHandler.cs +++ b/src/iOS.Core/Handlers/CustomNavigationHandler.cs @@ -5,7 +5,7 @@ using UIKit; namespace Bit.iOS.Core.Handlers { - //This is a Compatibility verion of the NavigationRenderer. Eventually we should see if there's a better way to implement this behavior. + //This is a Compatibility version of the NavigationRenderer. Eventually we should see if there's a better way to implement this behavior. public class CustomNavigationHandler : Microsoft.Maui.Controls.Handlers.Compatibility.NavigationRenderer { public override void PushViewController(UIViewController viewController, bool animated) diff --git a/src/iOS.Core/Handlers/CustomViewCellHandler.cs b/src/iOS.Core/Handlers/CustomViewCellHandler.cs new file mode 100644 index 000000000..184f6063e --- /dev/null +++ b/src/iOS.Core/Handlers/CustomViewCellHandler.cs @@ -0,0 +1,26 @@ +using Bit.App.Utilities; +using UIKit; + +namespace Bit.iOS.Core.Handlers +{ + //This is a Compatibility version of the ViewCellRenderer. Eventually we should see if there's a better way to implement this behavior. + public class CustomViewCellHandler : Microsoft.Maui.Controls.Handlers.Compatibility.ViewCellRenderer + { + private bool _noSelectionStyle = false; + + public CustomViewCellHandler() + { + _noSelectionStyle = !(ThemeManager.GetResourceColor("BackgroundColor").Equals(Colors.White)); + } + + public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv) + { + var cell = base.GetCell(item, reusableCell, tv); + if (_noSelectionStyle) + { + cell.SelectionStyle = UITableViewCellSelectionStyle.None; + } + return cell; + } + } +} diff --git a/src/iOS.Core/Utilities/iOSCoreHelpers.cs b/src/iOS.Core/Utilities/iOSCoreHelpers.cs index dcce807c0..3350d1332 100644 --- a/src/iOS.Core/Utilities/iOSCoreHelpers.cs +++ b/src/iOS.Core/Utilities/iOSCoreHelpers.cs @@ -47,6 +47,7 @@ namespace Bit.iOS.Core.Utilities { handlers.AddHandler(typeof(TabsPage), typeof(Handlers.CustomTabbedHandler)); handlers.AddHandler(typeof(NavigationPage), typeof(Handlers.CustomNavigationHandler)); + handlers.AddHandler(typeof(ViewCell), typeof(Handlers.CustomViewCellHandler)); handlers.AddHandler(typeof(ContentPage), typeof(Handlers.CustomContentPageHandler)); Handlers.ButtonHandlerMappings.Setup(); Handlers.DatePickerHandlerMappings.Setup();