Skip to content

Commit 95f4ea7

Browse files
committed
Merge branch 'eaze-master'
2 parents b78c515 + ff37346 commit 95f4ea7

File tree

8 files changed

+37
-4
lines changed

8 files changed

+37
-4
lines changed

Example/src/SignatureView.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class SignatureView extends Component {
4444
style={{flex: 1, width: '100%'}}
4545
onDragEvent={this._onDragEvent.bind(this)}
4646
onSaveEvent={this._onSaveEvent.bind(this)}
47+
backgroundColor='pink'
4748
/>
4849
</View>
4950
</Modal>

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ class CustomComponent extends Component {
122122
123123
+ **maxStrokeWidth** : sets the max stroke line width (_Android only_)
124124
125+
+ **backgroundColor**: Sets the background color of the component. Defaults to white. May be 'transparent'.
126+
127+
+ **strokeColor**: Sets the color of the signature. Defaults to black.
128+
125129
### Methods
126130
127131
+ **saveImage()** : when called it will save the image and returns the base 64 encoded string on onSaveEvent() callback
@@ -169,6 +173,8 @@ class RNSignatureExample extends Component {
169173
saveImageFileInExtStorage={false}
170174
showNativeButtons={false}
171175
showTitleLabel={false}
176+
backgroundColor="#ff00ff"
177+
strokeColor="#ffffff"
172178
viewMode={"portrait"}/>
173179
174180
<View style={{ flex: 1, flexDirection: "row" }}>

android/src/main/java/com/rssignaturecapture/RSSignatureCaptureMainView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ final void saveImage() {
176176

177177

178178
byte[] byteArray = byteArrayOutputStream.toByteArray();
179-
String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
179+
String encoded = Base64.encodeToString(byteArray, Base64.NO_WRAP);
180180

181181
WritableMap event = Arguments.createMap();
182182
event.putString("pathName", file.getAbsolutePath());

android/src/main/java/com/rssignaturecapture/RSSignatureCaptureView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public Bitmap getSignature() {
9797

9898
// set the signature bitmap
9999
if (signatureBitmap == null) {
100-
signatureBitmap = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap.Config.RGB_565);
100+
signatureBitmap = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap.Config.ARGB_8888);
101101
}
102102

103103
// important for saving signature

android/src/main/java/com/rssignaturecapture/RSSignatureCaptureViewManager.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,16 @@ public void setPropsStrokeColor(RSSignatureCaptureMainView view, @Nullable Strin
101101

102102
@ReactProp(name = PROPS_BACKGROUND_COLOR)
103103
public void setPropsBackgroundColor(RSSignatureCaptureMainView view, @Nullable String color) {
104+
int parsed;
105+
if (color.equalsIgnoreCase("transparent")) {
106+
parsed = Color.TRANSPARENT;
107+
} else {
108+
parsed = Color.parseColor(color);
109+
}
110+
104111
Log.d("backgroundColor:", ""+color);
105112
if(view!=null){
106-
view.getSignatureView().setBackgroundColor(Color.parseColor(color));
113+
view.getSignatureView().setBackgroundColor(parsed);
107114
}
108115
}
109116

ios/PPSSignatureView.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ @interface PPSSignatureView () {
109109
CGPoint previousMidPoint;
110110
PPSSignaturePoint previousVertex;
111111
PPSSignaturePoint currentVelocity;
112+
UIColor* backgroundColor;
113+
UIColor* strokeColor;
112114
}
113115

114116
@end
@@ -125,6 +127,7 @@ - (void)commonInit {
125127
time(NULL);
126128

127129
self.backgroundColor = [UIColor whiteColor];
130+
self.strokeColor = [UIColor blackColor];
128131
self.opaque = NO;
129132

130133
self.context = context;

ios/RSSignatureView.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ @implementation RSSignatureView {
1919
BOOL _showBorder;
2020
BOOL _showNativeButtons;
2121
BOOL _showTitleLabel;
22+
UIColor *_backgroundColor;
23+
UIColor *_strokeColor;
2224
}
2325

2426
@synthesize sign;
2527
@synthesize manager;
2628

2729
- (instancetype)init
2830
{
29-
_showBorder = YES;
31+
_showBorder = YES;
3032
_showNativeButtons = YES;
3133
_showTitleLabel = YES;
34+
_backgroundColor = UIColor.whiteColor;
35+
_strokeColor = UIColor.blackColor;
3236
if ((self = [super init])) {
3337
_border = [CAShapeLayer layer];
3438
_border.strokeColor = [UIColor blackColor].CGColor;
@@ -65,6 +69,8 @@ - (void)layoutSubviews
6569
initWithFrame: CGRectMake(0, 0, screen.width, screen.height)
6670
context: _context];
6771
sign.manager = manager;
72+
sign.backgroundColor = _backgroundColor;
73+
sign.strokeColor = _strokeColor;
6874

6975
[self addSubview:sign];
7076

@@ -179,6 +185,14 @@ - (void)setShowTitleLabel:(BOOL)showTitleLabel {
179185
_showTitleLabel = showTitleLabel;
180186
}
181187

188+
- (void)setBackgroundColor:(UIColor*)backgroundColor {
189+
_backgroundColor = backgroundColor;
190+
}
191+
192+
- (void)setStrokeColor:(UIColor*)strokeColor {
193+
_strokeColor = strokeColor;
194+
}
195+
182196
-(void) onSaveButtonPressed {
183197
[self saveImage];
184198
}

ios/RSSignatureViewManager.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ @implementation RSSignatureViewManager
1515
RCT_EXPORT_VIEW_PROPERTY(showBorder, BOOL)
1616
RCT_EXPORT_VIEW_PROPERTY(showNativeButtons, BOOL)
1717
RCT_EXPORT_VIEW_PROPERTY(showTitleLabel, BOOL)
18+
RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
19+
RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)
1820

1921

2022
-(dispatch_queue_t) methodQueue

0 commit comments

Comments
 (0)