import 'package:component_library/component_library.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:storybook_flutter/storybook_flutter.dart';

List<Story> getStories(GolekThemeData theme) {
  return [
    Story(
      name: 'Plain Input Field',
      section: 'Form Input',
      builder: (_, k) => InputField(
        errorMessage: k.text(label: 'errorMessage'),
        placeholder: k.text(
          label: 'placeholder',
          initial: 'Placeholder',
        ),
        label: k.text(label: 'Label', initial: 'Label'),
        obscureText: k.boolean(label: 'obscureText', initial: false),
        textInputType: k.options<TextInputType>(
            label: 'textInputType',
            initial: TextInputType.text,
            options: [
              const Option('Email', TextInputType.emailAddress),
              const Option('Number', TextInputType.number),
              const Option('Date Time', TextInputType.datetime),
            ]),
        inputFormatters: k.options<List<TextInputFormatter>>(
          label: 'inputFormatters',
          initial: [],
          options: [
            Option(
              'Maximum Text Input Formatter',
              [LengthLimitingTextInputFormatter(12)],
            ),
            Option(
              'Regex Filter Text Input Formatter',
              [FilteringTextInputFormatter.allow(RegExp(r'^[2-9][0-9]*'))],
            ),
          ],
        ),
        isDisabled: k.boolean(
          label: 'disabled',
          initial: false,
        ),
        isTouched: k.boolean(
          label: 'touched',
          initial: false,
        ),
        isError: k.boolean(
          label: 'error',
          initial: false,
        ),
      ),
    ),
    Story(
      name: 'Plain Input File',
      section: 'Form Input',
      builder: (_, k) => InputFile(
        allowMultiple: k.boolean(label: 'allowMultiple', initial: false),
        onChange: (files) {},
        files: [],
        inputLabel: '',
      ),
    ),
    Story.simple(
      name: 'Simple Expanded Elevated Button',
      section: 'Buttons',
      child: ExpandedElevatedButton(
        label: 'Press me',
        onTap: () {},
      ),
    ),
    Story(
      name: 'Expanded Elevated Button',
      section: 'Buttons',
      builder: (_, k) => ExpandedElevatedButton(
        label: k.text(
          label: 'label',
          initial: 'Press me',
        ),
        onTap: k.boolean(
          label: 'onTap',
          initial: true,
        )
            ? () {}
            : null,
        icon: Icon(
          k.options<IconData>(
            label: 'icon',
            initial: Icons.home,
            options: const [
              Option(
                'Login',
                Icons.login,
              ),
              Option(
                'Refresh',
                Icons.refresh,
              ),
              Option(
                'Logout',
                Icons.logout,
              ),
            ],
          ),
        ),
      ),
    ),
    Story(
      name: 'InProgress Expanded Elevated Button',
      section: 'Buttons',
      builder: (_, k) => ExpandedElevatedButton.inProgress(
        label: k.text(
          label: 'label',
          initial: 'Processing',
        ),
      ),
    ),
  ];
}
