2018-02-19 21:19:39 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-03-23 16:49:51 +00:00
|
|
|
import { View, SectionList, Text, Alert } from 'react-native';
|
2018-02-19 21:19:39 +00:00
|
|
|
import Icon from 'react-native-vector-icons/Ionicons';
|
|
|
|
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2018-04-03 16:24:59 +00:00
|
|
|
import LoggedView from '../View';
|
2018-02-19 21:19:39 +00:00
|
|
|
import styles from './styles';
|
2018-03-29 17:55:37 +00:00
|
|
|
import sharedStyles from '../Styles';
|
2018-02-19 21:19:39 +00:00
|
|
|
import Avatar from '../../containers/Avatar';
|
2018-03-29 17:55:37 +00:00
|
|
|
import Status from '../../containers/status';
|
2018-02-19 21:19:39 +00:00
|
|
|
import Touch from '../../utils/touch';
|
|
|
|
import database from '../../lib/realm';
|
2018-03-02 15:11:34 +00:00
|
|
|
import RocketChat from '../../lib/rocketchat';
|
2018-03-23 16:49:51 +00:00
|
|
|
import { leaveRoom } from '../../actions/room';
|
2018-04-24 19:34:03 +00:00
|
|
|
import { setLoading } from '../../actions/selectedUsers';
|
2018-05-18 17:55:08 +00:00
|
|
|
import log from '../../utils/log';
|
2018-05-18 16:41:47 +00:00
|
|
|
import RoomTypeIcon from '../../containers/RoomTypeIcon';
|
2018-06-01 17:38:13 +00:00
|
|
|
import I18n from '../../i18n';
|
2018-04-24 19:34:03 +00:00
|
|
|
|
|
|
|
const renderSeparator = () => <View style={styles.separator} />;
|
2018-05-18 16:41:47 +00:00
|
|
|
const getRoomTitle = room => (room.t === 'd' ? <Text>{room.fname}</Text> : <Text><RoomTypeIcon type={room.t} /> {room.name}</Text>);
|
2018-02-19 21:19:39 +00:00
|
|
|
|
|
|
|
@connect(state => ({
|
2018-04-24 19:34:03 +00:00
|
|
|
user_id: state.login.user.id,
|
|
|
|
user_username: state.login.user.username
|
2018-03-23 16:49:51 +00:00
|
|
|
}), dispatch => ({
|
2018-04-24 19:34:03 +00:00
|
|
|
leaveRoom: rid => dispatch(leaveRoom(rid)),
|
|
|
|
setLoadingInvite: loading => dispatch(setLoading(loading))
|
2018-02-19 21:19:39 +00:00
|
|
|
}))
|
2018-04-24 19:34:03 +00:00
|
|
|
|
2018-04-03 16:24:59 +00:00
|
|
|
export default class RoomActionsView extends LoggedView {
|
2018-02-19 21:19:39 +00:00
|
|
|
static propTypes = {
|
|
|
|
baseUrl: PropTypes.string,
|
2018-03-23 16:49:51 +00:00
|
|
|
user: PropTypes.object,
|
|
|
|
navigation: PropTypes.object,
|
|
|
|
leaveRoom: PropTypes.func
|
2018-02-19 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
2018-04-03 16:24:59 +00:00
|
|
|
super('RoomActionsView', props);
|
2018-02-19 21:19:39 +00:00
|
|
|
const { rid } = props.navigation.state.params;
|
|
|
|
this.rooms = database.objects('subscriptions').filtered('rid = $0', rid);
|
2018-04-24 19:34:03 +00:00
|
|
|
[this.room] = this.rooms;
|
2018-02-19 21:19:39 +00:00
|
|
|
this.state = {
|
2018-04-24 19:34:03 +00:00
|
|
|
room: this.room,
|
|
|
|
onlineMembers: [],
|
|
|
|
allMembers: [],
|
2018-03-29 17:55:37 +00:00
|
|
|
member: {}
|
2018-02-19 21:19:39 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-03-23 16:49:51 +00:00
|
|
|
async componentDidMount() {
|
2018-02-19 21:19:39 +00:00
|
|
|
this.rooms.addListener(this.updateRoom);
|
2018-04-24 19:34:03 +00:00
|
|
|
const [members, member] = await Promise.all([this.updateRoomMembers(), this.updateRoomMember()]);
|
|
|
|
this.setState({ ...members, ...member });
|
2018-02-19 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
2018-03-23 16:49:51 +00:00
|
|
|
componentWillUnmount() {
|
|
|
|
this.rooms.removeAllListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
onPressTouchable = (item) => {
|
|
|
|
if (item.route) {
|
2018-04-10 13:03:54 +00:00
|
|
|
return this.props.navigation.navigate({ key: item.route, routeName: item.route, params: item.params });
|
2018-03-23 16:49:51 +00:00
|
|
|
}
|
|
|
|
if (item.event) {
|
|
|
|
return item.event();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateRoomMembers = async() => {
|
2018-04-24 19:34:03 +00:00
|
|
|
const { t } = this.state.room;
|
2018-05-24 20:17:45 +00:00
|
|
|
|
|
|
|
if (!this.canViewMembers) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2018-04-24 19:34:03 +00:00
|
|
|
if (t === 'c' || t === 'p') {
|
|
|
|
let onlineMembers = [];
|
|
|
|
let allMembers = [];
|
|
|
|
try {
|
|
|
|
const onlineMembersCall = RocketChat.getRoomMembers(this.state.room.rid, false);
|
|
|
|
const allMembersCall = RocketChat.getRoomMembers(this.state.room.rid, true);
|
|
|
|
const [onlineMembersResult, allMembersResult] = await Promise.all([onlineMembersCall, allMembersCall]);
|
|
|
|
onlineMembers = onlineMembersResult.records;
|
|
|
|
allMembers = allMembersResult.records;
|
|
|
|
return { onlineMembers, allMembers };
|
|
|
|
} catch (error) {
|
|
|
|
return {};
|
|
|
|
}
|
2018-03-23 16:49:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-29 17:55:37 +00:00
|
|
|
updateRoomMember = async() => {
|
2018-05-18 17:55:08 +00:00
|
|
|
if (this.state.room.t !== 'd') {
|
2018-04-24 19:34:03 +00:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
const member = await RocketChat.getRoomMember(this.state.room.rid, this.props.user_id);
|
|
|
|
return { member };
|
2018-05-18 17:55:08 +00:00
|
|
|
} catch (e) {
|
|
|
|
log('RoomActions updateRoomMember', e);
|
2018-04-24 19:34:03 +00:00
|
|
|
return {};
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-24 19:34:03 +00:00
|
|
|
updateRoom = () => {
|
|
|
|
this.setState({ room: this.room });
|
|
|
|
}
|
|
|
|
get canAddUser() { // Invite user
|
|
|
|
const {
|
|
|
|
rid, t
|
|
|
|
} = this.room;
|
|
|
|
const { allMembers } = this.state;
|
|
|
|
// TODO: same test joined
|
|
|
|
const userInRoom = !!allMembers.find(m => m.username === this.props.user_username);
|
|
|
|
const permissions = RocketChat.hasPermission(['add-user-to-joined-room', 'add-user-to-any-c-room', 'add-user-to-any-p-room'], rid);
|
|
|
|
|
|
|
|
if (userInRoom && permissions['add-user-to-joined-room']) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (t === 'c' && permissions['add-user-to-any-c-room']) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (t === 'p' && permissions['add-user-to-any-p-room']) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2018-02-19 21:19:39 +00:00
|
|
|
}
|
2018-05-24 20:17:45 +00:00
|
|
|
get canViewMembers() {
|
|
|
|
const { rid, t, broadcast } = this.state.room;
|
|
|
|
if (broadcast) {
|
|
|
|
const viewBroadcastMemberListPermission = 'view-broadcast-member-list';
|
|
|
|
const permissions = RocketChat.hasPermission([viewBroadcastMemberListPermission], rid);
|
|
|
|
if (!permissions[viewBroadcastMemberListPermission]) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (t === 'c' || t === 'p');
|
|
|
|
}
|
2018-04-24 19:34:03 +00:00
|
|
|
get sections() {
|
|
|
|
const {
|
2018-05-24 20:17:45 +00:00
|
|
|
rid, t, blocker, notifications
|
2018-04-24 19:34:03 +00:00
|
|
|
} = this.room;
|
|
|
|
const { onlineMembers } = this.state;
|
2018-02-19 21:19:39 +00:00
|
|
|
|
|
|
|
const sections = [{
|
2018-03-29 17:55:37 +00:00
|
|
|
data: [{
|
|
|
|
icon: 'ios-star',
|
|
|
|
name: 'USER',
|
|
|
|
route: 'RoomInfo',
|
2018-05-23 13:39:18 +00:00
|
|
|
params: { rid },
|
|
|
|
testID: 'room-actions-info'
|
2018-03-29 17:55:37 +00:00
|
|
|
}],
|
2018-02-19 21:19:39 +00:00
|
|
|
renderItem: this.renderRoomInfo
|
|
|
|
}, {
|
|
|
|
data: [
|
2018-05-23 13:39:18 +00:00
|
|
|
{
|
|
|
|
icon: 'ios-call-outline',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Voice_call'),
|
2018-05-23 13:39:18 +00:00
|
|
|
disabled: true,
|
|
|
|
testID: 'room-actions-voice'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: 'ios-videocam-outline',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Video_call'),
|
2018-05-23 13:39:18 +00:00
|
|
|
disabled: true,
|
|
|
|
testID: 'room-actions-video'
|
|
|
|
}
|
2018-02-19 21:19:39 +00:00
|
|
|
],
|
|
|
|
renderItem: this.renderItem
|
|
|
|
}, {
|
|
|
|
data: [
|
2018-03-23 16:49:51 +00:00
|
|
|
{
|
|
|
|
icon: 'ios-attach',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Files'),
|
2018-03-23 16:49:51 +00:00
|
|
|
route: 'RoomFiles',
|
2018-05-23 13:39:18 +00:00
|
|
|
params: { rid },
|
|
|
|
testID: 'room-actions-files'
|
2018-03-23 16:49:51 +00:00
|
|
|
},
|
2018-03-02 15:11:34 +00:00
|
|
|
{
|
|
|
|
icon: 'ios-at-outline',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Mentions'),
|
2018-03-02 15:11:34 +00:00
|
|
|
route: 'MentionedMessages',
|
2018-05-23 13:39:18 +00:00
|
|
|
params: { rid },
|
|
|
|
testID: 'room-actions-mentioned'
|
2018-03-02 15:11:34 +00:00
|
|
|
},
|
2018-02-19 21:19:39 +00:00
|
|
|
{
|
|
|
|
icon: 'ios-star-outline',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Starred'),
|
2018-02-19 21:19:39 +00:00
|
|
|
route: 'StarredMessages',
|
2018-05-23 13:39:18 +00:00
|
|
|
params: { rid },
|
|
|
|
testID: 'room-actions-starred'
|
2018-02-19 21:19:39 +00:00
|
|
|
},
|
2018-04-24 19:34:03 +00:00
|
|
|
{
|
|
|
|
icon: 'ios-search',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Search'),
|
2018-04-24 19:34:03 +00:00
|
|
|
route: 'SearchMessages',
|
2018-05-23 13:39:18 +00:00
|
|
|
params: { rid },
|
|
|
|
testID: 'room-actions-search'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: 'ios-share-outline',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Share'),
|
2018-05-23 13:39:18 +00:00
|
|
|
disabled: true,
|
|
|
|
testID: 'room-actions-share'
|
2018-04-24 19:34:03 +00:00
|
|
|
},
|
2018-02-19 21:19:39 +00:00
|
|
|
{
|
|
|
|
icon: 'ios-pin',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Pinned'),
|
2018-02-19 21:19:39 +00:00
|
|
|
route: 'PinnedMessages',
|
2018-05-23 13:39:18 +00:00
|
|
|
params: { rid },
|
|
|
|
testID: 'room-actions-pinned'
|
2018-02-19 21:19:39 +00:00
|
|
|
},
|
2018-03-23 16:49:51 +00:00
|
|
|
{
|
|
|
|
icon: 'ios-code',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Snippets'),
|
2018-03-23 16:49:51 +00:00
|
|
|
route: 'SnippetedMessages',
|
2018-05-23 13:39:18 +00:00
|
|
|
params: { rid },
|
|
|
|
testID: 'room-actions-snippeted'
|
2018-03-23 16:49:51 +00:00
|
|
|
},
|
2018-04-24 19:34:03 +00:00
|
|
|
{
|
|
|
|
icon: `ios-notifications${ notifications ? '' : '-off' }-outline`,
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t(`${ notifications ? 'Enable' : 'Disable' }_notifications`),
|
2018-05-23 13:39:18 +00:00
|
|
|
event: () => this.toggleNotifications(),
|
|
|
|
testID: 'room-actions-notifications'
|
2018-04-24 19:34:03 +00:00
|
|
|
}
|
2018-02-19 21:19:39 +00:00
|
|
|
],
|
|
|
|
renderItem: this.renderItem
|
|
|
|
}];
|
2018-04-24 19:34:03 +00:00
|
|
|
|
2018-02-19 21:19:39 +00:00
|
|
|
if (t === 'd') {
|
|
|
|
sections.push({
|
|
|
|
data: [
|
2018-03-23 16:49:51 +00:00
|
|
|
{
|
|
|
|
icon: 'block',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t(`${ blocker ? 'Unblock' : 'Block' }_user`),
|
2018-03-23 16:49:51 +00:00
|
|
|
type: 'danger',
|
2018-05-23 13:39:18 +00:00
|
|
|
event: () => this.toggleBlockUser(),
|
|
|
|
testID: 'room-actions-block-user'
|
2018-03-23 16:49:51 +00:00
|
|
|
}
|
2018-02-19 21:19:39 +00:00
|
|
|
],
|
|
|
|
renderItem: this.renderItem
|
|
|
|
});
|
|
|
|
} else if (t === 'c' || t === 'p') {
|
2018-05-24 20:17:45 +00:00
|
|
|
const actions = [];
|
|
|
|
|
|
|
|
if (this.canViewMembers) {
|
|
|
|
actions.push({
|
|
|
|
icon: 'ios-people',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Members'),
|
|
|
|
description: (onlineMembers.length === 1 ?
|
|
|
|
I18n.t('1_online_member') :
|
|
|
|
I18n.t('N_online_members', { n: onlineMembers.length })),
|
2018-05-24 20:17:45 +00:00
|
|
|
route: 'RoomMembers',
|
|
|
|
params: { rid, members: onlineMembers },
|
|
|
|
testID: 'room-actions-members'
|
|
|
|
});
|
|
|
|
}
|
2018-04-24 19:34:03 +00:00
|
|
|
|
|
|
|
if (this.canAddUser) {
|
|
|
|
actions.push({
|
|
|
|
icon: 'ios-person-add',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Add_user'),
|
2018-04-24 19:34:03 +00:00
|
|
|
route: 'SelectedUsers',
|
|
|
|
params: {
|
|
|
|
nextAction: async() => {
|
|
|
|
try {
|
|
|
|
this.props.setLoadingInvite(true);
|
|
|
|
await RocketChat.addUsersToRoom(rid);
|
|
|
|
this.props.navigation.goBack();
|
2018-05-18 17:55:08 +00:00
|
|
|
} catch (e) {
|
|
|
|
log('RoomActions Add User', e);
|
2018-04-24 19:34:03 +00:00
|
|
|
} finally {
|
|
|
|
this.props.setLoadingInvite(false);
|
|
|
|
}
|
|
|
|
}
|
2018-05-23 13:39:18 +00:00
|
|
|
},
|
|
|
|
testID: 'room-actions-add-user'
|
2018-03-23 16:49:51 +00:00
|
|
|
});
|
|
|
|
}
|
2018-04-24 19:34:03 +00:00
|
|
|
sections[2].data = [...actions, ...sections[2].data];
|
2018-02-19 21:19:39 +00:00
|
|
|
sections.push({
|
|
|
|
data: [
|
2018-03-23 16:49:51 +00:00
|
|
|
{
|
|
|
|
icon: 'block',
|
2018-06-01 17:38:13 +00:00
|
|
|
name: I18n.t('Leave_channel'),
|
2018-03-23 16:49:51 +00:00
|
|
|
type: 'danger',
|
2018-05-23 13:39:18 +00:00
|
|
|
event: () => this.leaveChannel(),
|
|
|
|
testID: 'room-actions-leave-channel'
|
2018-03-23 16:49:51 +00:00
|
|
|
}
|
2018-02-19 21:19:39 +00:00
|
|
|
],
|
|
|
|
renderItem: this.renderItem
|
|
|
|
});
|
|
|
|
}
|
2018-04-24 19:34:03 +00:00
|
|
|
return sections;
|
2018-02-19 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
2018-05-23 13:39:18 +00:00
|
|
|
toggleBlockUser = async() => {
|
2018-05-24 20:17:45 +00:00
|
|
|
const { rid, blocker } = this.state.room;
|
2018-03-29 17:55:37 +00:00
|
|
|
const { member } = this.state;
|
2018-05-18 17:55:08 +00:00
|
|
|
try {
|
2018-05-24 20:17:45 +00:00
|
|
|
RocketChat.toggleBlockUser(rid, member._id, !blocker);
|
2018-05-18 17:55:08 +00:00
|
|
|
} catch (e) {
|
|
|
|
log('toggleBlockUser', e);
|
|
|
|
}
|
2018-03-23 16:49:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
leaveChannel = () => {
|
|
|
|
const { room } = this.state;
|
|
|
|
Alert.alert(
|
2018-06-01 17:38:13 +00:00
|
|
|
I18n.t('Are_you_sure_question_mark'),
|
|
|
|
I18n.t('Are_you_sure_you_want_to_leave_the_room', { room: room.t === 'd' ? room.fname : room.name }),
|
2018-03-23 16:49:51 +00:00
|
|
|
[
|
|
|
|
{
|
2018-06-01 17:38:13 +00:00
|
|
|
text: I18n.t('Cancel'),
|
2018-03-23 16:49:51 +00:00
|
|
|
style: 'cancel'
|
|
|
|
},
|
|
|
|
{
|
2018-06-01 17:38:13 +00:00
|
|
|
text: I18n.t('Yes_action_it', { action: I18n.t('leave') }),
|
2018-03-23 16:49:51 +00:00
|
|
|
style: 'destructive',
|
2018-03-29 17:55:37 +00:00
|
|
|
onPress: () => this.props.leaveRoom(room.rid)
|
2018-03-23 16:49:51 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-04-24 19:34:03 +00:00
|
|
|
toggleNotifications = () => {
|
|
|
|
const { room } = this.state;
|
2018-05-18 17:55:08 +00:00
|
|
|
try {
|
|
|
|
RocketChat.saveNotificationSettings(room.rid, 'mobilePushNotifications', room.notifications ? 'default' : 'nothing');
|
|
|
|
} catch (e) {
|
|
|
|
log('toggleNotifications', e);
|
|
|
|
}
|
2018-04-24 19:34:03 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 15:11:34 +00:00
|
|
|
renderRoomInfo = ({ item }) => {
|
2018-03-29 17:55:37 +00:00
|
|
|
const { room, member } = this.state;
|
2018-03-23 16:49:51 +00:00
|
|
|
const { name, t, topic } = room;
|
2018-03-02 15:11:34 +00:00
|
|
|
return (
|
|
|
|
this.renderTouchableItem([
|
|
|
|
<Avatar
|
|
|
|
key='avatar'
|
|
|
|
text={name}
|
|
|
|
size={50}
|
|
|
|
style={styles.avatar}
|
|
|
|
type={t}
|
2018-03-29 17:55:37 +00:00
|
|
|
>
|
|
|
|
{t === 'd' ? <Status style={sharedStyles.status} id={member._id} /> : null }
|
|
|
|
</Avatar>,
|
2018-03-02 15:11:34 +00:00
|
|
|
<View key='name' style={styles.roomTitleContainer}>
|
2018-04-24 19:34:03 +00:00
|
|
|
<Text style={styles.roomTitle}>{ getRoomTitle(room) }</Text>
|
2018-03-02 15:11:34 +00:00
|
|
|
<Text style={styles.roomDescription} ellipsizeMode='tail' numberOfLines={1}>{t === 'd' ? `@${ name }` : topic}</Text>
|
|
|
|
</View>,
|
2018-03-29 17:55:37 +00:00
|
|
|
<Icon key='icon' name='ios-arrow-forward' size={20} style={styles.sectionItemIcon} color='#ccc' />
|
2018-03-02 15:11:34 +00:00
|
|
|
], item)
|
|
|
|
);
|
|
|
|
}
|
2018-02-19 21:19:39 +00:00
|
|
|
|
|
|
|
renderTouchableItem = (subview, item) => (
|
|
|
|
<Touch
|
2018-03-23 16:49:51 +00:00
|
|
|
onPress={() => this.onPressTouchable(item)}
|
2018-02-19 21:19:39 +00:00
|
|
|
underlayColor='#FFFFFF'
|
|
|
|
activeOpacity={0.5}
|
|
|
|
accessibilityLabel={item.name}
|
|
|
|
accessibilityTraits='button'
|
2018-05-23 13:39:18 +00:00
|
|
|
testID={item.testID}
|
2018-02-19 21:19:39 +00:00
|
|
|
>
|
2018-03-29 17:55:37 +00:00
|
|
|
<View style={[styles.sectionItem, item.disabled && styles.sectionItemDisabled]}>
|
2018-02-19 21:19:39 +00:00
|
|
|
{subview}
|
|
|
|
</View>
|
|
|
|
</Touch>
|
|
|
|
)
|
|
|
|
|
|
|
|
renderItem = ({ item }) => {
|
2018-04-24 19:34:03 +00:00
|
|
|
const subview = item.type === 'danger' ? [
|
|
|
|
<MaterialIcon key='icon' name={item.icon} size={20} style={[styles.sectionItemIcon, styles.textColorDanger]} />,
|
|
|
|
<Text key='name' style={[styles.sectionItemName, styles.textColorDanger]}>{ item.name }</Text>
|
|
|
|
] : [
|
2018-02-19 21:19:39 +00:00
|
|
|
<Icon key='left-icon' name={item.icon} size={24} style={styles.sectionItemIcon} />,
|
|
|
|
<Text key='name' style={styles.sectionItemName}>{ item.name }</Text>,
|
|
|
|
item.description && <Text key='description' style={styles.sectionItemDescription}>{ item.description }</Text>,
|
2018-03-29 17:55:37 +00:00
|
|
|
<Icon key='right-icon' name='ios-arrow-forward' size={20} style={styles.sectionItemIcon} color='#ccc' />
|
2018-02-19 21:19:39 +00:00
|
|
|
];
|
|
|
|
return this.renderTouchableItem(subview, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderSectionSeparator = (data) => {
|
2018-04-24 19:34:03 +00:00
|
|
|
if (data.trailingItem) {
|
|
|
|
return <View style={[styles.sectionSeparator, data.leadingSection && styles.sectionSeparatorBorder]} />;
|
2018-02-19 21:19:39 +00:00
|
|
|
}
|
2018-04-24 19:34:03 +00:00
|
|
|
if (!data.trailingSection) {
|
|
|
|
return <View style={styles.sectionSeparatorBorder} />;
|
|
|
|
}
|
|
|
|
return null;
|
2018-02-19 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2018-05-23 13:39:18 +00:00
|
|
|
<View testID='room-actions-view'>
|
|
|
|
<SectionList
|
|
|
|
style={styles.container}
|
|
|
|
stickySectionHeadersEnabled={false}
|
|
|
|
sections={this.sections}
|
|
|
|
SectionSeparatorComponent={this.renderSectionSeparator}
|
|
|
|
ItemSeparatorComponent={renderSeparator}
|
|
|
|
keyExtractor={item => item.name}
|
|
|
|
testID='room-actions-list'
|
|
|
|
/>
|
|
|
|
</View>
|
2018-02-19 21:19:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|