2020-10-30 13:59:44 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { FlatList } from 'react-native';
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
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';
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export default {
|
|
|
|
title: 'List'
|
|
|
|
};
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const TitleAndSubtitle = () => (
|
2020-10-30 13:59:44 +00:00
|
|
|
<List.Container>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Chats' />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Chats' subtitle='All' />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title={longText} subtitle={longText} translateTitle={false} translateSubtitle={false} testID='test-id' />
|
|
|
|
<List.Separator />
|
|
|
|
</List.Container>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Alert = () => (
|
[NEW] Leave Teams (#3116)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Minor tweak
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Lint
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-25 18:04:05 +00:00
|
|
|
<List.Container>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Chats' alert />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title={longText} translateTitle={false} translateSubtitle={false} alert />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Chats' right={() => <List.Icon name='emoji' />} alert />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title={longText} translateTitle={false} translateSubtitle={false} right={() => <List.Icon name='emoji' />} alert />
|
|
|
|
<List.Separator />
|
|
|
|
</List.Container>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
[NEW] Leave Teams (#3116)
* Added Create Team
* Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
* Added createTeam sagas, createTeam reducer, new Team string and update CreateChannelView
* Remove unnecessary actionTypes, reducers and sagas, e2e tests and navigation to team view
* Minor tweaks
* Show TeamChannelsView only if joined the team
* Minor tweak
* Added AddChannelTeamView
* Added permissions, translations strings for teams, deleteTeamRoom and addTeamRooms, AddExistingChannelView, updated CreateChannelView, TeamChannelsView
* Refactor touch component and update removeRoom and deleteRoom methods
* Minor tweaks
* Minor tweaks for removing channels and addExistingChannelView
* Added missing events and fixed channels list
* Minor tweaks for refactored touch component
* Added SelectListView and logic for leaving team
* Minor tweak
* Minor tweak
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* Remove unnecesary prop
* Add screens to ModalStack, events, autoJoin, update createChannel, addRoomsToTeam and Touchable
* Minor tweak
* Update loadMessagesForRoom.js
* Updated schema, tag component, touch, AddChannelTeamView, AddExistingChannelView, ActionSheet Item
* Fix unnecessary changes
* Add i18n, update createChannel, AddExistingChannelTeamView, AddChannelTeamView, RightButton and TeamChannelsView
* Updated styles, added tag story
* Minor tweak
* Minor tweaks
* Auto-join tweak
* Minor tweaks
* Minor tweak on search
* Minor refactor to ListItem, add SelectListView to ModalStack, update handleLeaveTeam
* Minor tweaks
* Update SelectListView
* Update handleLeaveTeam, remove unnecessary method, add story
* Minor tweak
* Minor visual tweaks
* Updated SelectListView, RoomActionsView, leaveTeam method and string translations
* Update SelectListVIew
* Minor tweak
* Update SelectListView
* Minor tweak
* Fix for List.Item subtitles being pushed down by title's flex
* Minor tweaks
* Update RoomActionsView
* Use showConfirmationAlert and showErrorAlert
* Lint
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-25 18:04:05 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Pressable = () => (
|
2020-10-30 13:59:44 +00:00
|
|
|
<List.Container>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Press me' onPress={() => alert('Hi there!')} translateTitle={false} />
|
|
|
|
<List.Separator />
|
2021-09-13 20:41:05 +00:00
|
|
|
<List.Item title={"I'm disabled"} onPress={() => alert('Hi there!')} disabled translateTitle={false} />
|
2020-10-30 13:59:44 +00:00
|
|
|
<List.Separator />
|
|
|
|
</List.Container>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Header = () => (
|
2020-10-30 13:59:44 +00:00
|
|
|
<List.Container>
|
|
|
|
<List.Header title='Chats' />
|
|
|
|
<List.Header title={longText} translateTitle={false} />
|
|
|
|
</List.Container>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Icon = () => (
|
2020-10-30 13:59:44 +00:00
|
|
|
<List.Container>
|
|
|
|
<List.Icon name='emoji' />
|
|
|
|
</List.Container>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Separator = () => (
|
2020-10-30 13:59:44 +00:00
|
|
|
<List.Container>
|
|
|
|
<List.Separator />
|
|
|
|
</List.Container>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const SectionAndInfo = () => (
|
2020-10-30 13:59:44 +00:00
|
|
|
<SafeAreaView>
|
|
|
|
<List.Container>
|
|
|
|
<List.Section>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Section Item' translateTitle={false} />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Section Item' translateTitle={false} />
|
|
|
|
<List.Separator />
|
|
|
|
</List.Section>
|
|
|
|
<List.Section>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Section Item' translateTitle={false} />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Section Item' translateTitle={false} />
|
|
|
|
<List.Separator />
|
|
|
|
</List.Section>
|
|
|
|
<List.Section title='Chats'>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Section Item' translateTitle={false} />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Section Item' translateTitle={false} />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Info info='Chats' />
|
|
|
|
</List.Section>
|
|
|
|
<List.Section title={longText} translateTitle={false}>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Section Item' translateTitle={false} />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Section Item' translateTitle={false} />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Info info={longText} translateInfo={false} />
|
|
|
|
</List.Section>
|
|
|
|
</List.Container>
|
|
|
|
</SafeAreaView>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const WithIcon = () => (
|
2020-10-30 13:59:44 +00:00
|
|
|
<List.Container>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Icon Left' translateTitle={false} left={() => <List.Icon name='emoji' />} />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Icon Right' translateTitle={false} right={() => <List.Icon name='emoji' />} />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item
|
|
|
|
title={longText}
|
|
|
|
subtitle={longText}
|
|
|
|
translateTitle={false}
|
|
|
|
translateSubtitle={false}
|
|
|
|
left={() => <List.Icon name='emoji' />}
|
|
|
|
right={() => <List.Icon name='emoji' />}
|
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Show Action Indicator' translateTitle={false} showActionIndicator />
|
|
|
|
<List.Separator />
|
|
|
|
</List.Container>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const WithCustomColors = () => (
|
2020-10-30 13:59:44 +00:00
|
|
|
<List.Container>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item title='Chats' color='red' />
|
|
|
|
<List.Separator />
|
2021-01-21 19:52:26 +00:00
|
|
|
<List.Item
|
|
|
|
title='Press me!'
|
|
|
|
color='white'
|
|
|
|
onPress={() => alert('Press')}
|
|
|
|
backgroundColor='red'
|
|
|
|
underlayColor='green'
|
|
|
|
translateTitle={false}
|
|
|
|
/>
|
|
|
|
<List.Separator />
|
2020-10-30 13:59:44 +00:00
|
|
|
</List.Container>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|
2020-10-30 13:59:44 +00:00
|
|
|
|
|
|
|
const ListItemFull = ({ ...props }) => (
|
|
|
|
<List.Item
|
|
|
|
title='Chats'
|
|
|
|
subtitle='All'
|
|
|
|
onPress={() => alert('Hi')}
|
|
|
|
left={() => <List.Icon name='emoji' />}
|
|
|
|
right={() => <List.Icon name='emoji' />}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const ListFull = () => (
|
|
|
|
<SafeAreaView>
|
|
|
|
<List.Container>
|
|
|
|
<List.Section title='Chats'>
|
|
|
|
<List.Separator />
|
|
|
|
<ListItemFull />
|
|
|
|
<List.Separator />
|
|
|
|
<ListItemFull disabled />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Info info='Chats' />
|
|
|
|
</List.Section>
|
|
|
|
<List.Section title='Chats'>
|
|
|
|
<List.Separator />
|
|
|
|
<ListItemFull />
|
|
|
|
<List.Separator />
|
|
|
|
<ListItemFull disabled />
|
|
|
|
<List.Separator />
|
|
|
|
<List.Info info='Chats' />
|
|
|
|
</List.Section>
|
|
|
|
</List.Container>
|
|
|
|
</SafeAreaView>
|
|
|
|
);
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
const ThemeStory = ({ theme }: { theme: TSupportedThemes }) => (
|
2022-08-17 13:32:21 +00:00
|
|
|
<ThemeContext.Provider value={{ theme, colors: themes[theme] }}>
|
2020-10-30 13:59:44 +00:00
|
|
|
<ListFull />
|
|
|
|
</ThemeContext.Provider>
|
|
|
|
);
|
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const WithDarkTheme = () => <ThemeStory theme='dark' />;
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const WithBlackTheme = () => <ThemeStory theme='black' />;
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
const FontStory = ({ fontScale }: { fontScale: number }) => (
|
|
|
|
// @ts-ignore
|
2021-09-13 20:41:05 +00:00
|
|
|
<DimensionsContext.Provider value={{ fontScale }}>
|
2020-10-30 13:59:44 +00:00
|
|
|
<ListFull />
|
|
|
|
</DimensionsContext.Provider>
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* It's going to test height only.
|
|
|
|
* Font scale on text and icons is applied based on OS setting
|
|
|
|
*/
|
2022-08-19 19:53:40 +00:00
|
|
|
export const WithSmallFont = () => <FontStory fontScale={0.8} />;
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const WithBiggerFont = () => <FontStory fontScale={1.5} />;
|
2020-10-30 13:59:44 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const WithFlatList = () => (
|
2020-10-30 13:59:44 +00:00
|
|
|
<SafeAreaView>
|
|
|
|
<FlatList
|
|
|
|
data={[...Array(30).keys()]}
|
|
|
|
contentContainerStyle={List.styles.contentContainerStyleFlatList}
|
2022-08-19 19:53:40 +00:00
|
|
|
renderItem={({ item }) => <List.Item title={item.toString()} translateTitle={false} />}
|
2020-10-30 13:59:44 +00:00
|
|
|
ListHeaderComponent={List.Separator}
|
|
|
|
ListFooterComponent={List.Separator}
|
|
|
|
ItemSeparatorComponent={List.Separator}
|
|
|
|
/>
|
|
|
|
</SafeAreaView>
|
2022-08-19 19:53:40 +00:00
|
|
|
);
|