ESTabBarController icon indicating copy to clipboard operation
ESTabBarController copied to clipboard

ESTabBarItem loses info

Open hypermats opened this issue 1 year ago • 2 comments

With the changes from https://github.com/eggswift/ESTabBarController/commit/c454e0569ea0ff135c9d8926d09b222cc0658f7c#diff-5abb945dc5865b317e84e001627a243f52e8b34f819e833d954e39b062fa38a1

The init function was changed to directly set properties on the contentView. This is problematic because the properties cannot be read. In our app it causes issues as we use the item tag and all items have tag 0 instead of the value we set in the init.

Repro example:

let item = ESTabBarItem(
            BounceTabBarItem(),
            title: "My Tab",
            image: .imageAsset,
            selectedImage: .activeImageAsset,
            tag: 7
        )
 print(item.tag) //prints 0. 7 is expected
 print(item.contentView.tag) // prints 7

The fix should be to go back to setting the contentView properties as a result of calling the setters on ESTabBarItem.

(A different question is how on earth we didn't update this library until recently and discovered this bug from 2020)

hypermats avatar Dec 20 '23 22:12 hypermats

I'll try to look into it. Do you have any PR to fix this by any chance ?

rafaelfrancisco-dev avatar Dec 21 '23 10:12 rafaelfrancisco-dev

Hi @rafaelfrancisco-dev .

I think the easiest fix is to revert the change to the init function and bring back the open func setTitle(_ title: String? = nil, image: UIImage? = nil, selectedImage: UIImage? = nil, tag: Int = 0) { function

If the calls are made to set the title, image, selectedImage and tag on self they are propagated to the contentView in didSet.

I don't have a PR ready, but I can probably create one. Not until earliest in the new year though.

hypermats avatar Dec 21 '23 11:12 hypermats