-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Update cell when tintColor changes (without crashing) #1492
Conversation
This reverts commit f873035.
Setting the tintColor explicitly means this component will ignore future parent tintColor changes, which means it won’t work nicely in an app that uses tintColors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should test this before merging to make sure there are no problems
if row.isDisabled { | ||
tintColor = UIColor(red: red, green: green, blue: blue, alpha: 0.3) | ||
tintAdjustmentMode = .dimmed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the Apple docs (of tintAdjustmentMode
):
When this property’s value changes (either by the view’s value changing or by one of its superview’s values changing), -the system calls the tintColorDidChange() method to allow the view to refresh its rendering
So it does not break the loop. We should test which version looks better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mats-claassen thank you for looking at this! The intention of this change was to allow the component to accept future tintColor
updates. If you set the tintColor
explicitly then you're closed off to changes from your superview, so I think that it's best to use the tintAdjustmentMode
to handle this case.
You can see an example of this in the form rows example in Eureka when you set yourself a tintColor
. By the time the form rows get told about it these rows have already set their own based on the default tintColor
.
So, this change isn't about breaking the loop, it's about making tintColor
flowing down work.
I have tested on iPhone 7 and it works fine but the reported problems were mainly iPhone X so it would be helpful if someone could test it on iPhone X |
Hello guys @karlvr @mats-claassen @mtnbarreto , My bad to say that, just that issue is happening for me still. When I move setting of tintColor into update method, all works well. So, should be that an issue? |
@sena1or thanks for your message. Could you please post the stack trace that demonstrates this issue? |
Hi @karlvr Thank you for the fast response. |
@sena1or thank you. So the first stack trace is resulting in a stack overflow, but it seems to be creating lots of new cells. Is that what's happening? I'm guessed that looking at the changing
I don't understand yet why we're getting a new cell each time through this. Does |
Hi @karlvr When execution flow becomes to Second problem, that I mentioned is also related to instantiation process. And all of them cause by the change of Thanks, |
The reason why _cell isn't initialised is the flow can't get out from closure at first access of getter. |
@sena1or thanks for the pointer to Could you modify the Eureka source in your project (perhaps in the Pods directory?) and try out a change like this?
I'm not sure this is the best solution, but could we see if this solves the infinite recursion issue? |
It seems to me that we could add a method to |
@karlvr Hello from 2019, Apologies from being late :-( I fixed this locally year ago and come back again after dependency update.
and get rid of What would you say? Thanks! |
@sena1or no problem, I know the feeling! I'm now no longer close to this issue so I can't judge this so well. Could you explain what you've done? |
Correct version would be
@karlvr the main idea is to return a cell object, even if setup method didn't called. |
This is a do-over of #1439, which caused crashes reported #1447.
As in #1439 we update the row when the tint colour changes. This should capture all uses of
tintColor
in the variousupdate
methods throughout the framework.This PR adds explicit detection of the potential for an infinite loop, which occurs when a cell changes its
tintColor
in theupdate
method. This change is inCell.swift
.This PR also removes all the instances where components change the
tintColor
in theirupdate
method. I don't believe that our cells should set their owntintColor
as this prevents them from participating in the cascade oftintColor
from their parent views. InCheckRow.swift
andListCheckRow.swift
I have changed to usingtintAdjustmentMode
, which I believe is the correct way to achieve what those cells are trying to achieve. Note that there are many other cells in the project that usetintColor
dimmed to 30% alpha to indicate a disabled state. This is not what thetintAdjustmentMode
does; I believe instead it sets them to grey, but who knows what else it might do. It may be a separate task to make other components match up to the behaviour oftintAdjustmentMode
—I feel like it's best to match that, as it's Apple's way ;-)This PR also corrects the
tintColor
behaviour ofStepperRow
.You can easily test the
tintColor
behaviour by setting thetintColor
on theview
in the example app view controllers, such asRowsExampleViewController
. If you do that before and after this PR you should see what this PR is fixing!