diff --git a/.github/actions/setup-js/action.yml b/.github/actions/setup-js/action.yml new file mode 100644 index 00000000..45b2a02d --- /dev/null +++ b/.github/actions/setup-js/action.yml @@ -0,0 +1,28 @@ +name: Setup JS +description: Sets up Node.js and install NPM dependencies + +inputs: + enable-cache: + description: Determines if actions/setup-node will have cache enabled + required: true + type: boolean + +runs: + using: composite + steps: + - name: Setup Node.js (with cache) + if: ${{ inputs.enable-cache }} + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + with: + cache: yarn + node-version: 24 + + - name: Setup Node.js (without cache) + if: ${{ !inputs.enable-cache }} + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + with: + node-version: 24 + + - name: Install NPM dependencies + run: yarn install --immutable + shell: bash diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml deleted file mode 100644 index 05353327..00000000 --- a/.github/workflows/build-docs.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: build-docs - -on: - pull_request: - branches: [main] - paths: - - "docs/**" - - "packages/react-native-avoid-softinput/**" - - ".github/workflows/build-docs.yml" - push: - branches: [main] - paths: - - "docs/**" - - "packages/react-native-avoid-softinput/**" - - ".github/workflows/build-docs.yml" - -jobs: - checks: - if: github.event_name != 'push' - name: Build docs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - name: Restore node_modules from cache - uses: actions/cache@v4 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - name: Test Build - run: | - yarn docs/ install --immutable - yarn docs/ build - gh-release: - if: github.event_name != 'pull_request' - name: Deploy docs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Add key to allow access to repository - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - run: | - mkdir -p ~/.ssh - ssh-keyscan github.com >> ~/.ssh/known_hosts - echo "${{ secrets.ACTIONS_DEPLOY_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - cat <> ~/.ssh/config - Host github.com - HostName github.com - IdentityFile ~/.ssh/id_rsa - EOT - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - name: Restore node_modules from cache - uses: actions/cache@v4 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - name: Release to GitHub Pages - env: - USE_SSH: true - GIT_USER: git - CURRENT_BRANCH: main - DEPLOYMENT_BRANCH: gh-pages - github_token: ${{ secrets.GITHUB_TOKEN }} - run: | - git config --global user.email "luigimario1913@gmail.com" - git config --global user.name "Mateusz Mędrek" - yarn docs/ install --immutable - yarn docs/ deploy diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 00000000..54d0f04f --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,57 @@ +name: deploy-docs + +on: + push: + branches: [main] + paths: + - "docs/**" + - "packages/react-native-avoid-softinput/**" + - ".github/workflows/deploy-docs.yml" + +jobs: + prepare-docs: + name: Prepare docs + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 + with: + fetch-depth: 0 + + - name: Setup JS + uses: ./.github/actions/setup-js + with: + enable-cache: false + + - name: Install Docs npm packages + run: yarn docs/ install --immutable + shell: bash + + - name: Build Docs artifacts + run: yarn docs/ build + shell: bash + + - name: Upload Build Artifact + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 #v5.0.0 + with: + path: build + + deploy-docs: + name: Deploy docs + runs-on: ubuntu-latest + needs: prepare-docs + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy to Github Pages + id: deployment + uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 #v5.0.0 diff --git a/.github/workflows/lint-android.yml b/.github/workflows/lint-android.yml index 7fc4172c..fa977300 100644 --- a/.github/workflows/lint-android.yml +++ b/.github/workflows/lint-android.yml @@ -12,22 +12,22 @@ jobs: name: Lint Kotlin/Java runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/cache@v4 + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 with: - path: "**/node_modules" - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Install modules - uses: actions/setup-node@v4 + fetch-depth: 0 + + - name: Setup JS + uses: ./.github/actions/setup-js with: - cache: "yarn" - registry-url: "https://registry.npmjs.org" - cache-dependency-path: "**/yarn.lock" + enable-cache: true + - name: Set Java version - uses: actions/setup-java@v3 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 #v5.2.0 with: distribution: 'temurin' java-version: '17' - - run: yarn - - name: Spotless/Ktfmt + + - name: Lint Android (Spotless/Ktfmt) run: yarn lint:android + shell: bash diff --git a/.github/workflows/lint-ios.yml b/.github/workflows/lint-ios.yml index 6c81ce3e..66b24f7e 100644 --- a/.github/workflows/lint-ios.yml +++ b/.github/workflows/lint-ios.yml @@ -10,26 +10,23 @@ on: jobs: lint-ios: name: Lint ObjC - runs-on: macos-latest + runs-on: ubuntu-latest + strategy: + matrix: + path: + - 'packages/react-native-avoid-softinput/ios' steps: - - uses: actions/checkout@v4 - - uses: actions/cache@v4 + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 with: - path: "**/node_modules" - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Install modules - uses: actions/setup-node@v4 + fetch-depth: 0 + + - name: Setup JS + uses: ./.github/actions/setup-js + with: + enable-cache: true + + - name: Run ClangFormat + uses: jidicula/clang-format-action@654a770daa28443dd111d133e4083e21c1075674 #v4.18.0 with: - cache: "yarn" - registry-url: "https://registry.npmjs.org" - cache-dependency-path: "**/yarn.lock" - - run: yarn - - name: ClangFormat - run: | - #!/bin/bash - if ! command -v clang-format &> /dev/null - then - echo "ClangFormat is not installed. Installing" - brew install clang-format - fi - yarn format:ios:objc + check-path: ${{ matrix.path }} diff --git a/.github/workflows/lint-js.yml b/.github/workflows/lint-js.yml index 7e70ce49..52d947e9 100644 --- a/.github/workflows/lint-js.yml +++ b/.github/workflows/lint-js.yml @@ -27,21 +27,23 @@ jobs: name: Lint JS/TS runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/cache@v4 + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 with: - path: "**/node_modules" - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Install modules - uses: actions/setup-node@v4 + fetch-depth: 0 + + - name: Setup JS + uses: ./.github/actions/setup-js with: - cache: "yarn" - registry-url: "https://registry.npmjs.org" - cache-dependency-path: "**/yarn.lock" - - run: yarn + enable-cache: true - name: Lint JS/TS run: yarn lint:js + shell: bash + - name: TypeScript run: yarn typescript + shell: bash + - name: Prepare library run: yarn prepare + shell: bash diff --git a/.github/workflows/npm-release-template.yml b/.github/workflows/npm-release-template.yml deleted file mode 100644 index 44936c60..00000000 --- a/.github/workflows/npm-release-template.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Publish to NPM reusable workflow (template) - -on: - workflow_call: - inputs: - increment: - description: Release increment (major|minor|patch) - type: string - pre_release: - description: Is release candidate? - type: boolean - secrets: - npm_token: - required: true - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: "**/node_modules" - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Install modules - uses: actions/setup-node@v4 - with: - cache: "yarn" - registry-url: "https://registry.npmjs.org" - cache-dependency-path: "**/yarn.lock" - - run: | - yarn --cwd packages/react-native-avoid-softinput - yarn prepare - - name: Run Release - run: | - git config --global user.email "luigimario1913@gmail.com" - git config --global user.name "Mateusz Mędrek" - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc - if [[ ${{ inputs.pre_release }} == true ]] - then - yarn release --preRelease=rc --ci --npm.skipChecks - else - yarn release --increment=${{ inputs.increment }} --ci --npm.skipChecks - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.npm_token }} diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml deleted file mode 100644 index c9be522c..00000000 --- a/.github/workflows/pre-release.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Pre-release to NPM - -on: - workflow_dispatch: - -jobs: - pre-release: - uses: mateusz1913/react-native-avoid-softinput/.github/workflows/npm-release-template.yml@main - with: - pre_release: true - secrets: - npm_token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-major.yml b/.github/workflows/release-major.yml deleted file mode 100644 index 492dbd2e..00000000 --- a/.github/workflows/release-major.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Major release to NPM - -on: - workflow_dispatch: - -jobs: - npm-release-major: - uses: mateusz1913/react-native-avoid-softinput/.github/workflows/npm-release-template.yml@main - with: - increment: major - secrets: - npm_token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-minor.yml b/.github/workflows/release-minor.yml deleted file mode 100644 index 1db3b58d..00000000 --- a/.github/workflows/release-minor.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Minor release to NPM - -on: - workflow_dispatch: - -jobs: - npm-release-minor: - uses: mateusz1913/react-native-avoid-softinput/.github/workflows/npm-release-template.yml@main - with: - increment: minor - secrets: - npm_token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-patch.yml b/.github/workflows/release-patch.yml deleted file mode 100644 index a43085e9..00000000 --- a/.github/workflows/release-patch.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Patch release to NPM - -on: - workflow_dispatch: - -jobs: - npm-release-patch: - uses: mateusz1913/react-native-avoid-softinput/.github/workflows/npm-release-template.yml@main - with: - increment: patch - secrets: - npm_token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test-deploy-docs.yml b/.github/workflows/test-deploy-docs.yml new file mode 100644 index 00000000..54ff5158 --- /dev/null +++ b/.github/workflows/test-deploy-docs.yml @@ -0,0 +1,30 @@ +name: test-deploy-docs + +on: + pull_request: + branches: [main] + paths: + - "docs/**" + - "packages/react-native-avoid-softinput/**" + - ".github/workflows/test-deploy-docs.yml" + +jobs: + prepare-test-docs: + name: Prepare test docs + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 + with: + fetch-depth: 0 + + - name: Setup JS + uses: ./.github/actions/setup-js + with: + enable-cache: false + + - name: Install Docs npm packages + run: yarn docs/ install --immutable + + - name: Build Docs artifacts + run: yarn docs/ build diff --git a/PUBLISHING.md b/PUBLISHING.md new file mode 100644 index 00000000..3550576d --- /dev/null +++ b/PUBLISHING.md @@ -0,0 +1,5 @@ +# How to publish release? + +**Prerequisites:** authenticate via `npm login` + +Run appropriate release script from package.json (based on the increment) diff --git a/lefthook.yml b/lefthook.yml index 7bf56a6a..1f2fc5a9 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -21,14 +21,7 @@ pre-commit: # if any ObjC/ObjC++ file changed, run ObjC linter files: git diff --name-only --cached glob: "*.{h,m,mm,cpp}" - run: | - #!/bin/bash - if command -v clang-format &> /dev/null - then - yarn lint:ios:objc --Werror - else - echo "ClangFormat is not installed. Skipping" - fi + run: ./scripts/clang-format.sh lint commit-msg: commands: commitlint: diff --git a/package.json b/package.json index 2a0d7455..ec1d57bc 100644 --- a/package.json +++ b/package.json @@ -9,12 +9,16 @@ "typescript": "tsc --noEmit", "lint:js": "eslint \"**/*.{js,ts,tsx}\" && prettier --config .prettierrc.js \"packages/**/*.{js,ts,tsx}\"", "lint:android": "./packages/react-native-avoid-softinput/android/gradlew -p packages/react-native-avoid-softinput/android spotlessCheck --quiet", - "lint:ios:objc": "clang-format --dry-run -i ./packages/react-native-avoid-softinput/ios/*.{h,mm}", + "lint:ios:objc": "./scripts/clang-format.sh lint", "format:js": "eslint \"**/*.{js,ts,tsx}\" --fix --quiet && prettier -w --config .prettierrc.js \"packages/**/*.{js,ts,tsx}\"", "format:android": "./packages/react-native-avoid-softinput/android/gradlew -p packages/react-native-avoid-softinput/android spotlessApply", - "format:ios:objc": "clang-format -i ./packages/react-native-avoid-softinput/ios/*.{h,mm} -Werror", + "format:ios:objc": "./scripts/clang-format.sh format", "prepare": "yarn workspace react-native-avoid-softinput build-library", "release": "yarn workspace react-native-avoid-softinput release-library", + "release:pre-release": "yarn release --preRelease=rc", + "release:major": "yarn release --increment=major", + "release:minor": "yarn release --increment=minor", + "release:patch": "yarn release --increment=patch", "reset": "yarn reset:node_modules && yarn reset:pods", "reset:node_modules": "find . -type dir -name node_modules | xargs rm -rf && rm -rf yarn.lock", "reset:pods": "find . -type dir -name Pods | xargs rm -rf && find . -type f -name Podfile.lock | xargs rm -rf" diff --git a/packages/react-native-avoid-softinput/ios/AvoidSoftInputAnimationHandler.mm b/packages/react-native-avoid-softinput/ios/AvoidSoftInputAnimationHandler.mm index 852d5cdf..4119bdc6 100644 --- a/packages/react-native-avoid-softinput/ios/AvoidSoftInputAnimationHandler.mm +++ b/packages/react-native-avoid-softinput/ios/AvoidSoftInputAnimationHandler.mm @@ -227,11 +227,10 @@ - (void)changeOffsetInRootView:(UIView *)rootView } onAnimate:^{ [primaryAnimator setupAnimationTimersWithRootView:rootView]; - [rootView setFrame:CGRectMake( - rootView.frame.origin.x, - -newBottomOffset, - rootView.frame.size.width, - rootView.frame.size.height)]; + [rootView setFrame:CGRectMake(rootView.frame.origin.x, + -newBottomOffset, + rootView.frame.size.width, + rootView.frame.size.height)]; } onComplete:^{ [primaryAnimator completeAnimationWithNewBottomOffset:newBottomOffset shouldSaveCurrentAppliedOffset:NO]; @@ -263,11 +262,10 @@ - (void)removeOffsetInRootView:(UIView *)rootView [self->hideAnimator setupAnimationTimersWithRootView:rootView]; /// at the end, origin.y should be equal to 0 - [rootView setFrame:CGRectMake( - rootView.frame.origin.x, - rootView.frame.origin.y + self->bottomOffset, - rootView.frame.size.width, - rootView.frame.size.height)]; + [rootView setFrame:CGRectMake(rootView.frame.origin.x, + rootView.frame.origin.y + self->bottomOffset, + rootView.frame.size.width, + rootView.frame.size.height)]; } onComplete:^{ if (initialRootViewFrameOriginY == rootView.frame.origin.y) { @@ -309,11 +307,10 @@ - (void)addOffsetInRootView:(UIView *)rootView offset:(CGFloat)offset withFirstR onAnimate:^{ [self->showAnimator setupAnimationTimersWithRootView:rootView]; - [rootView setFrame:CGRectMake( - rootView.frame.origin.x, - -self->bottomOffset, - rootView.frame.size.width, - rootView.frame.size.height)]; + [rootView setFrame:CGRectMake(rootView.frame.origin.x, + -self->bottomOffset, + rootView.frame.size.width, + rootView.frame.size.height)]; } onComplete:^{ [self->showAnimator completeAnimationWithNewBottomOffset:self->bottomOffset @@ -445,8 +442,8 @@ - (void)removeOffsetInScrollView:(UIScrollView *)scrollView withRootView:(UIView onComplete:^{ BOOL areContentInsetsEqual = UIEdgeInsetsEqualToEdgeInsets(initialScrollViewContentInset, scrollView.contentInset); - BOOL areScrollIndicatorInsetsEqual = UIEdgeInsetsEqualToEdgeInsets( - initialScrollViewScrollIndicatorInsets, scrollView.verticalScrollIndicatorInsets); + BOOL areScrollIndicatorInsetsEqual = UIEdgeInsetsEqualToEdgeInsets(initialScrollViewScrollIndicatorInsets, + scrollView.verticalScrollIndicatorInsets); if (areContentInsetsEqual && areScrollIndicatorInsetsEqual) { /// https://github.com/mateusz1913/react-native-avoid-softinput/issues/54 /// Handle case when user tries to swipe-to-dismiss screen, but finally aborts it @@ -527,8 +524,8 @@ - (CGFloat)getScrollOffsetWithSoftInputHeight:(CGFloat)softInputHeight CGFloat firstResponderDistanceToBottom = [rootView getScreenHeight] - firstResponderBottomEdgeY - rootView.safeAreaInsets.bottom; - return MIN( - MAX(softInputHeight - firstResponderDistanceToBottom, 0), firstResponderPosition.y - scrollViewPosition.y); + return MIN(MAX(softInputHeight - firstResponderDistanceToBottom, 0), + firstResponderPosition.y - scrollViewPosition.y); } @end diff --git a/packages/react-native-avoid-softinput/ios/AvoidSoftInputManager.mm b/packages/react-native-avoid-softinput/ios/AvoidSoftInputManager.mm index 4063ccba..410f2e04 100644 --- a/packages/react-native-avoid-softinput/ios/AvoidSoftInputManager.mm +++ b/packages/react-native-avoid-softinput/ios/AvoidSoftInputManager.mm @@ -147,21 +147,20 @@ - (void)debounceAnimation:(CGFloat)oldSoftInputHeight isDebounceActive = YES; __weak AvoidSoftInputManager *weakSelf = self; // Debounce animation call for 48ms and invoke with the latest target value - dispatch_after( - dispatch_time(DISPATCH_TIME_NOW, [AvoidSoftInputManager animationDebounceTimeout]), - dispatch_get_main_queue(), - ^{ - AvoidSoftInputManager *strongSelf = weakSelf; - if (!strongSelf) { - return; - } - CGFloat targetHeight = strongSelf->currentNewSoftInputHeight; - [strongSelf->animationHandler startAnimationFrom:oldSoftInputHeight - to:targetHeight - withOrientationChange:isOrientationChange]; - strongSelf->isDebounceActive = NO; - strongSelf->currentNewSoftInputHeight = 0; - }); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, [AvoidSoftInputManager animationDebounceTimeout]), + dispatch_get_main_queue(), + ^{ + AvoidSoftInputManager *strongSelf = weakSelf; + if (!strongSelf) { + return; + } + CGFloat targetHeight = strongSelf->currentNewSoftInputHeight; + [strongSelf->animationHandler startAnimationFrom:oldSoftInputHeight + to:targetHeight + withOrientationChange:isOrientationChange]; + strongSelf->isDebounceActive = NO; + strongSelf->currentNewSoftInputHeight = 0; + }); } @end diff --git a/packages/react-native-avoid-softinput/ios/RCTConvert+UIViewAnimationOptions.mm b/packages/react-native-avoid-softinput/ios/RCTConvert+UIViewAnimationOptions.mm index 6f132f48..8d38511c 100644 --- a/packages/react-native-avoid-softinput/ios/RCTConvert+UIViewAnimationOptions.mm +++ b/packages/react-native-avoid-softinput/ios/RCTConvert+UIViewAnimationOptions.mm @@ -2,15 +2,14 @@ @implementation RCTConvert (UIViewAnimationOptions) -RCT_ENUM_CONVERTER( - UIViewAnimationOptions, - (@{ - @"easeIn" : @(UIViewAnimationOptionCurveEaseIn), - @"easeInOut" : @(UIViewAnimationOptionCurveEaseInOut), - @"easeOut" : @(UIViewAnimationOptionCurveEaseOut), - @"linear" : @(UIViewAnimationOptionCurveLinear) - }), - UIViewAnimationOptionCurveLinear, - integerValue) +RCT_ENUM_CONVERTER(UIViewAnimationOptions, + (@{ + @"easeIn" : @(UIViewAnimationOptionCurveEaseIn), + @"easeInOut" : @(UIViewAnimationOptionCurveEaseInOut), + @"easeOut" : @(UIViewAnimationOptionCurveEaseOut), + @"linear" : @(UIViewAnimationOptionCurveLinear) + }), + UIViewAnimationOptionCurveLinear, + integerValue) @end diff --git a/packages/react-native-avoid-softinput/ios/events/AvoidSoftInputAppliedOffsetChangedEvent.h b/packages/react-native-avoid-softinput/ios/events/AvoidSoftInputAppliedOffsetChangedEvent.h index 8b3158d1..c62be8b8 100644 --- a/packages/react-native-avoid-softinput/ios/events/AvoidSoftInputAppliedOffsetChangedEvent.h +++ b/packages/react-native-avoid-softinput/ios/events/AvoidSoftInputAppliedOffsetChangedEvent.h @@ -3,10 +3,8 @@ @class AvoidSoftInputConstants; -@interface AvoidSoftInputAppliedOffsetChangedEvent : NSObject +@interface AvoidSoftInputAppliedOffsetChangedEvent : NSObject -- (nonnull instancetype)initWithReactTag:(NSNumber * _Nonnull)reactTag - offset:(CGFloat)offset; +- (nonnull instancetype)initWithReactTag:(NSNumber *_Nonnull)reactTag offset:(CGFloat)offset; @end - diff --git a/packages/react-native-avoid-softinput/ios/events/AvoidSoftInputAppliedOffsetChangedEvent.mm b/packages/react-native-avoid-softinput/ios/events/AvoidSoftInputAppliedOffsetChangedEvent.mm index 0f5640c6..49fb0c48 100644 --- a/packages/react-native-avoid-softinput/ios/events/AvoidSoftInputAppliedOffsetChangedEvent.mm +++ b/packages/react-native-avoid-softinput/ios/events/AvoidSoftInputAppliedOffsetChangedEvent.mm @@ -51,7 +51,7 @@ - (NSArray *)arguments return @[ self.viewTag, RCTNormalizeInputEventName(self.eventName), - @{ AvoidSoftInputConstants.softInputAppliedOffsetKey: @(eventOffset) } + @{AvoidSoftInputConstants.softInputAppliedOffsetKey : @(eventOffset)} ]; } diff --git a/packages/react-native-avoid-softinput/ios/events/BaseAvoidSoftInputEvent.h b/packages/react-native-avoid-softinput/ios/events/BaseAvoidSoftInputEvent.h index dbafbfc0..f7d1df30 100644 --- a/packages/react-native-avoid-softinput/ios/events/BaseAvoidSoftInputEvent.h +++ b/packages/react-native-avoid-softinput/ios/events/BaseAvoidSoftInputEvent.h @@ -3,9 +3,8 @@ @class AvoidSoftInputConstants; -@interface BaseAvoidSoftInputEvent : NSObject +@interface BaseAvoidSoftInputEvent : NSObject -- (nonnull instancetype)initWithReactTag:(NSNumber * _Nonnull)reactTag - height:(CGFloat)height; +- (nonnull instancetype)initWithReactTag:(NSNumber *_Nonnull)reactTag height:(CGFloat)height; @end diff --git a/packages/react-native-avoid-softinput/ios/events/BaseAvoidSoftInputEvent.mm b/packages/react-native-avoid-softinput/ios/events/BaseAvoidSoftInputEvent.mm index 611a83ee..dab6fe28 100644 --- a/packages/react-native-avoid-softinput/ios/events/BaseAvoidSoftInputEvent.mm +++ b/packages/react-native-avoid-softinput/ios/events/BaseAvoidSoftInputEvent.mm @@ -41,7 +41,7 @@ - (NSArray *)arguments return @[ self.viewTag, RCTNormalizeInputEventName(self.eventName), - @{ AvoidSoftInputConstants.softInputHeightKey: @(eventHeight) } + @{AvoidSoftInputConstants.softInputHeightKey : @(eventHeight)} ]; } diff --git a/scripts/clang-format.sh b/scripts/clang-format.sh new file mode 100755 index 00000000..bb326f32 --- /dev/null +++ b/scripts/clang-format.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +function lint { + if ! command -v clang-format &> /dev/null + then + echo "ClangFormat is not installed. Skipping" + return + fi + + find packages/react-native-avoid-softinput/ios -type f \ + -name "*.c" -o \ + -name "*.cpp" -o \ + -name "*.h" -o \ + -name "*.m" -o \ + -name "*.mm" | xargs clang-format --dry-run -i -Werror +} + +function format { + if ! command -v clang-format &> /dev/null + then + echo "ClangFormat is not installed. Skipping" + return + fi + + find packages/react-native-avoid-softinput/ios -type f \ + -name "*.c" -o \ + -name "*.cpp" -o \ + -name "*.h" -o \ + -name "*.m" -o \ + -name "*.mm" | xargs clang-format -i -Werror +} + +"$@"