braze-inc / braze-swift-sdk

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

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

Closed Ferdzz closed 3 weeks ago

Ferdzz commented 2 months 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 2 months 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 2 months 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

Ferdzz commented 1 month ago

Hi @jerielng, No rush, but we were wondering if you could give us some feedback on this? Is this planned for an upcoming release?

jerielng commented 1 month ago

Hey @Ferdzz it's on our radar for sure. I've raised it with the team for prioritization and will get back to you here as soon as we have a clearer timeline. Thanks!

jerielng commented 3 weeks ago

Hi @Ferdzz, we've just released 11.2.0, which adds some new configurations that will help you accomplish your use case. You can find the full list of properties here, which will be configurable on either Modal and/or Full in-app messages. Additionally, our customization guide has been updated to demonstrate a sample of what this might look like in your code.

Feel free to reach back out to let us know if you have any further questions! Thank you!

Ferdzz commented 3 weeks ago

Awesome! Will be trying this out soon. Thank you very much for the quick turnaround!