Chore: evaluate `LegalView` (#4097)
* chore: evaluate LegalView * remove: `options` from `LegalView` on OutsideStack * remove: `mapStateToProps` in favor of `useSelector`
This commit is contained in:
parent
9320d1e05e
commit
c9fd7973f0
|
@ -28,7 +28,7 @@ const _OutsideStack = () => {
|
||||||
<Outside.Screen name='ForgotPasswordView' component={ForgotPasswordView} options={ForgotPasswordView.navigationOptions} />
|
<Outside.Screen name='ForgotPasswordView' component={ForgotPasswordView} options={ForgotPasswordView.navigationOptions} />
|
||||||
<Outside.Screen name='SendEmailConfirmationView' component={SendEmailConfirmationView} />
|
<Outside.Screen name='SendEmailConfirmationView' component={SendEmailConfirmationView} />
|
||||||
<Outside.Screen name='RegisterView' component={RegisterView} options={RegisterView.navigationOptions} />
|
<Outside.Screen name='RegisterView' component={RegisterView} options={RegisterView.navigationOptions} />
|
||||||
<Outside.Screen name='LegalView' component={LegalView} options={LegalView.navigationOptions} />
|
<Outside.Screen name='LegalView' component={LegalView} />
|
||||||
</Outside.Navigator>
|
</Outside.Navigator>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,62 +1,60 @@
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { StackNavigationOptions } from '@react-navigation/stack';
|
|
||||||
|
|
||||||
import I18n from '../i18n';
|
import I18n from '../i18n';
|
||||||
import StatusBar from '../containers/StatusBar';
|
import StatusBar from '../containers/StatusBar';
|
||||||
import openLink from '../utils/openLink';
|
import openLink from '../utils/openLink';
|
||||||
import { TSupportedThemes, withTheme } from '../theme';
|
import { useTheme } from '../theme';
|
||||||
import SafeAreaView from '../containers/SafeAreaView';
|
import SafeAreaView from '../containers/SafeAreaView';
|
||||||
import * as List from '../containers/List';
|
import * as List from '../containers/List';
|
||||||
|
import { OutsideParamList } from '../stacks/types';
|
||||||
|
import { IBaseScreen, IApplicationState } from '../definitions';
|
||||||
|
|
||||||
interface ILegalView {
|
interface ILegalViewProps extends IBaseScreen<OutsideParamList, 'LegalView'> {
|
||||||
server: string;
|
server: string;
|
||||||
theme: TSupportedThemes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LegalView extends React.Component<ILegalView, any> {
|
const LegalView = ({ navigation }: ILegalViewProps): React.ReactElement => {
|
||||||
static navigationOptions = (): StackNavigationOptions => ({
|
const server = useSelector((state: IApplicationState) => state.server.server);
|
||||||
title: I18n.t('Legal')
|
const { theme } = useTheme();
|
||||||
});
|
|
||||||
|
|
||||||
onPressItem = ({ route }: { route: string }) => {
|
useEffect(() => {
|
||||||
const { server, theme } = this.props;
|
navigation.setOptions({
|
||||||
|
title: I18n.t('Legal')
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onPressItem = ({ route }: { route: string }) => {
|
||||||
if (!server) {
|
if (!server) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
openLink(`${server}/${route}`, theme);
|
openLink(`${server}/${route}`, theme);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
return (
|
||||||
return (
|
<SafeAreaView testID='legal-view'>
|
||||||
<SafeAreaView testID='legal-view'>
|
<StatusBar />
|
||||||
<StatusBar />
|
<List.Container>
|
||||||
<List.Container>
|
<List.Section>
|
||||||
<List.Section>
|
<List.Separator />
|
||||||
<List.Separator />
|
<List.Item
|
||||||
<List.Item
|
title='Terms_of_Service'
|
||||||
title='Terms_of_Service'
|
onPress={() => onPressItem({ route: 'terms-of-service' })}
|
||||||
onPress={() => this.onPressItem({ route: 'terms-of-service' })}
|
testID='legal-terms-button'
|
||||||
testID='legal-terms-button'
|
showActionIndicator
|
||||||
showActionIndicator
|
/>
|
||||||
/>
|
<List.Separator />
|
||||||
<List.Separator />
|
<List.Item
|
||||||
<List.Item
|
title='Privacy_Policy'
|
||||||
title='Privacy_Policy'
|
onPress={() => onPressItem({ route: 'privacy-policy' })}
|
||||||
onPress={() => this.onPressItem({ route: 'privacy-policy' })}
|
testID='legal-privacy-button'
|
||||||
testID='legal-privacy-button'
|
showActionIndicator
|
||||||
showActionIndicator
|
/>
|
||||||
/>
|
<List.Separator />
|
||||||
<List.Separator />
|
</List.Section>
|
||||||
</List.Section>
|
</List.Container>
|
||||||
</List.Container>
|
</SafeAreaView>
|
||||||
</SafeAreaView>
|
);
|
||||||
);
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapStateToProps = (state: any) => ({
|
export default LegalView;
|
||||||
server: state.server.server
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withTheme(LegalView));
|
|
||||||
|
|
Loading…
Reference in New Issue