ptmt / react-native-macos

[deprecated in favor of https://microsoft.github.io/react-native-windows/] React Native for macOS is an experimental fork for writing desktop apps using Cocoa
MIT License
11.25k stars 429 forks source link

Stretch RCTRootView to fill its native parent view #218

Closed aleclarson closed 5 years ago

aleclarson commented 5 years ago

Curious if anyone has tackled this before.

I've tried doing it with Javascript, to no avail. Seems like the component that I return from the AppRegistry.registerComponent callback must have its size manually synchronized on the native side. Is this true? Or should I be able to use width: '100%' on my registered AppRegistry component?

Note: The contentView of my RCTRootView does fill the available space, but the component I return from AppRegistry.registerComponent doesn't want to do the same.

Oh, and I'm using RCTRootViewSizeFlexibilityWidthAndHeight.

aleclarson commented 5 years ago

Looks like RCTRootViewSizeFlexibilityWidthAndHeight was the issue. 😓

unmec commented 5 years ago

Hi @aleclarson , just had similar question about this. Could you please elaborate a bit more how you achieved it? It seems that the dimension state will not change when manually drag window's edges around. Thanks!

aleclarson commented 5 years ago

IIRC, the solution was to not set the sizeFlexibility property of RCTRootContentView to RCTRootViewSizeFlexibilityWidthAndHeight if you want your top-level React component to fill the available space.

It seems that the dimension state will not change when manually drag window's edges around.

Are you speaking of this API specifically? I haven't tried using that yet.

unmec commented 5 years ago

@aleclarson Yes I was referring to that API. I was playing around with an existing RN project for iOS to find out which parts work well with macos and which parts don't. Apparently dimensions doesn't for now.

aleclarson commented 5 years ago

@unmec Okay, please open an issue for that specifically, with the expected behavior versus the actual behavior. Thanks!