Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(in-app-messaging): add FullScreenMessage component #9130

Conversation

calebpollman
Copy link
Member

Description of changes

Add In-App Messaging FullScreenMessage React Native UI component for rendering InAppMessage payloads created in the Amazon Pinpoint console:

Examples
full_screen_portrait

full_screen_no_image

full_screen_landscape

Issue #, if available

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment on lines +48 to +64
// due to limitations with passing spacing style to the underlying style prop of the SafeAreaView of the
// MessageWrapper, only pass backgroundColor as a message or override style, apply all other override style
// values to container View
const { containerStyle, wrapperStyle } = useMemo(() => {
const { container: baseOverrideContainerStyle } = style ?? {};
const { backgroundColor, ...overrideContainerStyle } = Array.isArray(baseOverrideContainerStyle)
? StyleSheet.flatten(baseOverrideContainerStyle)
: (baseOverrideContainerStyle as ViewStyle) ?? {};

return {
containerStyle: [styles.container, overrideContainerStyle],

// prevent passing object with backgroundColor key and undefined or null value
// to avoid overriding payload backgroundColor
wrapperStyle: [container?.style, backgroundColor ? { backgroundColor } : null],
};
}, [container?.style, style]);
Copy link
Member Author

Choose a reason for hiding this comment

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

Will be abstracting this in to a util in a follow up PR as this handling is needed for the Modal and Carousel components as well

width = maxImageDimension;
}

return StyleSheet.create({ imageStyle: { height, resizeMode: 'contain', width } });
Copy link
Member Author

Choose a reason for hiding this comment

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

Landscape orientation images sizing in FullScreenMessage components is slightly off, will be addressing in a follow up hook/util refactor

Copy link
Contributor

@elorzafe elorzafe left a comment

Choose a reason for hiding this comment

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

I think there is a bug for isLandscape, also it might be an issue if the image url is broken?


const isSquare = aspectRatio === 1;
const isPortrait = imageHeight > imageWidth;
const isLandcape = imageWidth < imageHeight;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is incorrect, is the same as isPortrait

Copy link
Member Author

@calebpollman calebpollman Oct 29, 2021

Choose a reason for hiding this comment

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

Good catch :) Also misspelled 😱

@codecov-commenter
Copy link

codecov-commenter commented Oct 29, 2021

Codecov Report

Merging #9130 (8ebbab7) into in-app-messaging/main (8a6bd99) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@                  Coverage Diff                   @@
##           in-app-messaging/main    #9130   +/-   ##
======================================================
  Coverage                  78.00%   78.00%           
======================================================
  Files                        250      250           
  Lines                      18115    18115           
  Branches                    3885     3885           
======================================================
  Hits                       14131    14131           
  Misses                      3854     3854           
  Partials                     130      130           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a6bd99...8ebbab7. Read the comment docs.

{body?.content && <Text style={[styles.message, body.style, style?.message]}>{body.content}</Text>}
</View>
</View>
{(hasPrimaryButton || hasSecondaryButton) && (
Copy link
Member

Choose a reason for hiding this comment

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

Can this stuff be shared between message components somehow to be more DRY? Or is there a compelling reason not to?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will definitely move some of the variables in to a util in a follow up

Copy link
Member Author

Choose a reason for hiding this comment

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

In terms of not making things more DRY immediately, have been treating these components in a nuanced manner to avoid creating utils that may not end up fitting in the future

Copy link
Contributor

@elorzafe elorzafe left a comment

Choose a reason for hiding this comment

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

LGTM! 🌮

Copy link
Member

@cshfang cshfang left a comment

Choose a reason for hiding this comment

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

I'm still not sure avoiding a call to StyleSheet.flatten is worth checking if style is an array and making that bit of code a little harder to parse. But it is not a blocker either.

Copy link
Contributor

@reesscot reesscot left a comment

Choose a reason for hiding this comment

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

LGTM

@calebpollman calebpollman merged commit a14d082 into aws-amplify:in-app-messaging/main Oct 29, 2021
@calebpollman calebpollman deleted the in-app-messaging/add-full-screen-message branch October 29, 2021 23:44
@github-actions
Copy link

This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants