flowkey / UIKit-cross-platform

Cross-platform Swift implementation of UIKit, mostly for Android
MIT License
595 stars 40 forks source link

removed calls from sizeToFit and layoutSubviews #262

Closed janek closed 5 years ago

janek commented 5 years ago

Related to #137

Type of change: code fix

Motivation

When trying to track every call on the UIView lifecycle (setNeedsLayout, layoutSubviews, sizeToFit etc.), I noticed many more of those calls appearing in UIKit-x version than iOS version. Removing those two setNeedsLayout calls from UIView made it much more (albeit not perfectly) consistent with the way these calls happen in iOS.

The benefit of these changes is removing unnecessary calls (and lines of code that might be extra confusing, since they don't provide value, but are in the code).

The risk is that some those calls needed to be there after all and removing them will cause some elements to stop displaying correctly. This forces us to take a look at each screen and compare to a non-changed version. Since the change is removing setNeedsDisplay commands, the problems that can be expected would be views misplaced for a brief moment of time or before some action is taken by the user. I went through all screens of Player I could think of and did not notice any differences in layout. I covered part of that (the 'SongOrSlide' flow) with screenshots, included below. There don't seem to be any differences in layout, suggesting the changes are safe to include.

When comparing screenshots:

current master (no change) this PR (with change)
screen shot 2018-08-15 at 19 25 20 screen shot 2018-08-15 at 17 51 02
screen shot 2018-08-15 at 19 25 30 screen shot 2018-08-15 at 17 50 33
screen shot 2018-08-15 at 19 25 37 screen shot 2018-08-15 at 17 50 50
screen shot 2018-08-15 at 19 25 48 screen shot 2018-08-15 at 17 51 31
screen shot 2018-08-15 at 17 52 10 screen shot 2018-08-15 at 19 26 25
screen shot 2018-08-15 at 19 27 58 screen shot 2018-08-15 at 17 52 18

Please check if the PR fulfills these requirements