Skip to content

fix: make NSNumber nonnull on iOS #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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 @@ -44,7 +44,7 @@ protected static void open(final Activity activity,
CustomTabColorSchemeParams.Builder paramsBuilder = new CustomTabColorSchemeParams.Builder();
paramsBuilder.setNavigationBarColor(blackColor);

if (barTintColor != null) {
if (barTintColor != -1) {
@ColorInt int intValue = barTintColor.intValue();

paramsBuilder.setToolbarColor(intValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public void onHostDestroy() {}

@Override
public void open(String url,
Double barTintColor,
Double controlTintColor,
@Nullable String dismissButtonStyle,
@Nullable Double barTintColor,
@Nullable Double controlTintColor,
Promise promise) {
if (mBrowserVisible) {
promise.reject("swan_browser_visible",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public void onHostDestroy() {}

@ReactMethod
public void open(String url,
Double barTintColor,
Double controlTintColor,
@Nullable String dismissButtonStyle,
@Nullable Double barTintColor,
@Nullable Double controlTintColor,
Promise promise) {
if (mBrowserVisible) {
promise.reject("swan_browser_visible",
Expand Down
12 changes: 6 additions & 6 deletions ios/RNSwanBrowser.mm
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
}

- (void)open:(NSString *)url
barTintColor:(nonnull NSNumber *)barTintColor
controlTintColor:(nonnull NSNumber *)controlTintColor
dismissButtonStyle:(NSString *)dismissButtonStyle
barTintColor:(NSNumber *)barTintColor
controlTintColor:(NSNumber *)controlTintColor
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject {
#else
RCT_EXPORT_METHOD(open:(NSString *)url
barTintColor:(nonnull NSNumber *)barTintColor
controlTintColor:(nonnull NSNumber *)controlTintColor
dismissButtonStyle:(NSString *)dismissButtonStyle
barTintColor:(NSNumber *)barTintColor
controlTintColor:(NSNumber *)controlTintColor
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject) {
#endif
Expand All @@ -89,10 +89,10 @@ - (void)open:(NSString *)url
[_safariVC setDismissButtonStyle:SFSafariViewControllerDismissButtonStyleDone];
}

if (barTintColor != nil) {
if ([barTintColor intValue] != -1) {
[_safariVC setPreferredBarTintColor:[RCTConvert UIColor:barTintColor]];
}
if (controlTintColor != nil) {
if ([controlTintColor intValue] != -1) {
[_safariVC setPreferredControlTintColor:[RCTConvert UIColor:controlTintColor]];
}

Expand Down
4 changes: 2 additions & 2 deletions src/NativeRNSwanBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { TurboModuleRegistry } from "react-native";
export interface Spec extends TurboModule {
open(
url: string,
barTintColor: number,
controlTintColor: number,
dismissButtonStyle?: string,
barTintColor?: number,
controlTintColor?: number,
): Promise<null>;

close(): void;
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export const openBrowser = (url: string, options: Options): Promise<void> => {

return NativeModule.open(
url,
convertColorToNumber(barTintColor) || -1,
convertColorToNumber(controlTintColor) || -1,
dismissButtonStyle,
convertColorToNumber(barTintColor),
convertColorToNumber(controlTintColor),
).then(() => {
let deeplink: string | undefined;

Expand Down