braze-inc / braze-xamarin-sdk

Xamarin bindings for the Braze Android and iOS SDKs
https://www.braze.com
Other
3 stars 8 forks source link

[iOS] Cannot customize the content cards unviewed indicator #9

Open mr-coin-coin opened 3 years ago

mr-coin-coin commented 3 years ago

Hello,

I am using the current last version (1.21.1) of your binding library, and I would like to change the color of the content card unviewed indicator.

I have been following the official documentation for iOS to customize content card, but the thing is that I'm not able to reuse the proposed methods to customize the content card, though they have been marked as "exported" in the ApiDefinition.cs file.

For example, I cannot reuse following methods exposed in the ABKContentCardsTableViewController :

Is it normal ?

Here are some solutions I have tried so far, but still have some issues I'm not able to solve :

Solution 1 ```csharp public class InboxPageRenderer : PageRenderer { ABKContentCardsTableViewController cardsTableViewController; public InboxPageRenderer() { cardsTableViewController = ABKContentCardsTableViewController.GetNavigationContentCardsViewController(); cardsTableViewController.TableView .RegisterClassForCellReuse(typeof(CustomClassicContentCardCell), "ABKClassicCardCell"); } public override void ViewDidLoad() { base.ViewDidLoad(); AddChildViewController(this.cardsTableViewController); View.Add(this.cardsTableViewController.View); } } ```
Solution 2 ```csharp public class InboxPageRenderer : PageRenderer { CustomContentCardsTableViewController cardsTableViewController; public InboxPageRenderer() { cardsTableViewController = new CustomContentCardsTableViewController(IntPtr.Zero); cardsTableViewController.PopulateContentCards(); } public override void ViewDidLoad() { base.ViewDidLoad(); AddChildViewController(cardsTableViewController); View.Add(cardsTableViewController.View); } } public class CustomContentCardsTableViewController : ABKContentCardsTableViewController { public CustomContentCardsTableViewController(IntPtr handle) : base(handle) { this.TableView.RegisterClassForCellReuse(typeof(CustomClassicContentCardCell), "ABKClassicCardCell"); } public override void PopulateContentCards() { NSMutableArray unViewedCards = new NSMutableArray(); foreach (var card in Appboy.SharedInstance.ContentCardsController.ContentCards) { if (card is ABKClassicContentCard classic) { classic.Viewed = false; unViewedCards.Add(classic); } } Cards = unViewedCards; } } ```
And here is my CustomClassicContentCardCell ```csharp public class CustomClassicContentCardCell : ABKClassicContentCardCell { protected CustomClassicContentCardCell(IntPtr handle) : base(handle) { // Note: this .ctor should not contain any initialization logic. } UIView unviewedLineView; public override UIView UnviewedLineView { get => unviewedLineView; set { unviewedLineView = value; unviewedLineView.BackgroundColor = Color.FromHex("#E60078").ToUIColor(); } } } ```

Could you please help me into changing the color of the unread indicator ?

Akrosyss commented 3 years ago

I have the same issue on my project, any news please ?

mr-coin-coin commented 3 years ago

Hi @Bucimis , did you already achieve in customizing the unviewed indicator color with this binding library ?

Bucimis commented 3 years ago

@mr-coin-coin thanks for letting us know. Quick question, are you using the normal Xamarin UI, Forms, or MAUI?

mr-coin-coin commented 3 years ago

Hi ! I'm using your library in a Xamarin.Forms app (v5.0.0.2012)

Bucimis commented 3 years ago

@mr-coin-coin thanks for the context! It's in our roadmap to investigate and fix this if possible, most likely on the order of 4-6 weeks.