import React from 'react'; import { Text, View } from 'react-native'; import { StackNavigationProp, StackNavigationOptions } from '@react-navigation/stack'; import { connect } from 'react-redux'; import I18n from '../../i18n'; import Button from '../../containers/Button'; import { themes } from '../../constants/colors'; import { withTheme } from '../../theme'; import FormContainer, { FormContainerInner } from '../../containers/FormContainer'; import { getShowLoginButton } from '../../selectors/login'; import ServerAvatar from './ServerAvatar'; import styles from './styles'; interface IWorkSpaceProp { // TODO: waiting for the RootStackParamList https://reactnavigation.org/docs/typescript/#type-checking-screens navigation: StackNavigationProp; theme: string; Site_Name: string; Site_Url: string; server: string; Assets_favicon_512: { url?: string; defaultUrl: string; }; registrationForm: string; registrationText: string; showLoginButton: boolean; Accounts_iframe_enabled: boolean; inviteLinkToken: string; } class WorkspaceView extends React.Component { static navigationOptions: StackNavigationOptions = { title: I18n.t('Your_workspace') }; get showRegistrationButton() { const { registrationForm, inviteLinkToken, Accounts_iframe_enabled } = this.props; return ( !Accounts_iframe_enabled && (registrationForm === 'Public' || (registrationForm === 'Secret URL' && inviteLinkToken?.length)) ); } login = () => { const { navigation, server, Site_Name, Accounts_iframe_enabled } = this.props; if (Accounts_iframe_enabled) { navigation.navigate('AuthenticationWebView', { url: server, authType: 'iframe' }); return; } navigation.navigate('LoginView', { title: Site_Name }); }; register = () => { const { navigation, Site_Name } = this.props; navigation.navigate('RegisterView', { title: Site_Name }); }; renderRegisterDisabled = () => { const { Accounts_iframe_enabled, registrationText, theme } = this.props; if (Accounts_iframe_enabled) { return null; } return {registrationText}; }; render() { const { theme, Site_Name, Site_Url, Assets_favicon_512, server, showLoginButton } = this.props; return ( {Site_Name} {Site_Url} {showLoginButton ? (