refactor(cpp): use yoga namespace for StyleSizeLength (#260)
* refactor(cpp): use yoga namespace for StyleSizeLength - Replace yoga::StyleSizeLength with StyleSizeLength via 'using namespace yoga' - Switch from <yoga/style/StyleSizeLength.h> to <react/renderer/components/view/conversions.h> - Aligns with patterns used by react-native-safe-area-context Ref: https://github.com/lodev09/react-native-true-sheet/discussions/218 * chore: run tidy
This commit is contained in:
parent
4672bce203
commit
65ac47b738
@ -122,7 +122,13 @@ class TrueSheetViewManager :
|
||||
width = if (options.hasKey("width")) options.getDouble("width").toFloat() else null,
|
||||
height = if (options.hasKey("height")) options.getDouble("height").toFloat() else null,
|
||||
topMargin = if (options.hasKey("topMargin")) options.getDouble("topMargin").toFloat() else null,
|
||||
cornerRadius = if (options.hasKey("cornerRadius") && options.getDouble("cornerRadius") >= 0) options.getDouble("cornerRadius").toFloat() else null,
|
||||
cornerRadius = if (options.hasKey("cornerRadius") &&
|
||||
options.getDouble("cornerRadius") >= 0
|
||||
) {
|
||||
options.getDouble("cornerRadius").toFloat()
|
||||
} else {
|
||||
null
|
||||
},
|
||||
color = if (options.hasKey("color") && options.getInt("color") != 0) options.getInt("color") else null
|
||||
)
|
||||
view.setGrabberOptions(grabberOptions)
|
||||
|
||||
@ -25,10 +25,7 @@ data class GrabberOptions(
|
||||
* Displays a small pill-shaped indicator at the top of the sheet.
|
||||
*/
|
||||
@SuppressLint("ViewConstructor")
|
||||
class TrueSheetGrabberView(
|
||||
context: Context,
|
||||
private val options: GrabberOptions? = null
|
||||
) : View(context) {
|
||||
class TrueSheetGrabberView(context: Context, private val options: GrabberOptions? = null) : View(context) {
|
||||
|
||||
companion object {
|
||||
private const val DEFAULT_WIDTH = 32f // dp
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
#include "TrueSheetViewShadowNode.h"
|
||||
|
||||
#include <yoga/style/StyleSizeLength.h>
|
||||
#include <react/renderer/components/view/conversions.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
using namespace yoga;
|
||||
|
||||
extern const char TrueSheetViewComponentName[] = "TrueSheetView";
|
||||
|
||||
void TrueSheetViewShadowNode::adjustLayoutWithState() {
|
||||
@ -22,7 +24,7 @@ void TrueSheetViewShadowNode::adjustLayoutWithState() {
|
||||
|
||||
// Set width if provided
|
||||
if (stateData.containerWidth > 0) {
|
||||
adjustedStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(stateData.containerWidth));
|
||||
adjustedStyle.setDimension(yoga::Dimension::Width, StyleSizeLength::points(stateData.containerWidth));
|
||||
if (adjustedStyle.dimension(yoga::Dimension::Width) != currentStyle.dimension(yoga::Dimension::Width)) {
|
||||
needsUpdate = true;
|
||||
}
|
||||
@ -30,7 +32,7 @@ void TrueSheetViewShadowNode::adjustLayoutWithState() {
|
||||
|
||||
// Set height if provided
|
||||
if (stateData.containerHeight > 0) {
|
||||
adjustedStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(stateData.containerHeight));
|
||||
adjustedStyle.setDimension(yoga::Dimension::Height, StyleSizeLength::points(stateData.containerHeight));
|
||||
if (adjustedStyle.dimension(yoga::Dimension::Height) != currentStyle.dimension(yoga::Dimension::Height)) {
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ using namespace facebook::react;
|
||||
// Grabber options - check if any non-default values are set
|
||||
const auto &grabberOpts = newProps.grabberOptions;
|
||||
BOOL hasGrabberOptions = grabberOpts.width > 0 || grabberOpts.height > 0 || grabberOpts.topMargin > 0 ||
|
||||
grabberOpts.cornerRadius >= 0 || grabberOpts.color != 0;
|
||||
grabberOpts.cornerRadius >= 0 || grabberOpts.color != 0;
|
||||
|
||||
if (hasGrabberOptions) {
|
||||
NSMutableDictionary *options = [NSMutableDictionary dictionary];
|
||||
|
||||
@ -52,8 +52,7 @@ static const CGFloat kDefaultGrabberTopMargin = 5.0;
|
||||
|
||||
// Create blur effect for vibrancy base
|
||||
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleSystemChromeMaterial];
|
||||
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect
|
||||
style:UIVibrancyEffectStyleFill];
|
||||
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect style:UIVibrancyEffectStyleFill];
|
||||
|
||||
// Create the vibrancy view that fills this view
|
||||
_vibrancyView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user