Skip to content

Commit d198158

Browse files
authored
feat: New Arc support (#106)
* feat: upgrade example to expo 52 * fix(new-arch): fix touchable * fix(example): disable expo-autolinking in prebuild * fix: move width updates to JS * fix: scrollview handle * chore: deps * chore: deps * chore: git rid of expo example * chore: android build * fix(android): container size change * fix(ios): update size event * chore: remove flunky ci * chore: fix version * feat: update example * docs: add edgeToEdge guide
1 parent 65d3316 commit d198158

File tree

102 files changed

+15588
-11696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+15588
-11696
lines changed

.github/actions/setup/action.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@ runs:
55
using: composite
66
steps:
77
- name: Setup Node.js
8-
uses: actions/setup-node@v4
8+
uses: actions/setup-node@v3
99
with:
1010
node-version-file: .nvmrc
1111

12-
- name: Enable Corepack
13-
run: corepack enable
14-
shell: bash
15-
1612
- name: Cache dependencies
1713
id: yarn-cache
18-
uses: actions/cache@v4
14+
uses: actions/cache@v3
1915
with:
2016
path: |
2117
**/node_modules

.github/workflows/ci.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ on:
66
pull_request:
77
branches:
88
- main
9+
merge_group:
10+
types:
11+
- checks_requested
912

1013
jobs:
1114
lint:
1215
runs-on: ubuntu-latest
1316
steps:
1417
- name: Checkout
15-
uses: actions/checkout@v4
18+
uses: actions/checkout@v3
1619

1720
- name: Setup
1821
uses: ./.github/actions/setup
@@ -27,31 +30,19 @@ jobs:
2730
runs-on: ubuntu-latest
2831
steps:
2932
- name: Checkout
30-
uses: actions/checkout@v4
33+
uses: actions/checkout@v3
3134

3235
- name: Setup
3336
uses: ./.github/actions/setup
3437

3538
- name: Run unit tests
3639
run: yarn test --maxWorkers=2 --coverage
3740

38-
verify:
39-
runs-on: ubuntu-latest
40-
steps:
41-
- name: Checkout
42-
uses: actions/checkout@v4
43-
44-
- name: Setup
45-
uses: ./.github/actions/setup
46-
47-
- name: Run expo doctor
48-
run: yarn example doctor
49-
5041
build-library:
5142
runs-on: ubuntu-latest
5243
steps:
5344
- name: Checkout
54-
uses: actions/checkout@v4
45+
uses: actions/checkout@v3
5546

5647
- name: Setup
5748
uses: ./.github/actions/setup

.gitignore

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,15 @@ android/keystores/debug.keystore
7272
# Expo
7373
.expo/
7474

75+
# Turborepo
76+
.turbo/
77+
7578
# generated by bob
7679
lib/
7780

78-
# Example
79-
example/ios
80-
example/android
81+
# React Native Codegen
82+
ios/generated
83+
android/generated
84+
85+
# Docs
8186
.vercel

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

Lines changed: 541 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 28 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/releases/yarn-3.6.1.cjs

Lines changed: 874 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
nmHoistingLimits: workspaces
2-
31
nodeLinker: node-modules
2+
nmHoistingLimits: workspaces
43

54
plugins:
6-
spec: "@yarnpkg/plugin-workspace-tools"
5+
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
6+
spec: "@yarnpkg/plugin-interactive-tools"
7+
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
8+
spec: "@yarnpkg/plugin-workspace-tools"
9+
10+
yarnPath: .yarn/releases/yarn-3.6.1.cjs

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ The [example app](/example/) demonstrates usage of the library. You need to run
2323

2424
It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
2525

26-
If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/TrueSheetExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > TrueSheet`.
26+
If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/TrueSheetExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-true-sheet`.
2727

2828
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-true-sheet` under `Android`.
2929

3030
You can use various commands from the root directory to work with the project.
3131

3232
To start the packager:
3333

34+
```sh
35+
yarn example start
36+
```
37+
3438
To run the example app on Android:
3539

3640
```sh
@@ -43,7 +47,7 @@ To run the example app on iOS:
4347
yarn example ios
4448
```
4549

46-
Make sure your code passes TypeScript and ESLint. Run the following to verify:
50+
Make sure your code passes TypeScript and ESLint. Run the following to verify and fix:
4751

4852
```sh
4953
yarn tidy

android/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ buildscript {
1414
}
1515
}
1616

17+
def reactNativeArchitectures() {
18+
def value = rootProject.getProperties().get("reactNativeArchitectures")
19+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20+
}
21+
1722
def isNewArchitectureEnabled() {
1823
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
1924
}
@@ -90,6 +95,6 @@ dependencies {
9095
//noinspection GradleDynamicVersion
9196
implementation "com.facebook.react:react-native:+"
9297
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
93-
implementation "com.google.android.material:material:1.11.0"
98+
implementation 'com.google.android.material:material:1.12.0'
9499
}
95100

android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
7676
maxScreenHeight = Utils.screenHeight(reactContext, edgeToEdge)
7777
}
7878

79-
override fun getEdgeToEdgeEnabled(): Boolean {
80-
return edgeToEdge || super.getEdgeToEdgeEnabled()
81-
}
79+
override fun getEdgeToEdgeEnabled(): Boolean = edgeToEdge || super.getEdgeToEdgeEnabled()
8280

8381
override fun onStart() {
8482
super.onStart()
@@ -259,8 +257,8 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
259257
})
260258
}
261259

262-
fun setOnSizeChangeListener(listener: RootSheetView.OnSizeChangeListener) {
263-
rootSheetView.setOnSizeChangeListener(listener)
260+
fun setOnSizeChangeListener(listener: (w: Int, h: Int) -> Unit) {
261+
rootSheetView.sizeChangeListener = listener
264262
}
265263

266264
/**

android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import com.facebook.react.uimanager.UIManagerHelper
1212
import com.facebook.react.uimanager.events.EventDispatcher
1313
import com.google.android.material.bottomsheet.BottomSheetBehavior
1414
import com.lodev09.truesheet.core.RootSheetView
15+
import com.lodev09.truesheet.core.Utils
16+
import com.lodev09.truesheet.events.ContainerSizeChangeEvent
1517
import com.lodev09.truesheet.events.DismissEvent
1618
import com.lodev09.truesheet.events.MountEvent
1719
import com.lodev09.truesheet.events.PresentEvent
@@ -67,6 +69,10 @@ class TrueSheetView(context: Context) :
6769

6870
// Configure Sheet Dialog
6971
sheetDialog.apply {
72+
setOnSizeChangeListener { w, h ->
73+
eventDispatcher?.dispatchEvent(ContainerSizeChangeEvent(surfaceId, id, Utils.toDIP(w), Utils.toDIP(h)))
74+
}
75+
7076
// Setup listener when the dialog has been presented.
7177
setOnShowListener {
7278
registerKeyboardManager()

android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.facebook.react.uimanager.ThemedReactContext
99
import com.facebook.react.uimanager.ViewGroupManager
1010
import com.facebook.react.uimanager.annotations.ReactProp
1111
import com.lodev09.truesheet.core.Utils
12+
import com.lodev09.truesheet.events.ContainerSizeChangeEvent
1213
import com.lodev09.truesheet.events.DismissEvent
1314
import com.lodev09.truesheet.events.MountEvent
1415
import com.lodev09.truesheet.events.PresentEvent
@@ -30,6 +31,7 @@ class TrueSheetViewManager : ViewGroupManager<TrueSheetView>() {
3031
.put(PresentEvent.EVENT_NAME, MapBuilder.of("registrationName", "onPresent"))
3132
.put(DismissEvent.EVENT_NAME, MapBuilder.of("registrationName", "onDismiss"))
3233
.put(SizeChangeEvent.EVENT_NAME, MapBuilder.of("registrationName", "onSizeChange"))
34+
.put(ContainerSizeChangeEvent.EVENT_NAME, MapBuilder.of("registrationName", "onContainerSizeChange"))
3335
.build()
3436

3537
@ReactProp(name = "edgeToEdge")

android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import android.annotation.SuppressLint
44
import android.content.Context
55
import android.view.MotionEvent
66
import android.view.View
7-
import com.facebook.react.bridge.GuardedRunnable
87
import com.facebook.react.config.ReactFeatureFlags
98
import com.facebook.react.uimanager.JSPointerDispatcher
109
import com.facebook.react.uimanager.JSTouchDispatcher
1110
import com.facebook.react.uimanager.RootView
1211
import com.facebook.react.uimanager.ThemedReactContext
13-
import com.facebook.react.uimanager.UIManagerModule
1412
import com.facebook.react.uimanager.events.EventDispatcher
1513
import com.facebook.react.views.view.ReactViewGroup
1614

@@ -35,14 +33,10 @@ class RootSheetView(private val context: Context?) :
3533

3634
private val jSTouchDispatcher = JSTouchDispatcher(this)
3735
private var jSPointerDispatcher: JSPointerDispatcher? = null
38-
private var sizeChangeListener: OnSizeChangeListener? = null
36+
public var sizeChangeListener: ((w: Int, h: Int) -> Unit)? = null
3937

4038
var eventDispatcher: EventDispatcher? = null
4139

42-
interface OnSizeChangeListener {
43-
fun onSizeChange(width: Int, height: Int)
44-
}
45-
4640
init {
4741
if (ReactFeatureFlags.dispatchPointerEvents) {
4842
jSPointerDispatcher = JSPointerDispatcher(this)
@@ -55,30 +49,12 @@ class RootSheetView(private val context: Context?) :
5549
viewWidth = w
5650
viewHeight = h
5751
updateFirstChildView()
58-
59-
sizeChangeListener?.onSizeChange(w, h)
60-
}
61-
62-
fun setOnSizeChangeListener(listener: OnSizeChangeListener) {
63-
sizeChangeListener = listener
6452
}
6553

6654
private fun updateFirstChildView() {
6755
if (childCount > 0) {
6856
hasAdjustedSize = false
69-
val viewTag = getChildAt(0).id
70-
reactContext.runOnNativeModulesQueueThread(
71-
object : GuardedRunnable(reactContext) {
72-
override fun runGuarded() {
73-
val uiManager: UIManagerModule =
74-
reactContext
75-
.reactApplicationContext
76-
.getNativeModule(UIManagerModule::class.java) ?: return
77-
78-
uiManager.updateNodeSize(viewTag, viewWidth, viewHeight)
79-
}
80-
}
81-
)
57+
sizeChangeListener?.let { it(viewWidth, viewHeight) }
8258
} else {
8359
hasAdjustedSize = true
8460
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.lodev09.truesheet.events
2+
3+
import com.facebook.react.bridge.Arguments
4+
import com.facebook.react.bridge.WritableMap
5+
import com.facebook.react.uimanager.events.Event
6+
7+
// onContainerSizeChange
8+
class ContainerSizeChangeEvent(surfaceId: Int, viewId: Int, private val width: Float, private val height: Float) :
9+
Event<ContainerSizeChangeEvent>(surfaceId, viewId) {
10+
override fun getEventName() = EVENT_NAME
11+
12+
override fun getEventData(): WritableMap {
13+
val data = Arguments.createMap()
14+
data.putDouble("width", width.toDouble())
15+
data.putDouble("height", height.toDouble())
16+
17+
return data
18+
}
19+
20+
companion object {
21+
const val EVENT_NAME = "containerSizeChange"
22+
}
23+
}

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
presets: ['module:@react-native/babel-preset'],
2+
presets: [['module:react-native-builder-bob/babel-preset', { modules: 'commonjs' }]],
33
}

docs/docs/guides/edge2edge.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Enable edge-to-edge
3+
description: Turning on edge-to-edge support for Android.
4+
keywords: [bottom sheet edge-to-edge, edge-to-edge, android]
5+
---
6+
7+
Yes! TrueSheet does support [`edge-to-edge`](https://developer.android.com/develop/ui/views/layout/edge-to-edge).
8+
9+
## How?
10+
11+
It's easy, just set [`edgeToEdge`](/reference/props#edgetoedge) to `true`.
12+
13+
```tsx {3}
14+
const App = () => {
15+
return (
16+
<TrueSheet edgeToEdge={true}>
17+
<View />
18+
</TrueSheet>
19+
)
20+
}
21+
```
22+
23+
## react-native-edge-to-edge
24+
25+
[`react-native-edge-to-edge`](https://github.com/zoontek/react-native-edge-to-edge) is a cool tiny package that lets you effortlessly enable `edge-to-edge` display for your app. Go check it out!

docs/docs/reference/01-props.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ Shows a grabber (or handle). Native on IOS and styled `View` on Android.
133133
| - | - | - | - |
134134
| `boolean` | `true` |||
135135

136+
### `edgeToEdge`
137+
138+
Supports edge-to-edge on Android. Turn this on if your app has it enabled.
139+
140+
| Type | Default | 🍎 | 🤖 |
141+
| - | - | - | - |
142+
| `boolean` | | ||
143+
136144
### `grabberProps`
137145

138146
Overrides the grabber props for android.

example/Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
33
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
44
ruby ">= 2.6.10"
55

6-
# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
7-
# bound in the template on Cocoapods with next React Native release.
8-
gem 'cocoapods', '>= 1.13', '< 1.15'
9-
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
6+
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
7+
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
8+
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9+
gem 'xcodeproj', '< 1.26.0'

0 commit comments

Comments
 (0)