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

Support React Native 0.75 #207

Merged
merged 4 commits into from
Sep 27, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{h,m,mm}]
indent_size = 4

[*.{kt,java}]
indent_size = 4
82 changes: 15 additions & 67 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,20 @@
const path = require('path');

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: [
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
],
plugins: [
'import',
'react',
'react-hooks',
'react-native',
'@typescript-eslint',
],
ignorePatterns: [
'node_modules/',
'*/node_modules/',
'lib/',
'*/build/',
],
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
'@typescript-eslint/consistent-type-imports': [
'error',
],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' },
],
'@typescript-eslint/no-var-requires': 'off',
'import/order': [
'error',
{
'groups': [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
],
'newlines-between': 'always',
'alphabetize': { order: 'asc' },
},
],
'no-underscore-dangle': 'error',
'no-unused-vars': 'off',
'react/display-name': 'off',
'react/prop-types': 'off',
'react-hooks/exhaustive-deps': 'warn',
'react-native/no-inline-styles': 'warn',
'react-native/no-unused-styles': 'warn',
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
},
],
},
settings: {
react: {
version: 'detect',
extends: '@react-native',
parserOptions: {
babelOptions: {
configFile: path.resolve(__dirname, 'packages', 'example', 'babel.config.js'),
},
},
overrides: [
{
files: ['**/jest/*'],
plugins: ['jest'],
env: {
'jest/globals': true,
},
},
],
};
1 change: 0 additions & 1 deletion .github/workflows/lint-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
pull_request:
branches: [main]
paths:
- "packages/mobile/android/**"
- "packages/react-native-avoid-softinput/android/**"
- ".github/workflows/lint-android.yml"

Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/lint-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ on:
pull_request:
branches: [main]
paths:
- "packages/mobile/ios/**"
- "packages/fabricMobile/ios/**"
- "packages/react-native-avoid-softinput/ios/**"
- ".github/workflows/lint-ios.yml"

jobs:
lint-ios:
name: Lint Swift & ObjC
name: Lint ObjC
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -26,16 +24,7 @@ jobs:
registry-url: "https://registry.npmjs.org"
cache-dependency-path: "**/yarn.lock"
- run: yarn
- name: SwiftLint
run: |
#!/bin/bash
if ! command -v swiftlint &> /dev/null
then
echo "SwiftLint is not installed. Installing"
brew install swiftlint
fi
yarn lint:ios:swift
yarn lint:fabric:ios:swift
- run: yarn install:pods
- name: ClangFormat
run: |
#!/bin/bash
Expand All @@ -45,4 +34,3 @@ jobs:
brew install clang-format
fi
yarn format:ios:objc
yarn format:fabric:ios:objc
24 changes: 11 additions & 13 deletions .github/workflows/lint-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ on:
pull_request:
branches: [main]
paths:
- "packages/app/src/**"
- "packages/app/package.json"
- "packages/app/tsconfig.json"
- "packages/mobile/babel.config.js"
- "packages/mobile/index.tsx"
- "packages/mobile/metro.config.js"
- "packages/mobile/package.json"
- "packages/exanple/src/**"
- "packages/example/App.tsx"
- "packages/example/babel.config.js"
- "packages/example/index.js"
- "packages/example/metro.config.js"
- "packages/example/package.json"
- "packages/example/react-native.config.js"
- "packages/example/tsconfig.json"
- "packages/react-native-avoid-softinput/jest/**"
- "packages/react-native-avoid-softinput/src/**"
- "packages/react-native-avoid-softinput/package.json"
- "packages/react-native-avoid-softinput/tsconfig.json"
- ".eslintrc.js"
- "dprint.json"
- ".prettierrc.js"
- "package.json"
- "tsconfig.base.json"
- "tsconfig.jest.json"
- ".github/workflows/lint-js.yml"

jobs:
Expand All @@ -38,9 +38,7 @@ jobs:
registry-url: "https://registry.npmjs.org"
cache-dependency-path: "**/yarn.lock"
- run: yarn
- name: ESLint
- name: Lint JS/TS
run: yarn lint:js
- name: dprint
uses: dprint/[email protected]
- name: TypeScript
run: yarn typescript
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,3 @@ android/keystores/debug.keystore
packages/react-native-avoid-softinput/lib/

.npmrc

startCommand.bat
startCommand.command
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: true,
printWidth: 120,
singleQuote: true,
trailingComma: 'all',
};
893 changes: 0 additions & 893 deletions .yarn/releases/yarn-4.0.2.cjs

This file was deleted.

925 changes: 925 additions & 0 deletions .yarn/releases/yarn-4.5.0.cjs

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
afterInstall: "yarn pods:mobile && yarn pods:fabricMobile"

compressionLevel: mixed

enableGlobalCache: false
Expand All @@ -10,4 +8,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-after-install.cjs
spec: "https://raw.githubusercontent.com/mhassan1/yarn-plugin-after-install/v0.6.0/bundles/@yarnpkg/plugin-after-install.js"

yarnPath: .yarn/releases/yarn-4.0.2.cjs
yarnPath: .yarn/releases/yarn-4.5.0.cjs
74 changes: 29 additions & 45 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ We want this community to be friendly and respectful to each other. Please follo
This project is a monorepo, which uses [yarn workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/) and is divided into:

- `docs` - contains library's Docusaurus documentation
- `packages/app` - contains shared JS code for example app
- `packages/mobile` - contains mobile app example
- `packages/example` - contains mobile app example
- `packages/react-native-avoid-softinput` - contains library code

## Development workflow
Expand All @@ -21,48 +20,58 @@ To get started with the project, run `yarn` in the root directory to install the
yarn
```

While developing, you can run the [example app](/packages/mobile/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app.
While developing, you can run the [example app](/packages/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app.

To start the packager, run `yarn android:metro` or `yarn ios:metro`
To start the packager, run `cd packages/example` and then run `yarn start`

To run the example app on Android:

```sh
yarn android:start
cd packages/example
yarn android
```

To run the example app on iOS:

```sh
yarn ios:start
cd packages/example
yarn ios
```

Make sure your code passes TypeScript, ESLint and dprint. Run the following to verify:
Make sure your code passes TypeScript, ESLint and Prettier. Run the following to verify:

```sh
yarn typescript
yarn lint:js
yarn dprint check
```

To fix formatting errors, run the following:

```sh
yarn lint:js --fix
yarn format:js
```

To edit the Swift and Objective-C files, run `yarn ios:xcode` and find the source files at `Pods > Development Pods > react-native-avoid-softinput`.
To edit the Objective-C files

- install Pods with `yarn install:pods`
- open XCode with

```sh
cd packages/example
xed ios
```

- find the source files in XCode at `Pods > Development Pods > ReactNativeAvoidSoftinput`.

To edit the Kotlin files:

- if you have a command line launcher for Android Studio set up, you can run `yarn android:studio`
- otherwise open `packages/mobile/android` in Android Studio and find the source files at `reactnativeavoidsoftinput` under `Android`.
- open `packages/example/android` in Android Studio and find the source files at `react-native-avoid-softinput` under `Android`.

To run Docusaurus documentation locally, run the following:

```sh
yarn docs:start
cd docs
yarn start
```

### Commit message & branch convention
Expand Down Expand Up @@ -102,11 +111,9 @@ git branch chore/2-configuration
### Linting and tests

- [ESLint](https://eslint.org/) - JS/TS linting
- [dprint](https://dprint.dev/) - JS/TS formatting
- [Prettier](https://prettier.io/) - JS/TS formatting
- [TypeScript](https://www.typescriptlang.org/) - TS type checking
- [Spotless](https://github.com/diffplug/spotless) & [Ktfmt](https://github.com/facebook/ktfmt) - Kotlin/Java linting and formatting
- [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) - Swift formatting
- [SwiftLint](https://github.com/realm/SwiftLint) - Swift linting
- [ClangFormat](https://clang.llvm.org/) - ObjC/ObjC++ linting and formatting

Our pre-commit hooks verify that the linter and type checks pass when committing.
Expand All @@ -126,41 +133,18 @@ yarn release
The `package.json` file contains various scripts for common tasks:

- `yarn typescript`: type-check files with TypeScript.
- `yarn lint:js`: lint all JS/TS files with ESLint.
- `yarn lint:js`: lint all JS/TS files with ESLint & Prettier.
- `yarn lint:android`: run linter (Spotless/Ktfmt) for all Kotlin/Java files.
- `yarn lint:ios:swift`: run linter (SwiftLint) for all Swift files within old arch project (install [SwiftLint](https://github.com/realm/SwiftLint) e.g. with Homebrew).
- `yarn lint:ios:objc`: run linter (ClangFormat) for all ObjC/ObjC++ files within old arch project (install [ClangFormat](https://clang.llvm.org/) e.g. with Homebrew).
- `yarn lint:fabric:ios:swift`: run linter (SwiftLint) for all Swift files within new arch project (install [SwiftLint](https://github.com/realm/SwiftLint) e.g. with Homebrew).
- `yarn lint:fabric:ios:objc`: run linter (ClangFormat) for all ObjC/ObjC++ files within new arch project (install [ClangFormat](https://clang.llvm.org/) e.g. with Homebrew).
- `yarn format:js`: format all JS/TS files with dprint.
- `yarn lint:ios:objc`: run linter (ClangFormat) for all ObjC/ObjC++ files (install [ClangFormat](https://clang.llvm.org/) e.g. with Homebrew).
- `yarn format:js`: format all JS/TS files with ESLint & Prettier.
- `yarn format:android`: format (Spotless/Ktfmt) all Kotlin/Java files.
- `yarn format:ios:swift`: format (SwiftFormat) all Swift files within old arch project (install [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) e.g. with Homebrew).
- `yarn format:ios:objc`: format (ClangFormat) all ObjC/ObjC++ files within old arch project (install [ClangFormat](https://clang.llvm.org/) e.g. with Homebrew).
- `yarn format:fabric:ios:swift`: format (SwiftFormat) all Swift files within new arch project (install [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) e.g. with Homebrew).
- `yarn format:fabric:ios:objc`: format (ClangFormat) all ObjC/ObjC++ files within new arch project (install [ClangFormat](https://clang.llvm.org/) e.g. with Homebrew).
- `yarn format:ios:objc`: format (ClangFormat) all ObjC/ObjC++ files (install [ClangFormat](https://clang.llvm.org/) e.g. with Homebrew).
- `yarn release` release library to npm.
- `yarn bootstrap`: setup projects (old and new arch) by installing all dependencies and pods.
- `yarn bootstrap:mobile`: setup old arch project by installing all dependencies and pods.
- `yarn bootstrap:fabricMobile`: setup new arch project by installing all dependencies and pods.
- `yarn pods`: setup project's pods.
- `yarn install:pods`: setup project's pods.
- `yarn install:pods:fabric`: setup project's pods with new arch.
- `yarn reset`: clean all project's dependencies and pods.
- `yarn reset:node_modules`: clean all project's dependencies.
- `yarn reset:pods`: clean all project's pods.
- `yarn android:metro`: start the Metro server for the old arch example app.
- `yarn android:start`: run the old arch example app on Android.
- `yarn android:studio`: open old arch Android project in Android Studio.
- `yarn ios:metro`: start the Metro server for the old arch example app.
- `yarn ios:start`: run the old arch example app on iOS.
- `yarn ios:xcode`: open old arch iOS project in XCode.
- `yarn fabric:android:metro`: start the Metro server for the new arch example app.
- `yarn fabric:android:start`: run the new arch example app on Android.
- `yarn fabric:android:studio`: open new arch Android project in Android Studio.
- `yarn fabric:ios:metro`: start the Metro server for the new arch example app.
- `yarn fabric:ios:start`: run the new arch example app on iOS.
- `yarn fabric:ios:xcode`: open new arch iOS project in XCode.
- `yarn docs:start`: run Docusaurus documentation locally.
- `yarn docs:build`: build Docusaurus documentation.
- `yarn docs:clear`: clear Docusaurus project.

### Sending a pull request

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ npm i --save react-native-avoid-softinput
npx pod-install
```

3. (iOS-only) Create and configure bridging header in your iOS project, if it doesn't exist (the easiest way is to create empty .swift file in XCode)

For reference, you can visit [Getting started](https://mateusz1913.github.io/react-native-avoid-softinput/docs/guides/) section

## Expo
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/api/hooks/USE_SOFT_INPUT_APPLIED_OFFSET_CHANGED.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ keywords: [react-native-avoid-softinput, useSoftInputAppliedOffsetChanged, react

### Parameters

| Type | Required | Description |
| ------------------------------------------------------ | -------- | --------------------------------------------------------------------------------- |
| ({ appliedOffset }: { appliedOffset: number }) => void | yes | function called during applying padding or translation with current applied value |
| Type | Required | Description |
| ---------------------------------------------------------- | -------- | --------------------------------------------------------------------------------- |
| (\{ appliedOffset \}: \{ appliedOffset: number \}) => void | yes | function called during applying padding or translation with current applied value |

### Example

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/api/hooks/USE_SOFT_INPUT_HEIGHT_CHANGED.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ keywords: [react-native-avoid-softinput, useSoftInputHeightChanged, react hooks]

### Parameters

| Type | Required | Description |
| ---------------------------------------------------------- | -------- | --------------------------------------------------------------------------- |
| ({ softInputHeight }: { softInputHeight: number }) => void | yes | function called with current soft input height when soft input is displayed |
| Type | Required | Description |
| -------------------------------------------------------------- | -------- | --------------------------------------------------------------------------- |
| (\{ softInputHeight \}: \{ softInputHeight: number \}) => void | yes | function called with current soft input height when soft input is displayed |

### Example

Expand Down
Loading
Loading