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

Add beta macOS implementation to experimental-avatar to test arm64 pipeline #577

Merged
merged 7 commits into from
Jan 12, 2021

Conversation

Saadnajmi
Copy link
Collaborator

@Saadnajmi Saadnajmi commented Jan 9, 2021

Platforms Impacted

  • iOS
  • macOS
  • win32 (Office)
  • windows
  • android

Description of changes

I need a native module on macOS to test that the static libraries are indeed universal and compiled for x86 and arm64.
Since @chiuam is already working on button, I decided to add a macOS implementation to Avatar...

Note: I don't consider this macOS avatar implementation production ready, and have marked it "Beta" as such. There's a few API differences / hardcoded constants and such that we would need to recitfy. If you'll believe me, I REALLY did add it so I can test the e2e macOS pipeline for arm64.

This change adds a macOS (native) implementation for experimental-avatar, and packages the compiled static library into our nuget package. We also fix a bug on the iOS implementation where a custom backgroundColor was not getting set properly.

Verification

Ran both iOS and macOS test apps to make sure Avatar displayed properly.

Screen Shot 2021-01-11 at 4 27 12 PM

Screen Shot 2021-01-11 at 4 25 39 PM

Pull request checklist

This PR has considered (when applicable):

  • Automated Tests
  • Documentation and examples
  • Keyboard Accessibility
  • Voiceover
  • Internationalization and Right-to-left Layouts

@Saadnajmi Saadnajmi changed the title WIP: Testing macOS arm64 Pipeline Add beta macOS implementation to experimental-avatar to test arm64 pipeline Jan 11, 2021
Comment on lines +15 to +26
override func constantsToExport() -> [AnyHashable : Any]! {
return [
"sizes" : [
"xSmall" : 16,
"small" : 24,
"medium" : 32,
"large" : 40,
"xLarge" : 52,
"xxLarge" : 72
]
]
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

API difference:
iOS has these explicit sizes you can set the Avatar too. macOS supports any size. To keep the same API, I just hardcoded sizes for macOS avatar to use and call the constructor with the appropriate CGFloat,

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, can we bring this up with the design team? Avatar for mac is still bit undefine but there are lots of churn i don't know Taili's team might have more guidance :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's a figma somewhere with values I haven't looked up.. but that would be a FluentUI Apple change ideally. The purpose of this was really to unblock arm64 testing, so would it be cool to keep this enum here (perhaps with better defined constants) and integrate it back into FUA with the better design once we have it?

Copy link
Collaborator Author

@Saadnajmi Saadnajmi Jan 12, 2021

Choose a reason for hiding this comment

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

I asked Kaan to start, and he said the point values will most likely stay the same. Nevertheless, I filed microsoft/fluentui-apple#391 to track adding this to FluentUI Apple. I'll update that in code

Comment on lines +12 to +14
RCT_REMAP_VIEW_PROPERTY(imageSource, contactImage, UIImage)

RCT_REMAP_VIEW_PROPERTY(backgroundColor, avatarBackgroundColor, UIColor)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fun fact: even though this is macOS, you need to set these as UIImage and UIColor for it to work properly

Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add comments on this? i cringe a little

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes.. though lots of controls will have things that maps to colors and images (like in Amanda's change). Is it still worth adding a comment if I have to add it everywhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this just work because UIImage and UIColor are macros defined to the correct platform types?

Copy link
Contributor

Choose a reason for hiding this comment

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

If so, react-native-macos defines various RCT* wrappers around these native types that we could try using instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As in, specify something like RCTUIColor instead? I'll try that.
It seems that UIColor and UIImage map to their corresponding RCTConvert macros, which contain the correct macOS implementation. Both and and @chiuam had problems setting it to just NSColor.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea we need to change that at some point, but probably fine for now as that's out of scope for this review

@harrieshin
Copy link
Collaborator

its interesting that mac avatar background color doesn't match with iOS. i thought we updated the mac avatar background palettes to be the same?

@Saadnajmi
Copy link
Collaborator Author

its interesting that mac avatar background color doesn't match with iOS. i thought we updated the mac avatar background palettes to be the same?

The palettes are the same, but the hashing algorithm is different. When we did the work to integrate Avatar for it's first client (ToDo) it was requested but ultimately cut. So nothing should block us from "fixing" the hash algorithm to match.

@Saadnajmi Saadnajmi marked this pull request as ready for review January 12, 2021 06:14
Comment on lines 64 to +65
xcode_configuration: 'Debug'
xcode_extraArgs: '-xcconfig $(Build.Repository.LocalPath)/.ado/xcconfig/publish_overrides.xcconfig'
xcode_extraArgs: '-xcconfig $(Build.Repository.LocalPath)/.ado/xcconfig/publish_overrides.xcconfig' ONLY_ACTIVE_ARCH=NO
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So... this totally works, but It would be cleaner to not need to manually add the xcconfig here. I'll follow up with the react-native-test-app team on getting the change integrated upstream

Comment on lines +12 to +14
RCT_REMAP_VIEW_PROPERTY(imageSource, contactImage, UIImage)

RCT_REMAP_VIEW_PROPERTY(backgroundColor, avatarBackgroundColor, UIColor)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yea we need to change that at some point, but probably fine for now as that's out of scope for this review

@Saadnajmi
Copy link
Collaborator Author

FYI @harrieshin, I filed microsoft/fluentui-apple#392 for the color mismatch issue

@Saadnajmi Saadnajmi merged commit 4b8fb62 into microsoft:master Jan 12, 2021
@Saadnajmi Saadnajmi deleted the macos-arm64-test branch January 12, 2021 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants