Skip to content

Commit 8792e73

Browse files
committed
Merge branch 'main' into feat/drag-events
2 parents 7f55b25 + 744905a commit 8792e73

File tree

6 files changed

+15
-219
lines changed

6 files changed

+15
-219
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.lodev09.truesheet
33
import android.graphics.Color
44
import android.util.Log
55
import android.view.WindowManager
6+
import com.facebook.react.bridge.ColorPropConverter
67
import com.facebook.react.bridge.ReadableArray
78
import com.facebook.react.bridge.ReadableType
89
import com.facebook.react.common.MapBuilder
@@ -96,8 +97,8 @@ class TrueSheetViewManager : ViewGroupManager<TrueSheetView>() {
9697
}
9798

9899
@ReactProp(name = "background")
99-
fun setBackground(view: TrueSheetView, colorName: String) {
100-
val color = runCatching { Color.parseColor(colorName) }.getOrDefault(Color.WHITE)
100+
fun setBackground(view: TrueSheetView, colorName: Double) {
101+
val color = runCatching { ColorPropConverter.getColor(colorName, view.context) }.getOrDefault(Color.WHITE)
101102
view.setBackground(color)
102103
}
103104

@@ -107,10 +108,13 @@ class TrueSheetViewManager : ViewGroupManager<TrueSheetView>() {
107108
for (i in 0 until minOf(sizes.size(), 3)) {
108109
when (sizes.getType(i)) {
109110
ReadableType.Number -> result.add(sizes.getDouble(i))
111+
110112
// React Native < 0.77 used String for getString, but 0.77
111113
// changed it to String?. Suppress the error for older APIs.
112114
@Suppress("UNNECESSARY_SAFE_CALL")
113-
ReadableType.String -> sizes.getString(i)?.let { result.add(it) }
115+
ReadableType.String
116+
-> sizes.getString(i)?.let { result.add(it) }
117+
114118
else -> Log.d(TAG, "Invalid type")
115119
}
116120
}

ios/Extensions/UIColor+withName.swift

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

ios/TrueSheetView.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,8 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
266266
}
267267

268268
@objc
269-
func setBackground(_ color: NSString?) {
270-
if let color {
271-
viewController.backgroundColor = UIColor(name: color as String)
272-
} else {
273-
viewController.backgroundColor = nil
274-
}
275-
269+
func setBackground(_ color: NSNumber?) {
270+
viewController.backgroundColor = RCTConvert.uiColor(color)
276271
viewController.setupBackground()
277272
}
278273

ios/TrueSheetViewManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ @interface RCT_EXTERN_REMAP_MODULE (TrueSheetView, TrueSheetViewManager, RCTView
3535
RCT_EXPORT_VIEW_PROPERTY(maxHeight, NSNumber)
3636
RCT_EXPORT_VIEW_PROPERTY(sizes, NSArray)
3737
RCT_EXPORT_VIEW_PROPERTY(blurTint, NSString)
38-
RCT_EXPORT_VIEW_PROPERTY(background, NSString)
38+
RCT_EXPORT_VIEW_PROPERTY(background, NSNumber)
3939
RCT_EXPORT_VIEW_PROPERTY(cornerRadius, NSNumber)
4040
RCT_EXPORT_VIEW_PROPERTY(grabber, BOOL)
4141
RCT_EXPORT_VIEW_PROPERTY(dismissible, BOOL)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lodev09/react-native-true-sheet",
3-
"version": "1.0.3",
3+
"version": "1.1.0",
44
"description": "The true native bottom sheet experience for your React Native Apps.",
55
"source": "./src/index.ts",
66
"main": "./lib/commonjs/index.js",

src/TrueSheet.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
type ViewStyle,
99
type NativeSyntheticEvent,
1010
type LayoutChangeEvent,
11-
type ColorValue,
11+
type ProcessedColorValue,
12+
processColor,
1213
} from 'react-native'
1314

1415
import type { TrueSheetProps, SizeInfo } from './TrueSheet.types'
@@ -33,7 +34,7 @@ interface TrueSheetNativeViewProps
3334
extends Omit<TrueSheetProps, 'onPresent' | 'onSizeChange' | 'backgroundColor'> {
3435
contentHeight?: number
3536
footerHeight?: number
36-
background?: ColorValue
37+
background?: ProcessedColorValue | null
3738
scrollableHandle: number | null
3839
onPresent: (event: SizeChangeEvent) => void
3940
onSizeChange: (event: SizeChangeEvent) => void
@@ -272,7 +273,7 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
272273
scrollableHandle={this.state.scrollableHandle}
273274
sizes={sizes}
274275
blurTint={blurTint}
275-
background={backgroundColor}
276+
background={processColor(backgroundColor)}
276277
cornerRadius={cornerRadius}
277278
contentHeight={this.state.contentHeight}
278279
footerHeight={this.state.footerHeight}

0 commit comments

Comments
 (0)