-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for the new architecture
- Loading branch information
1 parent
bfd6d6e
commit 22f391f
Showing
7 changed files
with
117 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
android/src/main/java/com/facebook/reactnative/androidsdk/RCTLoginButtonEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.facebook.reactnative.androidsdk; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.facebook.react.bridge.WritableMap; | ||
import com.facebook.react.uimanager.events.Event; | ||
|
||
public class RCTLoginButtonEvent extends Event<RCTLoginButtonEvent> { | ||
public static final String EVENT_NAME = "topChange"; | ||
private final WritableMap mEvent; | ||
|
||
public RCTLoginButtonEvent(int surfaceId, int viewTag, WritableMap event) { | ||
super(surfaceId,viewTag); | ||
mEvent = event; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getEventName() { | ||
return EVENT_NAME; | ||
} | ||
|
||
@Override | ||
protected WritableMap getEventData() { | ||
return mEvent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#import <FBSDKLoginKit/FBSDKLoginKit.h> | ||
|
||
#import <React/RCTComponent.h> | ||
#import <React/RCTEventDispatcher.h> | ||
|
||
@interface RCTFBSDKLoginButtonView: UIView<FBSDKLoginButtonDelegate> | ||
|
||
@property (nonatomic, copy) RCTBubblingEventBlock onChange; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#import "RCTFBSDKLoginButtonView.h" | ||
|
||
#import <React/RCTComponentEvent.h> | ||
#import <React/RCTEventDispatcher.h> | ||
#import <React/RCTUtils.h> | ||
#import <React/UIView+React.h> | ||
|
||
|
||
@interface RCTFBSDKLoginButtonView () | ||
|
||
@property (nonatomic, strong) FBSDKLoginButton *loginButton; | ||
|
||
@end | ||
|
||
@implementation RCTFBSDKLoginButtonView | ||
|
||
- (instancetype)init | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
self.loginButton = [[FBSDKLoginButton alloc] init]; | ||
self.loginButton.delegate = self; | ||
self.loginButton.frame = self.bounds; | ||
self.loginButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
|
||
[self addSubview:_loginButton]; | ||
|
||
return self; | ||
} | ||
return self; | ||
} | ||
|
||
#pragma mark - FBSDKLoginButtonDelegate | ||
|
||
- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error | ||
{ | ||
NSDictionary *body = @{ | ||
@"type": @"loginFinished", | ||
@"error": error ? RCTJSErrorFromNSError(error) : [NSNull null], | ||
@"result": error ? [NSNull null] : @{ | ||
@"isCancelled": @(result.isCancelled), | ||
@"grantedPermissions": result.isCancelled ? [NSNull null] : result.grantedPermissions.allObjects, | ||
@"declinedPermissions": result.isCancelled ? [NSNull null] : result.declinedPermissions.allObjects, | ||
}, | ||
}; | ||
|
||
self.onChange(body); | ||
} | ||
|
||
- (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton | ||
{ | ||
NSDictionary *body = @{ | ||
@"type": @"logoutFinished", | ||
}; | ||
|
||
self.onChange(body); | ||
} | ||
|
||
@end |