|
1 |
| -import React from 'react'; |
2 |
| -import { Text, View } from 'react-native'; |
3 |
| - |
4 |
| -export const EncryptedRoom = () => ( |
5 |
| - <View> |
6 |
| - <Text>This room is encrypted</Text> |
7 |
| - </View> |
8 |
| -); |
| 1 | +import React, { ReactElement } from 'react'; |
| 2 | +import { StyleSheet, Text, View } from 'react-native'; |
| 3 | +import { StackNavigationProp } from '@react-navigation/stack'; |
| 4 | + |
| 5 | +import { ChatsStackParamList } from '../../../stacks/types'; |
| 6 | +import { useTheme } from '../../../theme'; |
| 7 | +import { CustomIcon } from '../../../containers/CustomIcon'; |
| 8 | +import Button from '../../../containers/Button'; |
| 9 | +import sharedStyles from '../../Styles'; |
| 10 | +import { useAppSelector } from '../../../lib/hooks'; |
| 11 | +import I18n from '../../../i18n'; |
| 12 | + |
| 13 | +const GAP = 32; |
| 14 | + |
| 15 | +export const EncryptedRoom = ({ |
| 16 | + navigation |
| 17 | +}: { |
| 18 | + navigation: StackNavigationProp<ChatsStackParamList, 'RoomView'>; |
| 19 | +}): ReactElement => { |
| 20 | + const { colors } = useTheme(); |
| 21 | + const styles = useStyle(); |
| 22 | + const isMasterDetail = useAppSelector(state => state.app.isMasterDetail); |
| 23 | + |
| 24 | + const navigate = () => { |
| 25 | + if (isMasterDetail) { |
| 26 | + navigation.navigate('ModalStackNavigator', { screen: 'E2EEnterYourPasswordView' }); |
| 27 | + } else { |
| 28 | + navigation.navigate('E2EEnterYourPasswordStackNavigator', { screen: 'E2EEnterYourPasswordView' }); |
| 29 | + } |
| 30 | + }; |
| 31 | + |
| 32 | + return ( |
| 33 | + <View style={styles.root}> |
| 34 | + <View style={styles.container}> |
| 35 | + <View style={styles.textView}> |
| 36 | + <View style={styles.icon}> |
| 37 | + <CustomIcon name='encrypted' size={42} color={colors.fontSecondaryInfo} /> |
| 38 | + </View> |
| 39 | + <Text style={styles.title}>This room is encrypted</Text> |
| 40 | + <Text style={styles.description}>To view its contents you must enter your encryption password.</Text> |
| 41 | + </View> |
| 42 | + <Button title={I18n.t('Enter_Your_E2E_Password')} onPress={navigate} /> |
| 43 | + <Button |
| 44 | + title={I18n.t('Learn_more')} |
| 45 | + type='secondary' |
| 46 | + backgroundColor={colors.chatComponentBackground} |
| 47 | + onPress={() => alert('learn more')} // TODO: missing url |
| 48 | + /> |
| 49 | + </View> |
| 50 | + </View> |
| 51 | + ); |
| 52 | +}; |
| 53 | + |
| 54 | +const useStyle = () => { |
| 55 | + const { colors } = useTheme(); |
| 56 | + const styles = StyleSheet.create({ |
| 57 | + root: { |
| 58 | + flex: 1, |
| 59 | + backgroundColor: colors.surfaceRoom |
| 60 | + }, |
| 61 | + container: { |
| 62 | + flex: 1, |
| 63 | + marginHorizontal: 24, |
| 64 | + justifyContent: 'center' |
| 65 | + }, |
| 66 | + textView: { alignItems: 'center' }, |
| 67 | + icon: { |
| 68 | + width: 58, |
| 69 | + height: 58, |
| 70 | + borderRadius: 30, |
| 71 | + marginBottom: GAP, |
| 72 | + backgroundColor: colors.surfaceNeutral, |
| 73 | + alignItems: 'center', |
| 74 | + justifyContent: 'center' |
| 75 | + }, |
| 76 | + title: { |
| 77 | + ...sharedStyles.textBold, |
| 78 | + fontSize: 24, |
| 79 | + lineHeight: 32, |
| 80 | + textAlign: 'center', |
| 81 | + color: colors.fontTitlesLabels, |
| 82 | + marginBottom: GAP |
| 83 | + }, |
| 84 | + description: { |
| 85 | + ...sharedStyles.textRegular, |
| 86 | + fontSize: 16, |
| 87 | + lineHeight: 24, |
| 88 | + textAlign: 'center', |
| 89 | + color: colors.fontDefault, |
| 90 | + marginBottom: GAP |
| 91 | + } |
| 92 | + }); |
| 93 | + return styles; |
| 94 | +}; |
0 commit comments