Skip to content

Improve fullscreen templates in landscape orientation#1435

Merged
tonidero merged 5 commits into
mainfrom
improve-fullscreen-templates-landscape
Nov 7, 2023
Merged

Improve fullscreen templates in landscape orientation#1435
tonidero merged 5 commits into
mainfrom
improve-fullscreen-templates-landscape

Conversation

@tonidero

@tonidero tonidero commented Nov 3, 2023

Copy link
Copy Markdown
Contributor

Description

This modifies templates 1 and 5 so the top images don't use the full height of the screen when using devices in horizontal. This is not a problem when presenting as a dialog, since the width is limited, but if using the composables directly, it might be problematic.

@tonidero

tonidero commented Nov 3, 2023

Copy link
Copy Markdown
Contributor Author

Screenshots change in: RevenueCat/purchases-android-snapshots#3. Will hold this until the base PR is ready. snapshot tests will fail until that PR is merged.

@tonidero tonidero marked this pull request as ready for review November 3, 2023 14:38
@tonidero tonidero requested a review from a team November 3, 2023 14:38

@NachoSoto NachoSoto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Just one question.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh so nice

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the paywall isn't displayed full screen and is instead a dialog?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I was assuming this would pick the window size of the dialog, not the screen, but I was wrong,
so this change would still apply there. As long as the width of the screen is bigger than the height, we will set the image as a percentage of the screen, instead of using an aspect ratio. This is not ideal, so trying to figure out a solution. Great catch! Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the algorithm to use the template size instead of the window size, so we don't care if it's displayed as a dialog, as full screen, or anything the developer wants to do. This will cause a recomposition unfortunately... But I think it's the best solution

NachoSoto

This comment was marked as duplicate.

@tonidero tonidero requested a review from NachoSoto November 3, 2023 15:59
Base automatically changed from toniricodiez/pwl-176-sdk-add-snapshot-tests-for-templates to main November 3, 2023 17:26
@tonidero tonidero force-pushed the improve-fullscreen-templates-landscape branch from 74ae68b to b878729 Compare November 6, 2023 09:40
aspectRatio(ratio = 1.2f)
}
.conditional(aspectRatio <= 1f) {
fillMaxWidth().height(screenHeight.dp / 2f)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this keep the aspect ratio? The fillMaxWidth() will fill the parent and the height will be reduced? So a portrait image will look squashed right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it won't. However, we are using ContentScale.Crop here, so the image won't look squashed but it will get cut, so depending on the image it might not look great.

I agree, this might not look great in some scenarios, but usually, this shouldn't be a problem as long as the width is not much larger than the height. So, for developers presenting as a dialog, this shouldn't be an issue I think (the dialog will not use the full available width in these scenarios.

Do you have any suggestions to handle this instead? This is the screenshots change after this: RevenueCat/purchases-android-snapshots#3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was missing the ContentScale.Crop 😄

I was worried the image would look squashed, but it won't, so this should be fine

aspectRatio(ratio = Template5UIConstants.headerAspectRatio)
}
.conditional(aspectRatio <= 1f) {
fillMaxHeight(Template5UIConstants.percentageScreenImageInLandscape).fillMaxWidth()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question here about the aspect ratio

@codecov

codecov Bot commented Nov 6, 2023

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.13%. Comparing base (0f688aa) to head (f044e9d).
Report is 318 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1435   +/-   ##
=======================================
  Coverage   84.13%   84.13%           
=======================================
  Files         197      197           
  Lines        6649     6649           
  Branches      965      965           
=======================================
  Hits         5594     5594           
  Misses        684      684           
  Partials      371      371           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tonidero tonidero merged commit 4982a45 into main Nov 7, 2023
@tonidero tonidero deleted the improve-fullscreen-templates-landscape branch November 7, 2023 07:36
NachoSoto added a commit that referenced this pull request Nov 8, 2023
**This is an automatic release.**

### RevenueCatUI
* `PaywallActivityLauncher`: new constructor for a generic
`ActivityResultCaller` (#1441) via NachoSoto (@NachoSoto)
* Improve fullscreen templates in landscape orientation (#1435) via Toni
Rico (@tonidero)
* `Paywalls`: improve Japanese localization (#1439) via NachoSoto
(@NachoSoto)
### Other Changes
* Remove side effect from setting purchasesUpdatedListener (#1443) via
Cesar de la Vega (@vegaro)
* Paywalls: Store paywall events on disk and API (1) (#1436) via Toni
Rico (@tonidero)

---------

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants