import * as React from 'react'; import { FunctionComponent } from 'react'; import { Context } from '../context/context'; import { User } from "@mancala/core"; import { getColorByBrightness } from '../util/ColorUtil'; import Space from './Space'; import { Theme } from '../theme/Theme'; import { StyleSheet, Text, View, ViewStyle } from 'react-native'; import { useTranslation } from 'react-i18next'; export type LayoutMode = "right" | "left"; const UserStatus: FunctionComponent<{ context: Context, user: User, layoutMode: LayoutMode, visible?: boolean, style?: ViewStyle }> = ({ context, user, layoutMode, visible, style }) => { if (visible === false) return <>; const textColorOnBoard = getColorByBrightness( context.themeManager.theme.background, context.themeManager.theme.textColor, context.themeManager.theme.textLightColor ); const { t } = useTranslation(); const styles = getDynamicStyles(context.themeManager.theme); return ( { user.isAnonymous ? t("Anonymous") : user.name} ); } function getDynamicStyles(theme: Theme) { return StyleSheet.create({ online: { backgroundColor: theme.boardColor }, offline: { backgroundColor: 'transparent' }, circle: { width: 15, height: 15, minWidth: 15, minHeight: 15, borderRadius: 15, borderWidth: 2, borderColor: theme.boardColor, borderStyle: "solid", }, flexRtl: { display: 'flex', flexDirection: 'row-reverse', alignItems: 'center', }, flexLtr: { display: 'flex', flexDirection: 'row', alignItems: 'center', }, text: { fontWeight: 'bold', overflow: 'hidden', }, icon: { color : "grey", width: 32, height: 32, fontSize: 32, } }); } export default UserStatus;