Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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] Use same font size for Editor/Entry placeholders #13140
[iOS] Use same font size for Editor/Entry placeholders #13140
Changes from all commits
129a47a
44b5c1a
25e8955
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
is not is preferred over != because operator can be overridden leading to possible bugs.
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.
I don't quite understand the logic, lets walk through it, first invert the if, that results in the following:
Same behaviour, of course if we have a nested if with no else, that equals a && so we have:
We can now move to the else clause, which is the one that confuses me, looks like you want to set _defaultPlaceholderSize to the size of the _placeholderLabel.Font.PointSize only when it is -1. By the look of the code _defaultPlaceholderSize is never modified by any other value, so why not moving that if outside the else clause?
No a huge fan of a read-write variable accessible by the rest of the code to hold the default value and be updated the first time a property is used. Maybe using https://learn.microsoft.com/en-us/dotnet/api/system.lazy-1?view=net-7.0 is a better approach, but I let you judge. Nevertheless the code is cleaner this way, or at least with the first iteration.
I believe you can make it a lot nicer if you use a nullable value, rather than _defaultPlaceholderSize = -1 make it a nfloat? which is much safer, we know we started with null, if not null someone changed it:
You can make it even smaller using a ternary operator:
The last implementation can be improved by removing the is not for the _defaultPlaceholderSize since we know it was set already:
The last suggestion seems the cleaner one. But do as you wish :)