Skip to content

Commit

Permalink
feat: detect react-native-edge-to-edge
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Nov 17, 2024
1 parent 025f73b commit b146232
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
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
10 changes: 9 additions & 1 deletion 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 @@ -51,7 +54,12 @@ function setShouldMimicIOSBehavior(shouldMimic: boolean) {
return;
}

module.setShouldMimicIOSBehavior(shouldMimic);
if (__DEV__) {
// Will print "setShouldMimicIOSBehavior value is ignored when using react-native-edge-to-edge"
controlEdgeToEdgeValues({ setShouldMimicIOSBehavior: shouldMimic });
}

module.setShouldMimicIOSBehavior(EDGE_TO_EDGE || 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 b146232

Please sign in to comment.