Resizing
Some of the base-level props in the component manifest detail the sizing of the component:
defaultWidthanddefaultHeightset the default sizing when the app creator drags the component into their app.resizeXandresizeYset the ability for the app creator to resize the component in the x and y directions, respectively.resizeXdefaults to true, andresizeYdefaults to false.
Dynamic Resizing Based on Screen Width
note
The following is only required if your component should dynamically change width based on screen size. For example, the slider component does this.
When the app creator resizes your component to within 50 pixels of either border, the component should dynamically resize to the width of the screen. Making this work in your code isn't hard, but it does require a few extra steps:
Add a
widthto the component's state, and set it tonullby default.Add a
handleLayoutcallback for a React NativeViewlike so:handleLayout = ({ nativeEvent }) => {const { width } = (nativeEvent && nativeEvent.layout) || {};const { width: prevWidth } = this.state;if (width !== prevWidth) {this.setState({ width });}};Make the
handleLayouta callback to the main View'sonLayoutevent:<ViewonLayout={this.handleLayout}>Set the width of the React component to
this.state.widthMake sure to conditionally render the component in the
Viewso that ifthis.state.width === nullthat the component does not render.
The create-adalo-component tool includes all of this.