Juanpe / SkeletonView

☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting
MIT License
12.53k stars 1.1k forks source link

[BUG] Fix crashing on NaN value #382

Closed coreyd303 closed 3 years ago

coreyd303 commented 3 years ago

Summary

Describe the goal of this PR. Mention any related Issue numbers.

This PR fixes a crash seen when the result of CGFloat(bounds.height - config.paddingInsets.top - config.paddingInsets.bottom) / CGFloat(requiredSpaceForEachLine) is 0

Applying round to 0 results in NaN which crashes the runtime when converting to Int

https://www.dropbox.com/s/u9id3amj27370bw/Screen%20Shot%202021-04-09%20at%203.04.05%20PM.png?dl=0

Steps to reproduce:

In our app we dynamically resize a text view depending if there is text within, it might be notable that the text view is embedded in a stackView, but I assume the crash would happen either way if the view size is 0.

Requirements (place an x in each of the [ ])

Juanpe commented 3 years ago

Thanks @coreyd303 for your first contribution!! 🎉 I've added a comment, please check it and let me know what do you think 🤙

Juanpe commented 3 years ago

Great! This PR will be included in the next version 🤙🏼 thanks