// @flow

import * as React from 'react';
import { View, Text, StyleSheet } from 'react-native';

import { threadTypes, type ThreadType } from 'lib/types/thread-types';

import ThreadIcon from './thread-icon.react';

type Props = {|
  +threadType: ThreadType,
  +color: string,
|};
function ThreadVisibility(props: Props) {
  const { threadType, color } = props;
  const visLabelStyle = [styles.visibilityLabel, { color }];

  let label;
  if (threadType === threadTypes.CHAT_SECRET) {
    label = 'Secret';
  } else if (threadType === threadTypes.PRIVATE) {
    label = 'Private';
  } else {
    label = 'Open';
  }

  return (
    <View style={styles.container}>
      <ThreadIcon threadType={threadType} color={color} />
      <Text style={visLabelStyle}>{label}</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    alignItems: 'center',
    flexDirection: 'row',
  },
  visibilityLabel: {
    fontSize: 16,
    fontWeight: 'bold',
    paddingLeft: 4,
  },
});

export default ThreadVisibility;

// @flow

import * as React from 'react';
import { View, Text, StyleSheet } from 'react-native';

import { threadLabel } from 'lib/shared/thread-utils';
import type { ThreadType } from 'lib/types/thread-types';

import ThreadIcon from './thread-icon.react';

type Props = {|
  +threadType: ThreadType,
  +color: string,
|};
function ThreadVisibility(props: Props) {
  const { threadType, color } = props;
  const visLabelStyle = [styles.visibilityLabel, { color }];
  const label = threadLabel(threadType);

  return (
    <View style={styles.container}>
      <ThreadIcon threadType={threadType} color={color} />
      <Text style={visLabelStyle}>{label}</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    alignItems: 'center',
    flexDirection: 'row',
  },
  visibilityLabel: {
    fontSize: 16,
    fontWeight: 'bold',
    paddingLeft: 4,
  },
});

export default ThreadVisibility;

Use threadLabel function in ThreadVisibility
[native] Use threadLabel function in ThreadVisibility

Test Plan: Tested all of thread types and checked if label is displayed correctly

Reviewers: ashoat, palys-swm

Reviewed By: ashoat, palys-swm

Subscribers: zrebcu411, Adrian, atul, subnub

Differential Revision: https://phabricator.ashoat.com/D659
