braze-inc / braze-swift-sdk

Braze SDK for the Apple ecosystem, including: iOS, macOS, iPadOS, visionOS, tvOS
https://www.braze.com
Other
49 stars 19 forks source link

[Feature]: Allow for configuration of line height in InAppMessageView #140

Open Ferdzz opened 1 day ago

Ferdzz commented 1 day ago

What problem are you facing?

We have in app messages in our app that use a custom font for the title section. Despite most styling options being available to us when configuring IAPs, we are unable to customize the line height of the title. This line spacing ends up being too large and doesn't match our designs.

Actual Design
image image

Workarounds

No workarounds available when using InAppMessageView. Because ModalTextView.Layout and ModalTextView.textView are private, the only workarounds would involve re-creating these UI elements, which seems like overkill for the issue at hand

Ideal Solution

The ModalTextView used by InAppMessageView has an enum Layout containing line spacing configurations:

    /// Manually-tuned values to get us closer to our visual spec.
    private enum Layout {
      static let headerLineSpacingScaleFactor = 0.78
      static let messageLineSpacingScaleFactor = 0.47
      static let headerMessageSpacingOffset = 1.0
    }

I believe it would be fairly simple to change this Layout private enum to a public struct with the same default values. This way we would be able to inject this Layout object and configure our own line spacing throughout the app.

However, lineSpacing isn't enough in our case, so we'd also appreciate exposing a lineHeightMultiplier. This is because lineSpacing only supports positive values, while our design requests a negative line spacing, which is a common design requirement.

Other Information

No response

jerielng commented 23 hours ago

Hi @Ferdzz, thanks for filing some detailed feedback! To understand your case a little better, you would need access to both the lineSpacing and lineHeightMultiple properties of the header and message text? I've filed a ticket for our team to take a look into how we could support this. We will notify you with any updates as we have them. Thanks!

Ferdzz commented 22 hours ago

Hi @jerielng , thanks for the quick response. Control over lineSpacing would be great, and would get us a little closer to our design, especially since that's something you already use. But adding lineHeightMultiple as well maxLineHeight & minLineHeight configurations would also be a must to have control over the actual line height (rather than just the line spacing) when using some of the larger fonts. Those will get us to perfect match with our designs