UNPKG

@matt-block/react-native-in-app-browser

Version:
128 lines (127 loc) 4.14 kB
/** * Copyright (c) 2018-2020, Matei Bogdan Radu <opensource@mateiradu.dev> * * This source code is licensed under the MIT license found in the LICENSE * file in the root directory of this source tree. */ import { PlatformOSType } from 'react-native'; import { ColorInput } from '@ctrl/tinycolor'; export interface Settings { /** * Android specific settings. * * All settings are optional and invalid ones will be ignored. * * The implementation uses Chrome Custom Tabs. */ android?: SettingsAndroid; /** * iOS specific settings. * * All settings are optional and invalid ones will be ignored. * * The implementation uses Safari View Manager. */ ios?: SettingsIOS; } export interface SettingsAndroid { /** * The color to tint the background of the toolbar. * * **Note**: if the color string is invalid, this setting will be ignored. */ toolbarColor?: ColorInput; /** * Flag to toggle if the title should be shown in the custom tab. * * **Note**: if the value is invalid, this setting will be ignored. */ showTitle?: boolean; /** * Custom close button icon. * * Provided icon must be a `.png`, `.jpg`, or `.gif` file. * * **Note**: if icon asset is invalid, this setting will be ignored. */ closeButtonIcon?: any; /** * Flag to toggle the default share menu. * * **Note**: if the value is invalid, this setting will be ignored. */ addDefaultShareMenu?: boolean; } export interface SettingsIOS { /** * The color to tint the background of the navigation bar and the toolbar. * * **Available on**: iOS >= 10.0. * * **Note**: if the color string is invalid or if the current iOS version * is < 10.0, this setting will be ignored. */ preferredBarTintColor?: ColorInput; /** * The color to tint the control buttons on the navigation bar and the * toolbar. * * **Available on**: iOS >= 10.0. * * **Note**: if the color string is invalid or if the current iOS version * is < 10.0, this setting will be ignored. */ preferredControlTintColor?: ColorInput; /** * **Available on**: iOS >= 11.0. * * **Note**: if the value is invalid or if the current iOS version * is < 11.0, this setting will be ignored. */ barCollapsingEnabled?: boolean; /** * A value that specifies whether Safari should enter Reader mode, if it is available. * * **Available on**: iOS >= 11.0. * * **Note**: if the value is invalid or if the current iOS version * is < 11.0, this setting will be ignored. */ entersReaderIfAvailable?: boolean; /** * **Available on**: iOS >= 11.0. * * **Note**: if the value is invalid or if the current iOS version * is < 11.0, this setting will be ignored. */ dismissButtonStyle?: IOSDismissButtonStyle; [key: string]: any; } declare const iosDismissButtonStyles: readonly ["done", "close", "cancel"]; declare type IOSDismissButtonStyle = typeof iosDismissButtonStyles[number]; /** * Default settings. * * These values can be augmented throgh initialization. */ export declare const defaultSettings: Required<Settings>; /** * Sanitize the settings based on the running OS. * * Provided settings will be merged with the default ones. * Also, in case of same properties, provided ones have priority * over defaults. */ export declare function sanitize(os: 'android', settings?: Settings): SettingsAndroid; export declare function sanitize(os: 'ios', settings?: Settings): SettingsIOS; export declare function sanitize(os: PlatformOSType, settings?: Settings): {}; /** * Initializes the platform-specific settings for the in-app browser * experience. * * This utility function is useful when `openInApp` is used in several * portions of the application code base as it allows to provide the * settings only once instead of specifing them with each call. */ export declare function initialize(settings: Settings): void; export {};