Screen
Screen
is a layout component that you can use to wrap all the views in your app. By default, it renders a Box element.
The Screen
component also implements a SafeAreaView
under the hood. This allows the content wrapped by the Screen
component to
always be within the safe areas of the device. (This is especially helpful for keeping your app accessible on devices with rounded corners
or camera notches)
#
Importimport { Screen } from "pearl-ui";
#
Usage<Screen>This is the screen</Screen>
#
Scrolling behaviourMore often than not the contents inside your screen would exceed the device height, thus Screen
allows you to add scrolling support to all your screens using the scrollable
prop. By default, it's value is set to true
.
<Screen scrollable={true}>This is a scrollable screen</Screen>
<Screen scrollable={false}>This is a static screen</Screen>
#
Pull to RefreshThe pull-to-refresh (or swipe-to-refresh) pattern lets a user pull down on a list of data using touch in order to retrieve more data.
This can be added using the onPullToRefresh
prop which expects a function/Promise which should be executed if a pull-to-refresh action has occured.
(Note: The screen needs to scrollable to allow this behaviour to work on iOS devices).
<Screen onPullToRefresh={() => { new Promise<void>((res, rej) => setTimeout(() => { console.log("I got executed!"); res(); }, 2000) ); }}> Pull me!</Screen>
#
Example#
Props#
Supported style propsScreen
composes Box so you can pass all Box related props.
#
Additional propsScreen
also composes a KeyboardAwareScrollView, there it supports all of it's props excluding:
refresh
scrollEnabled
showsHorizontalScrollIndicator
showsVerticalScrollIndicator
Finally, the following additional props are supported as well:
Name | Required | Type | Default | Description |
---|---|---|---|---|
size | false | The size of the screen. | ||
variant | false | The variant of the screen. | ||
scrollable | false | true | Whether the screen is scrollable. | |
showScrollBar | false | false | Whether to show the vertical scrollbar if the Screen is scrollable. | |
onPullToRefresh | false | Method to execute when a pull-to-refresh action is performed. | ||
refreshIndicatorColors | false | The colors (at least one) that will be used to draw the refresh indicator (Android only). | ||
refreshProgressBackgroundColor | false | Progress view top offset. | ||
refreshProgressViewOffset | false | 0 | The background color of the refresh indicator. | |
refreshIndicatorSize | false | "default" | Size of the refresh indicator (Android only). | |
refreshTintColor | false | "default" | The color of the refresh indicator (iOS only). | |
refreshTitle | false | "default" | The title displayed under the refresh indicator (iOS only). | |
refreshTitleColor | false | "default" | The color of the refresh indicator title (iOS only). |
#
Default Component Styleexport default { baseStyle: { scrollable: true, showScrollBar: false, backgroundColor: { light: "neutral.50", dark: "neutral.800", }, padding: "m", },};