import { storiesOf } from '@storybook/react-native';
import * as React from 'react';
import { View, Alert, ViewStyle } from 'react-native';

import { StoryScreen, Story, UseCase } from '~/storybook/views';
import { color } from '~/theme';

import { Header } from './header';

declare let module;

const VIEWSTYLE = {
  flex: 1,
  backgroundColor: color.storybookDarkBg,
} as ViewStyle;

storiesOf('Header', module)
  .addDecorator((fn) => <StoryScreen>{fn()}</StoryScreen>)
  .add('Behavior', () => (
    <Story>
      <UseCase noPad text="default" usage="The default usage">
        <View style={VIEWSTYLE}>
          <Header headerText="Demo screen header" />
        </View>
      </UseCase>
      <UseCase noPad text="leftIcon" usage="A left nav icon">
        <View style={VIEWSTYLE}>
          <Header
            headerText="Demo screen header"
            leftIcon="chevron-left"
            onLeftPress={() => Alert.alert('left nav')}
          />
        </View>
      </UseCase>
      <UseCase noPad text="rightIcon" usage="A right nav icon">
        <View style={VIEWSTYLE}>
          <Header
            headerText="Demo screen header"
            rightIcon="expand"
            onRightPress={() => Alert.alert('right nav')}
          />
        </View>
      </UseCase>
      <UseCase noPad text="rightIcon" usage="A right nav icon">
        <View style={VIEWSTYLE}>
          <Header
            headerText="Demo screen header"
            leftIcon="chevron-left"
            rightIcon="person"
            titleStyle={{ color: color.active }}
            onRightPress={() => Alert.alert('right nav')}
          />
        </View>
      </UseCase>
    </Story>
  ));
