Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,14 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
}

@ReactMethod
fun launchSmallplugWithBranding(targetEndpoint: String, params: String, readableMap: ReadableMap?, promise: Promise) {
fun launchSmallplugWithBranding(targetEndpoint: String, params: String, headerColor: String?, headerOpacity: Double?, backIconColor: String?, backIconOpacity: Double?, promise: Promise
) {
val readableMap = Arguments.createMap().apply {
headerColor?.let { putString("headerColor", it) }
headerOpacity?.let { putDouble("headerOpacity", it) }
backIconColor?.let { putString("backIconColor", it) }
backIconOpacity?.let { putDouble("backIconOpacity", it) }
}

fun getColorValue(value: Any?, defaultValue: String): String {
return when (value) {
Expand All @@ -196,7 +203,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
var partnerProps: SmallplugPartnerProps? = SmallplugPartnerProps(headerColor = "#2F363F", backIconColor = "ffffff")

try {
partnerProps = readableMap?.toHashMap()?.let { map ->
partnerProps = readableMap.toHashMap().let { map ->
val hc = getColorValue(map["headerColor"], "#2F363F")
val ho = map["headerOpacity"]?.let { if (it is Double) it else 1.0 } ?: 1.0
val bc = getColorValue(map["backIconColor"], "#ffffff")
Expand All @@ -206,19 +213,16 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
} catch (e: Throwable) {
}


SmallcaseGatewaySdk.launchSmallPlug(currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener {
override fun onFailure(errorCode: Int, errorMessage: String) {
val err = createErrorJSON(errorCode, errorMessage, null)

promise.reject("error", err)
}

override fun onSuccess(smallPlugResult: SmallPlugResult) {
val res = resultToWritableMap(smallPlugResult)
promise.resolve(res)
}

}, partnerProps)
}

Expand Down
24 changes: 20 additions & 4 deletions ios/SmallcaseGateway.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ @interface RCT_EXTERN_MODULE(SmallcaseGateway, NSObject)
RCT_REMAP_METHOD(setConfigEnvironment,
envName:(NSString *)envName
gateway:(NSString *)gateway
isLeprechaunActive: (BOOL *)isLeprechaunActive
isAmoEnabled: (BOOL *)isAmoEnabled
isLeprechaunActive: (BOOL)isLeprechaunActive
isAmoEnabled: (BOOL)isAmoEnabled
preProvidedBrokers: (NSArray *)preProvidedBrokers
setConfigEnvironmentWithResolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
Expand Down Expand Up @@ -383,9 +383,25 @@ @interface RCT_EXTERN_MODULE(SmallcaseGateway, NSObject)
rejecter:(RCTPromiseRejectBlock)reject)
{
dispatch_async(dispatch_get_main_queue(), ^(void) {

NSString* (^processColorValue)(NSString*, NSString*) = ^NSString*(NSString *color, NSString *defaultColor) {
if (color == nil || color.length < 6) {
return defaultColor;
}
if ([color hasPrefix:@"#"]) {
return [color substringFromIndex:1];
}
return color;
};

NSString *processedHeaderColor = processColorValue(headerColor, @"2F363F");
NSString *processedBackIconColor = processColorValue(backIconColor, @"ffffff");

double finalHeaderOpacity = headerOpacity != nil ? [headerOpacity doubleValue] : 1.0;
double finalBackIconOpacity = backIconOpacity != nil ? [backIconOpacity doubleValue] : 1.0;

SmallplugData *smallplugData = [[SmallplugData alloc] init:targetEndpoint :params];
SmallplugUiConfig *smallplugUiConfig = [[SmallplugUiConfig alloc] initWithSmallplugHeaderColor:headerColor headerColorOpacity:headerOpacity backIconColor:backIconColor backIconColorOpacity:backIconOpacity];
SmallplugUiConfig *smallplugUiConfig = [[SmallplugUiConfig alloc] initWithSmallplugHeaderColor:processedHeaderColor headerColorOpacity:@(finalHeaderOpacity) backIconColor:processedBackIconColor backIconColorOpacity:@(finalBackIconOpacity)];

[SCGateway.shared launchSmallPlugWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] smallplugData:smallplugData smallplugUiConfig:smallplugUiConfig completion:^(id smallplugResponse, NSError * error) {

Expand Down Expand Up @@ -480,7 +496,7 @@ @interface RCT_EXTERN_MODULE(SmallcaseGateway, NSObject)
RCT_REMAP_METHOD(triggerLeadGenWithLoginCta,
userParams: (NSDictionary *)userParams
utmParams:(NSDictionary *)utmParams
showLoginCta:(BOOL *)showLoginCta
showLoginCta:(BOOL)showLoginCta
leadGenGenWithResolver: (RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject
) {
Expand Down
2 changes: 1 addition & 1 deletion smart_investing_react_native/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false
newArchEnabled=true

# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
Expand Down
5 changes: 3 additions & 2 deletions smart_investing_react_native/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ target 'smart_investing_react_native' do

use_react_native!(
:path => config[:reactNativePath],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
:app_path => "#{Pod::Config.instance.installation_root}/..",
:fabric_enabled => true,
:hermes_enabled => true
)

post_install do |installer|
Expand Down
Loading