Skip to content

Commit 264b438

Browse files
feat: migrate to BaseButton (#9)
* feat: replace gesture detector with pressable * chore: release 0.2.2-beta.0 * chore: add types * chore: set up base button * feat: implement animated base button with active state handling * feat: set up base screen navigation * refactor: simplify event handling in BasePressable and update context types * fix: types * refactor: memoize base pressable * fix: base callbacks * chore: update readme * chore: release 0.2.2-beta.2 * chore: update dependencies and remove Yarn configuration files * chore: release 0.2.2-beta.4 * fix: update BasePressableProps type definition for better type safety * chore: release 0.2.2-beta.5 * fix: support additional props on base pressable * chore: release 0.2.2-beta.6 * fix: update progress handling to use get() method for animated values * chore: migrate to bun * refactor: remove enabled checks from pressable event handlers for cleaner code * chore: update react-native-reanimated to version 4.1.1 in bun.lock and package.json * chore: add react-native-worklets dependency and update related configurations * chore: update expo and related dependencies in package.json and bun.lock * chore: update deps * chore: remove unused dependencies and webpack configuration files * chore: update deps * chore: upgrade react and react-native * chore: add Jest configuration and update Babel presets for testing * chore: update installation instructions to include react-native-worklets * refactor: update PressablesConfig animation settings and improve animated style dependencies * chore: add Jest types to TypeScript configuration * chore: add .eslintignore file and update dependencies for eslint-plugin-jest and expo packages * chore: add eslint-plugin-eslint-comments to dependencies in package.json and bun.lock * chore: add eslint-plugin-react to dependencies in package.json and bun.lock * chore: add babel-preset-expo to devDependencies * chore: update eslint-plugin-react-hooks * chore: add eslint-plugin-react-native * chore: update @react-native/eslint-plugin to version 0.82.0 in package.json and bun.lock * chore: update devDependencies
1 parent 60ffc34 commit 264b438

32 files changed

Lines changed: 4550 additions & 18467 deletions

.eslintignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules/
2+
lib/
3+
coverage/
4+
example/node_modules/
5+
example/android/
6+
example/ios/
7+
example/.expo/
8+
example/dist/
9+
*.config.js

.github/actions/setup/action.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
name: Setup
2-
description: Setup Node.js and install dependencies
2+
description: Setup Bun and install dependencies
33

44
runs:
55
using: composite
66
steps:
7-
- name: Setup Node.js
8-
uses: actions/setup-node@v3
7+
- name: Setup Bun
8+
uses: oven-sh/setup-bun@v2
99
with:
10-
node-version-file: .nvmrc
11-
12-
- name: Cache dependencies
13-
id: yarn-cache
14-
uses: actions/cache@v3
15-
with:
16-
path: |
17-
**/node_modules
18-
.yarn/install-state.gz
19-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
20-
restore-keys: |
21-
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
22-
${{ runner.os }}-yarn-
10+
bun-version: latest
2311

2412
- name: Install dependencies
25-
if: steps.yarn-cache.outputs.cache-hit != 'true'
26-
run: yarn install --immutable
13+
run: bun install
2714
shell: bash

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
uses: ./.github/actions/setup
2222

2323
- name: Lint files
24-
run: yarn lint
24+
run: bun run lint
2525

2626
- name: Typecheck files
27-
run: yarn typecheck
27+
run: bun run typecheck
2828

2929
test:
3030
runs-on: ubuntu-latest
@@ -36,7 +36,7 @@ jobs:
3636
uses: ./.github/actions/setup
3737

3838
- name: Run unit tests
39-
run: yarn test --maxWorkers=2 --coverage
39+
run: bun run test --maxWorkers=2 --coverage
4040

4141
build-library:
4242
runs-on: ubuntu-latest
@@ -48,7 +48,7 @@ jobs:
4848
uses: ./.github/actions/setup
4949

5050
- name: Build package
51-
run: yarn prepare
51+
run: bun run prepare
5252

5353
build-web:
5454
runs-on: ubuntu-latest
@@ -61,4 +61,4 @@ jobs:
6161

6262
- name: Build example for Web
6363
run: |
64-
yarn example expo export --platform web
64+
bun run example expo export --platform web

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,9 @@ lib/
8080
# React Native Codegen
8181
ios/generated
8282
android/generated
83+
84+
.cursor
85+
86+
dist
87+
88+
coverage

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Lines changed: 0 additions & 541 deletions
This file was deleted.

.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Lines changed: 0 additions & 28 deletions
This file was deleted.

.yarn/releases/yarn-3.6.1.cjs

Lines changed: 0 additions & 874 deletions
This file was deleted.

.yarnrc.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ We want this community to be friendly and respectful to each other. Please follo
66

77
## Development workflow
88

9-
This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
9+
This project is a monorepo managed using [Bun workspaces](https://bun.sh/docs/install/workspaces). It contains the following packages:
1010

1111
- The library package in the root directory.
1212
- An example app in the `example/` directory.
1313

14-
To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
14+
To get started with the project, run `bun install` in the root directory to install the required dependencies for each package:
1515

1616
```sh
17-
yarn
17+
bun install
1818
```
1919

20-
> Since the project relies on Yarn workspaces, you cannot use [`npm`](https://github.com/npm/cli) for development.
20+
> Since the project relies on Bun workspaces, you should use [`bun`](https://bun.sh) for development.
2121
2222
The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make.
2323

@@ -28,44 +28,44 @@ You can use various commands from the root directory to work with the project.
2828
To start the packager:
2929

3030
```sh
31-
yarn example start
31+
bun example start
3232
```
3333

3434
To run the example app on Android:
3535

3636
```sh
37-
yarn example android
37+
bun example android
3838
```
3939

4040
To run the example app on iOS:
4141

4242
```sh
43-
yarn example ios
43+
bun example ios
4444
```
4545

4646
To run the example app on Web:
4747

4848
```sh
49-
yarn example web
49+
bun example web
5050
```
5151

5252
Make sure your code passes TypeScript and ESLint. Run the following to verify:
5353

5454
```sh
55-
yarn typecheck
56-
yarn lint
55+
bun run typecheck
56+
bun run lint
5757
```
5858

5959
To fix formatting errors, run the following:
6060

6161
```sh
62-
yarn lint --fix
62+
bun run lint --fix
6363
```
6464

6565
Remember to add tests for your change if possible. Run the unit tests by:
6666

6767
```sh
68-
yarn test
68+
bun test
6969
```
7070

7171
### Commit message convention
@@ -96,20 +96,20 @@ We use [release-it](https://github.com/release-it/release-it) to make it easier
9696
To publish new versions, run the following:
9797

9898
```sh
99-
yarn release
99+
bun run release
100100
```
101101

102102
### Scripts
103103

104104
The `package.json` file contains various scripts for common tasks:
105105

106-
- `yarn`: setup project by installing dependencies.
107-
- `yarn typecheck`: type-check files with TypeScript.
108-
- `yarn lint`: lint files with ESLint.
109-
- `yarn test`: run unit tests with Jest.
110-
- `yarn example start`: start the Metro server for the example app.
111-
- `yarn example android`: run the example app on Android.
112-
- `yarn example ios`: run the example app on iOS.
106+
- `bun install`: setup project by installing dependencies.
107+
- `bun run typecheck`: type-check files with TypeScript.
108+
- `bun run lint`: lint files with ESLint.
109+
- `bun test`: run unit tests with Jest.
110+
- `bun example start`: start the Metro server for the example app.
111+
- `bun example android`: run the example app on Android.
112+
- `bun example ios`: run the example app on iOS.
113113

114114
### Sending a pull request
115115

README.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1+
## Pressto 🔥
2+
13
https://github.com/user-attachments/assets/c857eb8d-3ce7-4afe-b2dd-e974560684d8
24

35
The fastest way to improve your React Native app is by using tap gestures.
46
That's why I've created **pressto**, a super-simple package to help you get started.
57

6-
The package is built on top of the Tap Gesture from [react-native-gesture-handler](https://docs.swmansion.com/react-native-gesture-handler/) to handle the resulting gestures and animations on the main thread. It aims to replace your “TouchableOpacity”.
8+
The package is built on top of the BaseButton from [react-native-gesture-handler](https://docs.swmansion.com/react-native-gesture-handler/) to handle the resulting gestures and animations on the main thread. It aims to replace your “TouchableOpacity”.
79

810
## Installation
911

1012
```sh
11-
yarn add pressto react-native-reanimated react-native-gesture-handler
13+
bun add pressto react-native-reanimated react-native-gesture-handler react-native-worklets
1214
```
1315

1416
Or with Expo
1517

1618
```sh
17-
npx expo install pressto react-native-reanimated react-native-gesture-handler
19+
npx expo install pressto react-native-reanimated react-native-gesture-handler react-native-worklets
1820
```
1921

2022
## Features
@@ -95,7 +97,7 @@ function App() {
9597
export default () => (
9698
<PressablesConfig
9799
animationType="spring"
98-
config={{ mass: 2 }}
100+
config={{ mass: 1, damping: 30, stiffness: 200 }}
99101
globalHandlers={{
100102
onPress: () => {
101103
console.log('you can call haptics here');
@@ -125,28 +127,38 @@ A function to create custom animated pressables. It takes a worklet function tha
125127

126128
A component to configure global settings for all pressable components within its children.
127129

128-
## Use with ScrollView and FlatList/FlashList
130+
## Avoid highlight flicker effect in Scrollable List
129131

130-
`pressto` provides an optional custom scroll render component that enhances the scrolling experience when used with pressable components.
132+
Since pressto is built on top of the BaseButton from react-native-gesture-handler, it handles tap conflict detection automatically when used with a FlatList imported from react-native-gesture-handler.
131133

132134
```jsx
133-
import { renderScrollComponent } from 'pressto';
134-
import { FlatList } from 'react-native';
135+
import { FlatList } from 'react-native-gesture-handler';
135136

136137
function App() {
137138
return (
138-
// This works with all the lists that support the renderScrollComponent prop
139139
<FlatList
140-
renderScrollComponent={renderScrollComponent}
141140
data={data}
142141
renderItem={({ item }) => <PressableRotate style={styles.box} />}
143142
/>
144143
);
145144
}
146145
```
147146

148-
The `renderScrollComponent` function wraps the scroll view with additional functionality in order to allow smoother interactions between scrolling and pressable components, preventing unwanted activations during scroll gestures.
149-
Applying the renderScrollComponent from `pressto` means that the tap gesture will be delayed for a short amount of time to understand if the tap gesture is a scroll or a tap gesture.
147+
You can also use whatever Scrollable component you want, as long as it supports the renderScrollComponent prop.
148+
149+
```jsx
150+
import { WhateverList } from 'your-favorite-list-package'
151+
import { ScrollView } from 'react-native-gesture-handler';
152+
153+
function App() {
154+
return (
155+
<WhateverList
156+
data={data}
157+
renderItem={({ item }) => <PressableRotate style={styles.box} />}
158+
renderScrollComponent={(props) => <ScrollView {...props} />}
159+
);
160+
}
161+
```
150162

151163
## Contributing
152164

0 commit comments

Comments
 (0)