Skip to content

Commit

Permalink
Merge pull request #219 from zoontek/detect-edge-to-edge
Browse files Browse the repository at this point in the history
Detect react-native-edge-to-edge and bypass setShouldMimicIOSBehavior
  • Loading branch information
mateusz1913 authored Nov 18, 2024
2 parents 025f73b + 10adbcb commit 26f8ea0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/react-native-avoid-softinput/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"build-library": "bob build",
"release-library": "release-it"
},
"dependencies": {
"react-native-is-edge-to-edge": "^1.1.6"
},
"devDependencies": {
"@release-it/conventional-changelog": "8.0.2",
"@types/react": "18.3.12",
Expand Down
11 changes: 9 additions & 2 deletions packages/react-native-avoid-softinput/src/AvoidSoftInput.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import type { EmitterSubscription } from 'react-native';
import { NativeEventEmitter, Platform } from 'react-native';
import { controlEdgeToEdgeValues, isEdgeToEdge } from 'react-native-is-edge-to-edge';

import module from './AvoidSoftInputModule';
import type { SoftInputAppliedOffsetEventData, SoftInputEasing, SoftInputEventData } from './types';

const EDGE_TO_EDGE = isEdgeToEdge();

const eventEmitter = new NativeEventEmitter(Platform.OS !== 'ios' ? undefined : module);

/**
Expand Down Expand Up @@ -50,8 +53,12 @@ function setShouldMimicIOSBehavior(shouldMimic: boolean) {
if (Platform.OS !== 'android') {
return;
}

module.setShouldMimicIOSBehavior(shouldMimic);
if (__DEV__) {
controlEdgeToEdgeValues({ shouldMimic });
}
if (!EDGE_TO_EDGE) {
module.setShouldMimicIOSBehavior(shouldMimic);
}
}

/**
Expand Down
11 changes: 11 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13100,6 +13100,7 @@ __metadata:
react: "npm:18.3.1"
react-native: "npm:0.76.0"
react-native-builder-bob: "npm:0.30.2"
react-native-is-edge-to-edge: "npm:^1.1.6"
release-it: "npm:17.6.0"
typescript: "npm:5.0.4"
peerDependencies:
Expand Down Expand Up @@ -13155,6 +13156,16 @@ __metadata:
languageName: node
linkType: hard

"react-native-is-edge-to-edge@npm:^1.1.6":
version: 1.1.6
resolution: "react-native-is-edge-to-edge@npm:1.1.6"
peerDependencies:
react: ">=18.2.0"
react-native: ">=0.73.0"
checksum: 10/4e07c1e34c01c8d50fd7c1d0460db06f6f0515197405230386a8ffb950cb724b10743af032310d1384df0a90059bfb8992ba2d93344ce86315315f0493feccc2
languageName: node
linkType: hard

"react-native-reanimated@npm:3.16.1":
version: 3.16.1
resolution: "react-native-reanimated@npm:3.16.1"
Expand Down

0 comments on commit 26f8ea0

Please sign in to comment.