2020-06-15 19:35:45 +00:00
|
|
|
import React from 'react';
|
[NEW] Add/Create/Remove channel on a team (#3090)
* 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
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* 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
* One way to refactor :P
* Next level refactor :)
* Fix create group dm
* Refactor renderItem
* Minor bug fixes
* Fix stories
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-19 21:14:42 +00:00
|
|
|
import { Text, View } from 'react-native';
|
2020-06-15 19:35:45 +00:00
|
|
|
|
2022-05-03 00:48:08 +00:00
|
|
|
import { CustomIcon } from '../CustomIcon';
|
2022-03-22 20:44:27 +00:00
|
|
|
import { useTheme } from '../../theme';
|
2023-12-11 15:51:44 +00:00
|
|
|
import EventEmitter from '../../lib/methods/helpers/events';
|
|
|
|
import I18n from '../../i18n';
|
2022-05-03 00:48:08 +00:00
|
|
|
import { TActionSheetOptionsItem } from './Provider';
|
2021-09-13 20:41:05 +00:00
|
|
|
import styles from './styles';
|
2023-12-11 15:51:44 +00:00
|
|
|
import { LISTENER } from '../Toast';
|
2022-08-17 13:32:21 +00:00
|
|
|
import Touch from '../Touch';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-03-22 20:44:27 +00:00
|
|
|
export interface IActionSheetItem {
|
2022-05-03 00:48:08 +00:00
|
|
|
item: TActionSheetOptionsItem;
|
2021-09-13 20:41:05 +00:00
|
|
|
hide(): void;
|
|
|
|
}
|
2020-06-15 19:35:45 +00:00
|
|
|
|
2022-03-22 20:44:27 +00:00
|
|
|
export const Item = React.memo(({ item, hide }: IActionSheetItem) => {
|
2023-12-11 15:51:44 +00:00
|
|
|
const enabled = item?.enabled ?? true;
|
|
|
|
const { colors } = useTheme();
|
2020-06-15 19:35:45 +00:00
|
|
|
const onPress = () => {
|
2023-12-11 15:51:44 +00:00
|
|
|
if (enabled) {
|
|
|
|
hide();
|
|
|
|
item?.onPress();
|
|
|
|
} else {
|
|
|
|
EventEmitter.emit(LISTENER, { message: I18n.t('You_dont_have_permission_to_perform_this_action') });
|
|
|
|
}
|
2020-06-15 19:35:45 +00:00
|
|
|
};
|
|
|
|
|
2023-12-11 15:51:44 +00:00
|
|
|
let textColor = colors.bodyText;
|
|
|
|
if (item.danger) {
|
|
|
|
textColor = colors.dangerColor;
|
|
|
|
}
|
|
|
|
if (!enabled) {
|
|
|
|
textColor = colors.fontDisabled;
|
|
|
|
}
|
|
|
|
|
2020-06-15 19:35:45 +00:00
|
|
|
return (
|
2023-12-11 15:51:44 +00:00
|
|
|
<Touch onPress={onPress} style={[styles.item, { backgroundColor: colors.focusedBackground }]} testID={item.testID}>
|
|
|
|
{item.icon ? <CustomIcon name={item.icon} size={20} color={textColor} /> : null}
|
[NEW] Add/Create/Remove channel on a team (#3090)
* 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
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* 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
* One way to refactor :P
* Next level refactor :)
* Fix create group dm
* Refactor renderItem
* Minor bug fixes
* Fix stories
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-19 21:14:42 +00:00
|
|
|
<View style={styles.titleContainer}>
|
2023-12-11 15:51:44 +00:00
|
|
|
<Text numberOfLines={1} style={[styles.title, { color: textColor, marginLeft: item.icon ? 16 : 0 }]}>
|
[NEW] Add/Create/Remove channel on a team (#3090)
* 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
* Minor tweaks
* Remove unnecesary changes, update TeamChannelsView, AddExistingChannelView, AddChannelTeamView, createChannel, goRoom and Touchable
* 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
* One way to refactor :P
* Next level refactor :)
* Fix create group dm
* Refactor renderItem
* Minor bug fixes
* Fix stories
Co-authored-by: Diego Mello <diegolmello@gmail.com>
2021-05-19 21:14:42 +00:00
|
|
|
{item.title}
|
|
|
|
</Text>
|
|
|
|
</View>
|
2021-09-13 20:41:05 +00:00
|
|
|
{item.right ? <View style={styles.rightContainer}>{item.right ? item.right() : null}</View> : null}
|
2022-08-17 13:32:21 +00:00
|
|
|
</Touch>
|
2020-06-15 19:35:45 +00:00
|
|
|
);
|
|
|
|
});
|