create-react-native-library 0.56.0 → 0.56.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-react-native-library",
3
- "version": "0.56.0",
3
+ "version": "0.56.1",
4
4
  "description": "CLI to scaffold React Native libraries",
5
5
  "keywords": [
6
6
  "react-native",
@@ -63,5 +63,5 @@
63
63
  "@types/fs-extra": "^9.0.13",
64
64
  "@types/validate-npm-package-name": "^3.0.3"
65
65
  },
66
- "gitHead": "674ccc16f182e55b5086ba7c26a6b82318de2fc1"
66
+ "gitHead": "109bd9b8813db79b30665b558f3fd687e1f8709c"
67
67
  }
@@ -31,8 +31,8 @@ class <%- project.name -%>ViewManager : SimpleViewManager<<%- project.name -%>Vi
31
31
  }
32
32
 
33
33
  @ReactProp(name = "color")
34
- override fun setColor(view: <%- project.name -%>View?, color: String?) {
35
- view?.setBackgroundColor(Color.parseColor(color))
34
+ override fun setColor(view: <%- project.name -%>View?, color: Int?) {
35
+ view?.setBackgroundColor(color ?: Color.TRANSPARENT)
36
36
  }
37
37
 
38
38
  companion object {
@@ -1,7 +1,11 @@
1
- import { codegenNativeComponent, type ViewProps } from 'react-native';
1
+ import {
2
+ codegenNativeComponent,
3
+ type ColorValue,
4
+ type ViewProps,
5
+ } from 'react-native';
2
6
 
3
7
  interface NativeProps extends ViewProps {
4
- color?: string;
8
+ color?: ColorValue;
5
9
  }
6
10
 
7
11
  export default codegenNativeComponent<NativeProps>('<%- project.name -%>View');
@@ -8,10 +8,8 @@ import androidx.core.graphics.toColorInt
8
8
  @DoNotStrip
9
9
  class Hybrid<%- project.name %>(val context: ThemedReactContext) : Hybrid<%- project.name %>Spec() {
10
10
 
11
- // View
12
11
  override val view: View = View(context)
13
12
 
14
- // Props
15
13
  private var _color = "#000"
16
14
  override var color: String
17
15
  get() = _color
@@ -1,7 +1,8 @@
1
1
  #import "<%- project.name -%>View.h"
2
2
 
3
+ #import <React/RCTConversions.h>
4
+
3
5
  #import <react/renderer/components/<%- project.name -%>ViewSpec/ComponentDescriptors.h>
4
- #import <react/renderer/components/<%- project.name -%>ViewSpec/EventEmitters.h>
5
6
  #import <react/renderer/components/<%- project.name -%>ViewSpec/Props.h>
6
7
  #import <react/renderer/components/<%- project.name -%>ViewSpec/RCTComponentViewHelpers.h>
7
8
 
@@ -9,10 +10,6 @@
9
10
 
10
11
  using namespace facebook::react;
11
12
 
12
- @interface <%- project.name -%>View () <RCT<%- project.name -%>ViewViewProtocol>
13
-
14
- @end
15
-
16
13
  @implementation <%- project.name -%>View {
17
14
  UIView * _view;
18
15
  }
@@ -42,30 +39,10 @@ using namespace facebook::react;
42
39
  const auto &newViewProps = *std::static_pointer_cast<<%- project.name -%>ViewProps const>(props);
43
40
 
44
41
  if (oldViewProps.color != newViewProps.color) {
45
- NSString * colorToConvert = [[NSString alloc] initWithUTF8String: newViewProps.color.c_str()];
46
- [_view setBackgroundColor:[self hexStringToColor:colorToConvert]];
42
+ [_view setBackgroundColor: RCTUIColorFromSharedColor(newViewProps.color)];
47
43
  }
48
44
 
49
45
  [super updateProps:props oldProps:oldProps];
50
46
  }
51
47
 
52
- Class<RCTComponentViewProtocol> <%- project.name -%>ViewCls(void)
53
- {
54
- return <%- project.name -%>View.class;
55
- }
56
-
57
- - hexStringToColor:(NSString *)stringToConvert
58
- {
59
- NSString *noHashString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""];
60
- NSScanner *stringScanner = [NSScanner scannerWithString:noHashString];
61
-
62
- unsigned hex;
63
- if (![stringScanner scanHexInt:&hex]) return nil;
64
- int r = (hex >> 16) & 0xFF;
65
- int g = (hex >> 8) & 0xFF;
66
- int b = (hex) & 0xFF;
67
-
68
- return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f];
69
- }
70
-
71
48
  @end