Skip to content

Commit

Permalink
refactor: move all interactive keyboard code to dedicated `interactiv…
Browse files Browse the repository at this point in the history
…e` folder (Android) (#353)

## 📜 Description

Move all interactive keyboard code to dedicated `interactive`
folder/package in kotlin/Android.

## 💡 Motivation and Context

Ideally in root android folder I'd like to keep a single `package` file
and all other code should be placed in folders.

Initially I created generic purpose folders, like
`events`/`listeners`/`views` etc. However sometimes it may be hard to
create generic purpose folders for specific files. Theoretically I could
create folders `controllers`/`providers`, but they would contain only
single files.

So I took an inspiration from
#346
PR, where I created `traversal` folder for keeping functionality related
to view traversal/keyboard toolbar. And in this PR I moved all
interactive-keyboard related code into `interactive` folder - it keeps
file-system clean 😎

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### CI
- free up disk for `e2e` tests (Android);

### Android

- added `interactive` folder;
- move `interpolators` folder to `interactive`;
- moved `InteractiveKeyboardProvider` and `KeyboardAnimationController`
to `interactive` folder.

## 🤔 How Has This Been Tested?

Tested on CI.

## 📸 Screenshots (if appropriate):

|Before|After|
|-------|-----|
|<img width="279" alt="image"
src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/e441f44b-865f-4fb7-97c1-d303ee951bbb">|<img
width="351" alt="image"
src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/0abc31f3-6a38-4a6e-aa44-4f9dbd95c741">|

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
  • Loading branch information
kirillzyusko authored Feb 4, 2024
1 parent 6859701 commit a70c6fd
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/android-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ jobs:
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# force to remove default tools
tool-cache: true
# preserve Android
android: false
- uses: actions/setup-node@v4
with:
node-version: 18.x
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.reactnativekeyboardcontroller
package com.reactnativekeyboardcontroller.interactive

object InteractiveKeyboardProvider {
var shown = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.reactnativekeyboardcontroller
package com.reactnativekeyboardcontroller.interactive

import android.os.CancellationSignal
import android.view.View
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.reactnativekeyboardcontroller.interpolators
package com.reactnativekeyboardcontroller.interactive.interpolators

interface Interpolator {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.reactnativekeyboardcontroller.interpolators
package com.reactnativekeyboardcontroller.interactive.interpolators

class IosInterpolator : Interpolator {
override fun interpolate(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.reactnativekeyboardcontroller.interpolators
package com.reactnativekeyboardcontroller.interactive.interpolators

class LinearInterpolator : Interpolator {
override fun interpolate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.views.textinput.ReactEditText
import com.facebook.react.views.view.ReactViewGroup
import com.reactnativekeyboardcontroller.InteractiveKeyboardProvider
import com.reactnativekeyboardcontroller.events.KeyboardTransitionEvent
import com.reactnativekeyboardcontroller.extensions.dispatchEvent
import com.reactnativekeyboardcontroller.extensions.dp
import com.reactnativekeyboardcontroller.extensions.isKeyboardAnimation
import com.reactnativekeyboardcontroller.interactive.InteractiveKeyboardProvider
import kotlin.math.abs

private val TAG = KeyboardAnimationCallback::class.qualifiedName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.views.view.ReactViewGroup
import com.reactnativekeyboardcontroller.KeyboardAnimationController
import com.reactnativekeyboardcontroller.extensions.copyBoundsInWindow
import com.reactnativekeyboardcontroller.interpolators.Interpolator
import com.reactnativekeyboardcontroller.interpolators.IosInterpolator
import com.reactnativekeyboardcontroller.interpolators.LinearInterpolator
import com.reactnativekeyboardcontroller.interactive.KeyboardAnimationController
import com.reactnativekeyboardcontroller.interactive.interpolators.Interpolator
import com.reactnativekeyboardcontroller.interactive.interpolators.IosInterpolator
import com.reactnativekeyboardcontroller.interactive.interpolators.LinearInterpolator
import kotlin.math.absoluteValue
import kotlin.math.roundToInt

Expand Down

0 comments on commit a70c6fd

Please sign in to comment.