Skip to content

Commit 954431f

Browse files
chore(fix): resolve issue of unable to use custom colors in header and back icon in smallPlug
1 parent 575bfeb commit 954431f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

ios/SmallcaseGateway.m

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,25 @@ @interface RCT_EXTERN_MODULE(SmallcaseGateway, NSObject)
383383
rejecter:(RCTPromiseRejectBlock)reject)
384384
{
385385
dispatch_async(dispatch_get_main_queue(), ^(void) {
386+
387+
NSString* (^processColorValue)(NSString*, NSString*) = ^NSString*(NSString *color, NSString *defaultColor) {
388+
if (color == nil || color.length < 6) {
389+
return defaultColor;
390+
}
391+
if ([color hasPrefix:@"#"]) {
392+
return [color substringFromIndex:1];
393+
}
394+
return color;
395+
};
396+
397+
NSString *processedHeaderColor = processColorValue(headerColor, @"2F363F");
398+
NSString *processedBackIconColor = processColorValue(backIconColor, @"ffffff");
399+
400+
double finalHeaderOpacity = headerOpacity != nil ? [headerOpacity doubleValue] : 1.0;
401+
double finalBackIconOpacity = backIconOpacity != nil ? [backIconOpacity doubleValue] : 1.0;
386402

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

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

0 commit comments

Comments
 (0)