https://github.com/rescript-react-native/safe-area-context
ReScript bindings for react-native-safe-area-context
https://github.com/rescript-react-native/safe-area-context
react react-native rescript rescript-react rescript-react-native
Last synced: 13 days ago
JSON representation
ReScript bindings for react-native-safe-area-context
- Host: GitHub
- URL: https://github.com/rescript-react-native/safe-area-context
- Owner: rescript-react-native
- License: mit
- Created: 2019-12-19T07:37:16.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-11-19T19:13:25.000Z (7 months ago)
- Last Synced: 2025-04-01T23:04:29.806Z (3 months ago)
- Topics: react, react-native, rescript, rescript-react, rescript-react-native
- Language: ReScript
- Homepage:
- Size: 499 KB
- Stars: 7
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - safe-area-context - native-safe-area-context | rescript-react-native | 5 | (ReScript)
README
# `@rescript-react-native/safe-area-context`
[](https://github.com/rescript-react-native/safe-area-context/actions)
[](https://www.npmjs.com/@rescript-react-native/safe-area-context)
[](https://forum.rescript-lang.org/)[ReScript](https://rescript-lang.org) bindings for
[`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).Exposed as `ReactNativeSafeAreaContext` module.
`@rescript-react-native/safe-area-context` X.y.\* means it's compatible with
`react-native-safe-area-context` X.y.\*## Installation
When
[`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context)
is properly installed & configured by following their installation instructions,
you can install the bindings:```console
npm install @rescript-react-native/safe-area-context
# or
yarn add @rescript-react-native/safe-area-context
````@rescript-react-native/safe-area-context` should be added to `bs-dependencies` in
your `rescript.json`:```diff
{
//...
"bs-dependencies": [
"@rescript/react",
"rescript-react-native",
// ...
+ "@rescript-react-native/safe-area-context"
],
//...
}
```## Usage
### Types
#### `ReactNativeSafeAreaContext.insets`
```rescript
type insets = {
top: float,
bottom: float,
left: float,
right: float,
};
```#### `ReactNativeSafeAreaContext.frame`
```rescript
type frame = {
x: float,
y: float,
width: float,
height: float,
};
```#### `ReactNativeSafeAreaContext.metrics`
```rescript
type metrics = {
insets,
frame,
};
```### Constants
#### `initialWindowMetrics`
See
### Methods
#### ``
```rescript
open ReactNative;
open ReactNativeSafeAreaContext;@react.component
let make = () => {
// your app...
;
}
```See for
`initialMetrics`.#### `ReactNativeSafeAreaContext.useSafeAreaInsets(): insets`
```rescript
open ReactNative;
open ReactNativeSafeAreaContext;@react.component
let make = () => {
let insets = useSafeAreaInsets();
;
}
```#### `ReactNativeSafeAreaContext.useSafeAreaFrame(): frame`
```rescript
open ReactNative;
open ReactNativeSafeAreaContext;@react.component
let make = () => {
let frame = useSafeAreaFrame();
;
}
```#### ``
```rescript
open ReactNative;
open ReactNativeSafeAreaContext;@react.component
let make = () => {
// your component, handy for classes
{insets => }
;
}
```#### ``
```rescript
open ReactNative;
open ReactNativeSafeAreaContext;@react.component
let make = () => {
;
}
```---
## Changelog
Check the [changelog](./CHANGELOG.md) for more informations about recent
releases.---
## Contribute
Read the
[contribution guidelines](https://github.com/rescript-react-native/.github/blob/master/CONTRIBUTING.md)
before contributing.## Code of Conduct
We want this community to be friendly and respectful to each other. Please read
[our full code of conduct](https://github.com/rescript-react-native/.github/blob/master/CODE_OF_CONDUCT.md)
so that you can understand what actions will and will not be tolerated.