Resizing
Some of the base-level props in the component manifest detail the sizing of the component:
defaultWidth
anddefaultHeight
set the default sizing when the app creator drags the component into their app.resizeX
andresizeY
set the ability for the app creator to resize the component in the x and y directions, respectively.resizeX
defaults to true, andresizeY
defaults 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
width
to the component's state, and set it tonull
by default.Add a
handleLayout
callback for a React NativeView
like so:handleLayout = ({ nativeEvent }) => {const { width } = (nativeEvent && nativeEvent.layout) || {};const { width: prevWidth } = this.state;if (width !== prevWidth) {this.setState({ width });}};Make the
handleLayout
a callback to the main View'sonLayout
event:<ViewonLayout={this.handleLayout}>Set the width of the React component to
this.state.width
Make sure to conditionally render the component in the
View
so that ifthis.state.width === null
that the component does not render.
The create-adalo-component
tool includes all of this.