Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Android improvements #1

Merged
merged 4 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npm i @lodev09/react-native-true-sheet

## Usage

```ts
```tsx
import { TrueSheet } from "@lodev09/react-native-true-sheet"

// ...
Expand Down Expand Up @@ -78,7 +78,7 @@ Extends `ViewProps`

## Methods

```ts
```tsx
const sheet = useRef<TrueSheet>(null)

const resize = () => {
Expand Down Expand Up @@ -108,7 +108,7 @@ return (

## Events

```ts
```tsx
const handleSizeChange = (info: SizeInfo) => {
console.log(info)
}
Expand All @@ -130,7 +130,7 @@ return (

### `SheetSize`

```ts
```tsx
<TrueSheet sizes={['auto', '80%', 'large']}>
// ...
</TrueSheet>
Expand Down Expand Up @@ -166,7 +166,7 @@ Grabber props to be used for android grabber or handle.

Blur tint that is mapped into native values in iOS.

```ts
```tsx
<TrueSheet blurTint="dark">
// ...
</TrueSheet>
Expand Down Expand Up @@ -200,7 +200,7 @@ Blur tint that is mapped into native values in iOS.

`Object` that comes with some events.

```ts
```tsx
{
index: 1,
value: 69
Expand All @@ -216,25 +216,37 @@ Blur tint that is mapped into native values in iOS.

When using `jest`, simply mock the entire package.

```ts
```tsx
jest.mock('@lodev09/react-native-true-sheet')
```

## Troubleshooting

### Handling `ScrollView` on **Android**

On Android, `nestedScrollEnabled` needs to be enabled so that scrolling works when the sheet is expanded to its `maxHeight`.

```tsx
<TrueSheet ref={sheet}>
<ScrollView nestedScrollEnabled>
// ...
</ScrollView>
</TrueSheet>
```

### Using `react-native-gesture-handler` on **Android**

On Android, RNGH does not work by default because modals are not located under React Native Root view in native hierarchy. To fix that, components need to be wrapped with `GestureHandlerRootView`.

Example:
```ts
```tsx
import { GestureHandlerRootView } from 'react-native-gesture-handler'
```
```ts
```tsx
return (
<TrueSheet ref={sheet}>
<GestureHandlerRootView>
<MyComponent />
// ...
</GestureHandlerRootView>
</TrueSheet>
)
Expand All @@ -245,7 +257,7 @@ return (
On iOS, navigating to a [React Navigation](https://reactnavigation.org) screen from within the Sheet can cause issues. To resolve this, dismiss the sheet before navigating!

Example:
```ts
```tsx
const sheet = useRef<TrueSheet>(null)

const navigate = async () => {
Expand Down
230 changes: 0 additions & 230 deletions android/src/main/java/com/lodev09/truesheet/TrueSheetBehavior.kt

This file was deleted.

Loading
Loading