Skip to content

feat: migrate Camera to new arch#3082

Closed
WoLewicki wants to merge 7 commits intornmapbox:mainfrom
j-piasecki:@wolewicki/migrate-camera
Closed

feat: migrate Camera to new arch#3082
WoLewicki wants to merge 7 commits intornmapbox:mainfrom
j-piasecki:@wolewicki/migrate-camera

Conversation

@WoLewicki
Copy link
Copy Markdown
Contributor

PR adding Camera implementation on new arch and adding all the files to fabricexample so it is easier to test new things there.

Copy link
Copy Markdown
Contributor

@mfazekas mfazekas left a comment

Choose a reason for hiding this comment

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

@WoLewicki nice, thanks much!

I'm don't think I fully understand the need and purpose for fabricexample. I'm concerned about code duplication. I'm sure some of the example will be improved in fabricexample some in example and it will get confusing.

Note that I've updated the example to rn 0.72.5 so it should work with fabric as well, I think I've briefly tried that. It's building in CI for sure. fabricexample still has simpler setup it uses symlink instead of metro/babel trickery.

void setLogoPosition(T view, Dynamic value);
void setCompassEnabled(T view, boolean value);
void setCompassFadeWhenNorth(T view, boolean value);
void setCompassEnabled(T view, Dynamic value);
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's the reason for the codegen change? I was changed from Int, etc to all Dynamic in old-arch?

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'm don't think I fully understand the need and purpose for fabricexample.

I just wanted to have both example and fabricexample with cached pods etc, but after we convert the whole library, we can just remove it.

What's the reason for the codegen change? I was changed from Int, etc to all Dynamic in old-arch?

I'll paste the reasoning I described with folks on codegen channel:
image

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 updated the PR with newest main and UnsafeMixed<T> code, which is cool btw :D

Copy link
Copy Markdown
Contributor

@mfazekas mfazekas Sep 28, 2023

Choose a reason for hiding this comment

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

Thanks, so just to clarify that I understand correctly.

logoEnabled?: boolean

is an optional property and by default we've showed the logo if it was shown by default by the native Mapbox SDK, which was true - I assume.
But in new architecture, if user doesn't set's logoEnabled logoEnabled gets default value as false, as codegen doesn't recognise the optional ? in the type declaration? So if you don't set logoEnabled in new architecture it'll be hidden.

Have you tested, WithDefault ?

logoEnabled?: WithDefault<boolean,undefined>;

for old-arch it seems that it generated correct code:

-        mViewManager.setLogoEnabled(view, value == null ? false : (boolean) value);
+        mViewManager.setLogoEnabled(view, value == null ? null : (Boolean) value);

Haven't checked what it generated for new arch.

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.

The problem exists on iOS, on Android the values can be null indeed, but on iOS we have props as primitive cpp types with no Optional.

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.

@WoLewicki oh I see. I assume codegen could (and should) generate std::optional<boolean>. But yeah it doesn't.

Sure than it's good. The only improvement I can think of is this:

type OptionalProp<T> = UnsafeMixed<T>;
...

logoEnabled?: OptionalProp<boolean>;

...
}

Hopefully codegen will have means of supporting optional properties, and then we can replace.

Copy link
Copy Markdown
Contributor

@mfazekas mfazekas left a comment

Choose a reason for hiding this comment

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

Looks good to me, once the CI pass this can be merged

👍

@WoLewicki
Copy link
Copy Markdown
Contributor Author

I resolved the issues. You still need to trigger the jobs for CI, right?

@mfazekas
Copy link
Copy Markdown
Contributor

mfazekas commented Oct 2, 2023

@WoLewicki you have now access I think, so you can push it to a branch on this repo? then CI can run.

@WoLewicki
Copy link
Copy Markdown
Contributor Author

Ok, I'll check

@WoLewicki WoLewicki closed this Oct 2, 2023
@mfazekas
Copy link
Copy Markdown
Contributor

@WoLewicki I'd like to update our example to rn 0.73 and will be requiring 0.73 for fabric going further. Is this an issue for you?
0.73 seems to have UnsafeMixed support for events/methods.

@WoLewicki
Copy link
Copy Markdown
Contributor Author

If everything works OOTB then it is perfect for me.

0.73 seems to have UnsafeMixed support for events/methods.

Do you think there is much value in porting it now?

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.

2 participants