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

[Bug]: In-app message Modal Image the image and contentView can be scaleAspectFit #27

Closed chronicqazxc closed 1 year ago

chronicqazxc commented 1 year ago

Platform

iOS

Platform Version

iOS 16.0

Braze SDK Version

5.6.3

Xcode Version

Xcode 14.0

Computer Processor

Intel

Repro Rate

100%

Steps To Reproduce

Example:

  1. Implement BrazeInAppMessageUIDelegate method to set image contentMode to scaleAspectFit
    func inAppMessage(
    _ ui: BrazeInAppMessageUI,
    prepareWith context: inout BrazeInAppMessageUI.PresentationContext
    ) {
    // Customize the in-app message presentation here using the context
      context.attributes?.modalImage?.onPresent = { view in
          view.imageView.contentMode = .scaleAspectFit
      }
    }
  2. Present in-app message modalImage type with 800 x 960 image.
    var mockImage: URL {
       return URL.mockImage(width: 800, height: 960)
    }
    var themes: BrazeKit.Braze.InAppMessage.Themes {
       return ["light": .init(backgroundColor: .clear, closeButtonColor: .green)]
    }
    AppDelegate.braze?.inAppMessagePresenter?.present(message: .modalImage(
        Braze.InAppMessage.ModalImage(imageURL: mockImage, themes: themes)
    ))
  3. Image was shrink but the contentView didn't.

Screen Shot 2022-11-24 at 18 24 10 image

Expected Behavior

In-App message the content view and image can aspect scale to fit the screen size.

Actual Incorrect Behavior

In-App message image can aspect scale to fit the screen size but content view doesn't.

Verbose Logs

No response

Additional Information

No response

hokstuff commented 1 year ago

Hi @chronicqazxc,

Thanks for filing this issue. We're currently investigating this and plan to address the root cause in a future release.

lowip commented 1 year ago

Hi @chronicqazxc,

We have implemented a fix that will be available in our next release. We'll update here once this release is available.

Best,

lowip commented 1 year ago

Hi @chronicqazxc,

We have released 5.7.0 which includes the fix for that issue.

Please note that setting the image view content mode as .scaleAspectFit is not needed. The modal respect the aspect ratio of the image as long as there's enough space in the screen to display it.

chronicqazxc commented 1 year ago

Hi @hokstuff , @lowip Noted and thanks a lot for the fix.