2020-10-30 13:59:44 +00:00
|
|
|
import React from 'react';
|
2020-11-30 21:47:05 +00:00
|
|
|
import {
|
2021-01-21 19:52:26 +00:00
|
|
|
View, Text, StyleSheet, I18nManager
|
2020-11-30 21:47:05 +00:00
|
|
|
} from 'react-native';
|
2020-10-30 13:59:44 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import Touch from '../../utils/touch';
|
|
|
|
import { themes } from '../../constants/colors';
|
|
|
|
import sharedStyles from '../../views/Styles';
|
|
|
|
import { withTheme } from '../../theme';
|
|
|
|
import I18n from '../../i18n';
|
|
|
|
import { Icon } from '.';
|
[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
|
|
|
import { BASE_HEIGHT, ICON_SIZE, PADDING_HORIZONTAL } from './constants';
|
2020-10-30 13:59:44 +00:00
|
|
|
import { withDimensions } from '../../dimensions';
|
[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
|
|
|
import { CustomIcon } from '../../lib/Icons';
|
2020-10-30 13:59:44 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
paddingHorizontal: PADDING_HORIZONTAL
|
|
|
|
},
|
|
|
|
leftContainer: {
|
|
|
|
paddingRight: PADDING_HORIZONTAL
|
|
|
|
},
|
|
|
|
rightContainer: {
|
|
|
|
paddingLeft: PADDING_HORIZONTAL
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
opacity: 0.3
|
|
|
|
},
|
|
|
|
textContainer: {
|
|
|
|
flex: 1,
|
|
|
|
justifyContent: 'center'
|
|
|
|
},
|
[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
|
|
|
textAlertContainer: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center'
|
|
|
|
},
|
|
|
|
alertIcon: {
|
|
|
|
paddingLeft: 4
|
|
|
|
},
|
2020-10-30 13:59:44 +00:00
|
|
|
title: {
|
[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
|
|
|
flexShrink: 1,
|
2020-10-30 13:59:44 +00:00
|
|
|
fontSize: 16,
|
|
|
|
...sharedStyles.textRegular
|
|
|
|
},
|
|
|
|
subtitle: {
|
|
|
|
fontSize: 14,
|
|
|
|
...sharedStyles.textRegular
|
2020-11-30 21:47:05 +00:00
|
|
|
},
|
|
|
|
actionIndicator: {
|
|
|
|
...I18nManager.isRTL
|
|
|
|
? { transform: [{ rotate: '180deg' }] }
|
|
|
|
: {}
|
2020-10-30 13:59:44 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const Content = React.memo(({
|
[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
|
|
|
title, subtitle, disabled, testID, left, right, color, theme, translateTitle, translateSubtitle, showActionIndicator, fontScale, alert
|
2020-10-30 13:59:44 +00:00
|
|
|
}) => (
|
|
|
|
<View style={[styles.container, disabled && styles.disabled, { height: BASE_HEIGHT * fontScale }]} testID={testID}>
|
|
|
|
{left
|
|
|
|
? (
|
|
|
|
<View style={styles.leftContainer}>
|
|
|
|
{left()}
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
: null}
|
|
|
|
<View style={styles.textContainer}>
|
[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
|
|
|
<View style={styles.textAlertContainer}>
|
|
|
|
<Text style={[styles.title, { color: color || themes[theme].titleText }]} numberOfLines={1}>{translateTitle ? I18n.t(title) : title}</Text>
|
|
|
|
{alert ? (
|
|
|
|
<CustomIcon style={[styles.alertIcon, { color: themes[theme].dangerColor }]} size={ICON_SIZE} name='info' />
|
|
|
|
) : null}
|
|
|
|
</View>
|
2020-10-30 13:59:44 +00:00
|
|
|
{subtitle
|
|
|
|
? <Text style={[styles.subtitle, { color: themes[theme].auxiliaryText }]} numberOfLines={1}>{translateSubtitle ? I18n.t(subtitle) : subtitle}</Text>
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
</View>
|
|
|
|
{right || showActionIndicator
|
|
|
|
? (
|
|
|
|
<View style={styles.rightContainer}>
|
|
|
|
{right ? right() : null}
|
2020-11-30 21:47:05 +00:00
|
|
|
{showActionIndicator ? <Icon name='chevron-right' style={styles.actionIndicator} /> : null}
|
2020-10-30 13:59:44 +00:00
|
|
|
</View>
|
|
|
|
)
|
|
|
|
: null}
|
|
|
|
</View>
|
|
|
|
));
|
|
|
|
|
|
|
|
const Button = React.memo(({
|
2021-01-21 19:52:26 +00:00
|
|
|
onPress, backgroundColor, underlayColor, ...props
|
2020-10-30 13:59:44 +00:00
|
|
|
}) => (
|
|
|
|
<Touch
|
|
|
|
onPress={() => onPress(props.title)}
|
2021-01-21 19:52:26 +00:00
|
|
|
style={{ backgroundColor: backgroundColor || themes[props.theme].backgroundColor }}
|
|
|
|
underlayColor={underlayColor}
|
2020-10-30 13:59:44 +00:00
|
|
|
enabled={!props.disabled}
|
|
|
|
theme={props.theme}
|
|
|
|
>
|
|
|
|
<Content {...props} />
|
|
|
|
</Touch>
|
|
|
|
));
|
|
|
|
|
|
|
|
const ListItem = React.memo(({ ...props }) => {
|
|
|
|
if (props.onPress) {
|
|
|
|
return <Button {...props} />;
|
|
|
|
}
|
|
|
|
return (
|
2021-01-21 19:52:26 +00:00
|
|
|
<View style={{ backgroundColor: props.backgroundColor || themes[props.theme].backgroundColor }}>
|
2020-10-30 13:59:44 +00:00
|
|
|
<Content {...props} />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
ListItem.propTypes = {
|
|
|
|
onPress: PropTypes.func,
|
2021-01-21 19:52:26 +00:00
|
|
|
theme: PropTypes.string,
|
|
|
|
backgroundColor: PropTypes.string
|
2020-10-30 13:59:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ListItem.displayName = 'List.Item';
|
|
|
|
|
|
|
|
Content.propTypes = {
|
|
|
|
title: PropTypes.string.isRequired,
|
|
|
|
subtitle: PropTypes.string,
|
|
|
|
left: PropTypes.func,
|
|
|
|
right: PropTypes.func,
|
|
|
|
disabled: PropTypes.bool,
|
|
|
|
testID: PropTypes.string,
|
|
|
|
theme: PropTypes.string,
|
|
|
|
color: PropTypes.string,
|
|
|
|
translateTitle: PropTypes.bool,
|
|
|
|
translateSubtitle: PropTypes.bool,
|
|
|
|
showActionIndicator: PropTypes.bool,
|
[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
|
|
|
fontScale: PropTypes.number,
|
|
|
|
alert: PropTypes.bool
|
2020-10-30 13:59:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Content.defaultProps = {
|
|
|
|
translateTitle: true,
|
|
|
|
translateSubtitle: true,
|
|
|
|
showActionIndicator: false
|
|
|
|
};
|
|
|
|
|
|
|
|
Button.propTypes = {
|
|
|
|
title: PropTypes.string,
|
|
|
|
onPress: PropTypes.func,
|
|
|
|
disabled: PropTypes.bool,
|
2021-01-21 19:52:26 +00:00
|
|
|
theme: PropTypes.string,
|
|
|
|
backgroundColor: PropTypes.string,
|
|
|
|
underlayColor: PropTypes.string
|
2020-10-30 13:59:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Button.defaultProps = {
|
|
|
|
disabled: false
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withTheme(withDimensions(ListItem));
|