Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mr-coin-coin opened this issue Sep 28, 2021 · 5 comments
Open

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

mr-coin-coin opened this issue Sep 28, 2021 · 5 comments

Comments

@mr-coin-coin
Copy link

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 :

  • void RegisterTableViewCellClasses ();
  • void SetUpUI ();

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
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
  
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<ABKContentCard> unViewedCards = new NSMutableArray<ABKContentCard>();
        
        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
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
Copy link

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

@mr-coin-coin
Copy link
Author

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

@Bucimis
Copy link
Collaborator

Bucimis commented Oct 25, 2021

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

@mr-coin-coin
Copy link
Author

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

@Bucimis
Copy link
Collaborator

Bucimis commented Oct 25, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants