import React from 'react';
import { FlatList } from 'react-native';
import * as List from '.';
import SafeAreaView from '../SafeAreaView';
import { longText } from '../../../.storybook/utils';
import { ThemeContext, TSupportedThemes } from '../../theme';
import { DimensionsContext } from '../../dimensions';
import { themes } from '../../lib/constants';
export default {
title: 'List'
};
export const TitleAndSubtitle = () => (
<List.Container>
<List.Separator />
<List.Item title='Chats' />
<List.Item title='Chats' subtitle='All' />
<List.Item title={longText} subtitle={longText} translateTitle={false} translateSubtitle={false} testID='test-id' />
</List.Container>
);
export const Alert = () => (
<List.Item title='Chats' alert />
<List.Item title={longText} translateTitle={false} translateSubtitle={false} alert />
<List.Item title='Chats' right={() => <List.Icon name='emoji' />} alert />
<List.Item title={longText} translateTitle={false} translateSubtitle={false} right={() => <List.Icon name='emoji' />} alert />
export const Pressable = () => (
<List.Item title='Press me' onPress={() => alert('Hi there!')} translateTitle={false} />
<List.Item title={"I'm disabled"} onPress={() => alert('Hi there!')} disabled translateTitle={false} />
export const Header = () => (
<List.Header title='Chats' />
<List.Header title={longText} translateTitle={false} />
export const Icon = () => (
<List.Icon name='emoji' />
export const Separator = () => (
export const SectionAndInfo = () => (
<SafeAreaView>
<List.Section>
<List.Item title='Section Item' translateTitle={false} />
</List.Section>
<List.Section title='Chats'>
<List.Info info='Chats' />
<List.Section title={longText} translateTitle={false}>
<List.Info info={longText} translateInfo={false} />
</SafeAreaView>
export const WithIcon = () => (
<List.Item title='Icon Left' translateTitle={false} left={() => <List.Icon name='emoji' />} />
<List.Item title='Icon Right' translateTitle={false} right={() => <List.Icon name='emoji' />} />
<List.Item
title={longText}
subtitle={longText}
translateTitle={false}
translateSubtitle={false}
left={() => <List.Icon name='emoji' />}
right={() => <List.Icon name='emoji' />}
/>
<List.Item title='Show Action Indicator' translateTitle={false} showActionIndicator />
export const WithCustomColors = () => (
<List.Item title='Chats' color='red' />
title='Press me!'
color='white'
onPress={() => alert('Press')}
backgroundColor='red'
underlayColor='green'
const ListItemFull = ({ ...props }) => (
title='Chats'
subtitle='All'
onPress={() => alert('Hi')}
{...props}
const ListFull = () => (
<ListItemFull />
<ListItemFull disabled />
const ThemeStory = ({ theme }: { theme: TSupportedThemes }) => (
<ThemeContext.Provider value={{ theme, colors: themes[theme] }}>
<ListFull />
</ThemeContext.Provider>
export const WithDarkTheme = () => <ThemeStory theme='dark' />;
export const WithBlackTheme = () => <ThemeStory theme='black' />;
const FontStory = ({ fontScale }: { fontScale: number }) => (
// @ts-ignore
<DimensionsContext.Provider value={{ fontScale }}>
</DimensionsContext.Provider>
/**
* It's going to test height only.
* Font scale on text and icons is applied based on OS setting
*/
export const WithSmallFont = () => <FontStory fontScale={0.8} />;
export const WithBiggerFont = () => <FontStory fontScale={1.5} />;
export const WithFlatList = () => (
<FlatList
data={[...Array(30).keys()]}
contentContainerStyle={List.styles.contentContainerStyleFlatList}
renderItem={({ item }) => <List.Item title={item.toString()} translateTitle={false} />}
ListHeaderComponent={List.Separator}
ListFooterComponent={List.Separator}
ItemSeparatorComponent={List.Separator}