/* eslint-disable react-native/no-inline-styles */
/* eslint-disable react-native/no-color-literals */

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

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

import { Checkbox } from './checkbox';

declare let module;

const arrayStyle: ViewStyle[] = [{ paddingVertical: 40 }, { alignSelf: 'flex-end' }];
const arrayOutlineStyle: ViewStyle[] = [{ borderColor: '#b443c9' }, { borderWidth: 25 }];
const arrayFillStyle: ViewStyle[] = [{ backgroundColor: '#55e0ff' }];

storiesOf('Checkbox', module)
  .addDecorator((fn) => <StoryScreen>{fn()}</StoryScreen>)
  .add('Behaviour', () => (
    <Story>
      <UseCase text="The Checkbox" usage="Use the checkbox to represent on/off states.">
        <Toggle initial={false}>
          {({ on, toggle }) => <Checkbox text="Toggle me" value={on} onToggle={toggle} />}
        </Toggle>
      </UseCase>
      <UseCase text="value = true" usage="This is permanently on.">
        <Checkbox value text="Always on" />
      </UseCase>
      <UseCase text="value = false" usage="This is permanantly off.">
        <Checkbox text="Always off" value={false} />
      </UseCase>
    </Story>
  ))
  .add('Styling', () => (
    <Story>
      <UseCase text="multiline = true" usage="For really really long text">
        <Toggle initial={false}>
          {({ on, toggle }) => (
            <View>
              <Checkbox
                multiline
                text="We’re an App Design & Development Team. Experts in mobile & web technologies. We create beautiful, functional mobile apps and websites. "
                value={on}
                onToggle={toggle}
              />
            </View>
          )}
        </Toggle>
      </UseCase>
      <UseCase text=".style" usage="Override the container style">
        <Toggle initial={false}>
          {({ on, toggle }) => (
            <View>
              <Checkbox
                style={{
                  backgroundColor: 'purple',
                  marginLeft: 40,
                  paddingVertical: 30,
                  paddingLeft: 60,
                }}
                text="Hello there!"
                value={on}
                onToggle={toggle}
              />
            </View>
          )}
        </Toggle>
      </UseCase>
      <UseCase text=".outlineStyle" usage="Override the outline style">
        <Toggle initial={false}>
          {({ on, toggle }) => (
            <View>
              <Checkbox
                outlineStyle={{
                  borderColor: 'green',
                  borderRadius: 10,
                  borderWidth: 4,
                  width: 60,
                  height: 20,
                }}
                text="Outline is the box frame"
                value={on}
                onToggle={toggle}
              />
            </View>
          )}
        </Toggle>
      </UseCase>
      <UseCase text=".fillStyle" usage="Override the fill style">
        <Toggle initial={false}>
          {({ on, toggle }) => (
            <View>
              <Checkbox
                fillStyle={{ backgroundColor: 'red', borderRadius: 8 }}
                text="Fill er up"
                value={on}
                onToggle={toggle}
              />
            </View>
          )}
        </Toggle>
      </UseCase>

      <UseCase text="Array style" usage="Use array styles">
        <Toggle initial={false}>
          {({ on, toggle }) => (
            <View>
              <Checkbox
                fillStyle={arrayFillStyle}
                outlineStyle={arrayOutlineStyle}
                style={arrayStyle}
                text="Check it twice"
                value={on}
                onToggle={toggle}
              />
            </View>
          )}
        </Toggle>
      </UseCase>
    </Story>
  ));
