/** * Platform rules for the `VideoFeed` `autosizing` and `maxVideos` props. * * Both props mean the same thing to a host app on either platform, but the native SDKs * do not offer them the same way, so the differences are collected here instead of being * spread through the component. */ /** * Videos an autosized feed loads at most: one page. A feed that grows with its content has * to stay bounded, so both SDKs reduce a larger `maxVideos` to this. */ export const AUTOSIZED_MAX_VIDEOS = 20; /** * Whether `autosizing` can be honored for `mode` on `platform`. * * iOS sizes a `grid`/`column` feed to its content and a `row` feed to its fixed row * height, so every mode is supported. The Android SDK only derives a height for `grid`: * a `row` or `column` feed keeps a fixed height there, so an autosized one would collapse * instead of expanding. */ export function isAutosizingSupported( platform: string, mode: string | undefined ): boolean { if (platform === 'ios') { return true; } if (platform === 'android') { return mode === 'grid'; } return false; } /** * Whether a validated `maxVideos` can be forwarded to the native feed. * * The Android SDK has no separate autosizing switch: it expands a grid feed to its * content height exactly when a cap is set. Forwarding a cap for a fixed-height feed * would silently turn that feed into an expanding one, so on Android the cap only * reaches feeds that are autosizing anyway. iOS takes the cap independently of sizing. */ export function isMaxVideosSupported( platform: string, autosizingEnabled: boolean ): boolean { return platform !== 'android' || autosizingEnabled; } /** * Whether `maxVideos` will be reduced to [AUTOSIZED_MAX_VIDEOS] by the native feed. * * Both SDKs bound an autosized feed that expands with its content to a single page. A `row` * feed is never bounded this way: iOS gives it a fixed row height instead of expanding, and * Android does not autosize it at all. * * The reduction happens natively; this only reports it so the caller can warn rather than * leave the host app wondering why it asked for more videos than it got. */ export function isMaxVideosCapped( maxVideos: number, autosizingEnabled: boolean, mode: string | undefined ): boolean { return ( autosizingEnabled && (mode ?? 'row') !== 'row' && maxVideos > AUTOSIZED_MAX_VIDEOS ); }