import { isNil } from 'ramda';
import { ViewStyle } from 'react-native';

/**
 * All the variations of screens.
 */
export const presets = {
  /**
   * No scrolling. Suitable for full-screen carousels and ~/components
   * which have built-in scrolling like FlatList.
   */
  fixed: {
    outer: {
      flex: 1,
    } as ViewStyle,
  },

  /**
   * Scrolls. Suitable for forms or other things requiring a keyboard.
   *
   * Pick this one if you don't know which one you want yet.
   */
  scroll: {
    outer: {
      flexBasis: 1,
    } as ViewStyle,
    inner: {
      minHeight: '100%',
    } as ViewStyle,
  },
};

/**
 * The variations of screens.
 */
export type ScreenPresets = keyof typeof presets;

/**
 * Is this preset a non-scrolling one?
 *
 * @param preset The preset to check
 */
export function isNonScrolling(preset: ScreenPresets) {
  // any of these things will make you scroll
  return isNil(preset) || !preset.length || isNil(presets[preset]) || preset === 'fixed';
}
