Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…re-capture into eaze-master
  • Loading branch information
jedt committed Jan 26, 2021
2 parents b78c515 + ad8a6ea commit ff37346
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions Example/src/SignatureView.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class SignatureView extends Component {
style={{flex: 1, width: '100%'}}
onDragEvent={this._onDragEvent.bind(this)}
onSaveEvent={this._onSaveEvent.bind(this)}
backgroundColor='pink'
/>
</View>
</Modal>
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ class CustomComponent extends Component {
+ **maxStrokeWidth** : sets the max stroke line width (_Android only_)
+ **backgroundColor**: Sets the background color of the component. Defaults to white. May be 'transparent'.
+ **strokeColor**: Sets the color of the signature. Defaults to black.
### Methods
+ **saveImage()** : when called it will save the image and returns the base 64 encoded string on onSaveEvent() callback
Expand Down Expand Up @@ -169,6 +173,8 @@ class RNSignatureExample extends Component {
saveImageFileInExtStorage={false}
showNativeButtons={false}
showTitleLabel={false}
backgroundColor="#ff00ff"
strokeColor="#ffffff"
viewMode={"portrait"}/>
<View style={{ flex: 1, flexDirection: "row" }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ final void saveImage() {


byte[] byteArray = byteArrayOutputStream.toByteArray();
String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
String encoded = Base64.encodeToString(byteArray, Base64.NO_WRAP);

WritableMap event = Arguments.createMap();
event.putString("pathName", file.getAbsolutePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public Bitmap getSignature() {

// set the signature bitmap
if (signatureBitmap == null) {
signatureBitmap = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap.Config.RGB_565);
signatureBitmap = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap.Config.ARGB_8888);
}

// important for saving signature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,16 @@ public void setPropsStrokeColor(RSSignatureCaptureMainView view, @Nullable Strin

@ReactProp(name = PROPS_BACKGROUND_COLOR)
public void setPropsBackgroundColor(RSSignatureCaptureMainView view, @Nullable String color) {
int parsed;
if (color.equalsIgnoreCase("transparent")) {
parsed = Color.TRANSPARENT;
} else {
parsed = Color.parseColor(color);
}

Log.d("backgroundColor:", ""+color);
if(view!=null){
view.getSignatureView().setBackgroundColor(Color.parseColor(color));
view.getSignatureView().setBackgroundColor(parsed);
}
}

Expand Down
3 changes: 3 additions & 0 deletions ios/PPSSignatureView.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ @interface PPSSignatureView () {
CGPoint previousMidPoint;
PPSSignaturePoint previousVertex;
PPSSignaturePoint currentVelocity;
UIColor* backgroundColor;
UIColor* strokeColor;
}

@end
Expand All @@ -125,6 +127,7 @@ - (void)commonInit {
time(NULL);

self.backgroundColor = [UIColor whiteColor];
self.strokeColor = [UIColor blackColor];
self.opaque = NO;

self.context = context;
Expand Down
16 changes: 15 additions & 1 deletion ios/RSSignatureView.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ @implementation RSSignatureView {
BOOL _showBorder;
BOOL _showNativeButtons;
BOOL _showTitleLabel;
UIColor *_backgroundColor;
UIColor *_strokeColor;
}

@synthesize sign;
@synthesize manager;

- (instancetype)init
{
_showBorder = YES;
_showBorder = YES;
_showNativeButtons = YES;
_showTitleLabel = YES;
_backgroundColor = UIColor.whiteColor;
_strokeColor = UIColor.blackColor;
if ((self = [super init])) {
_border = [CAShapeLayer layer];
_border.strokeColor = [UIColor blackColor].CGColor;
Expand Down Expand Up @@ -65,6 +69,8 @@ - (void)layoutSubviews
initWithFrame: CGRectMake(0, 0, screen.width, screen.height)
context: _context];
sign.manager = manager;
sign.backgroundColor = _backgroundColor;
sign.strokeColor = _strokeColor;

[self addSubview:sign];

Expand Down Expand Up @@ -179,6 +185,14 @@ - (void)setShowTitleLabel:(BOOL)showTitleLabel {
_showTitleLabel = showTitleLabel;
}

- (void)setBackgroundColor:(UIColor*)backgroundColor {
_backgroundColor = backgroundColor;
}

- (void)setStrokeColor:(UIColor*)strokeColor {
_strokeColor = strokeColor;
}

-(void) onSaveButtonPressed {
[self saveImage];
}
Expand Down
2 changes: 2 additions & 0 deletions ios/RSSignatureViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ @implementation RSSignatureViewManager
RCT_EXPORT_VIEW_PROPERTY(showBorder, BOOL)
RCT_EXPORT_VIEW_PROPERTY(showNativeButtons, BOOL)
RCT_EXPORT_VIEW_PROPERTY(showTitleLabel, BOOL)
RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(strokeColor, UIColor)


-(dispatch_queue_t) methodQueue
Expand Down

0 comments on commit ff37346

Please sign in to comment.