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.51k stars 1.1k forks source link

Improve multiline height calculation #466

Closed Juanpe closed 2 years ago

Juanpe commented 2 years ago

Summary

The goal of this PR is to improve how the height of the lines for text nodes is calculated. Until now, the library decided to use the font height, the constraints, or the default value. Now, exist a new type to define how the library should calculate the height.

Before

You could only decide whether to use the height of the source line or not:

label.useFontLineHeight = true

After

Now, you can be more specific:

label.skeletonTextLineHeight = .relativeToFont

Here the SkeletonTextLineHeight definition:

enum SkeletonTextLineHeight: Equatable {

    /// Calculates the line height based on the font line-height.
    case relativeToFont

    /// Calculates the line height based on the height constraints.
    ///
    /// If no constraints exist, the height will be set to the `multilineHeight`
    /// value defined in the `SkeletonAppearance`.
    case relativeToConstraints

    /// Returns the specific height specified as the associated value.
    case fixed(CGFloat)

}
github-actions[bot] commented 2 years ago
Warnings
:warning: Consider **also** updating the README for other languages.

Generated by :no_entry_sign: Danger Swift against 22fff5a634597e68124746f502674de75b0b76a9