Files
mattermost-mobile/app/screens/settings/about/about.tsx
Avinash Lingaloo adde833ea9 MM-45221 - Gekidou Settings fixes - part 2 (#6491)
* modifying setting option

* navigates to email screen

* UI construction [in progress]

* hooking up withObservables

* email settings - need to save now

* adding a bit of paddings

* setting initial value

* Update notification_email.tsx

* UI Polish - main setting screen

* UI Polish - Mention

* UI Polish - Notification main screen

* code clean up

* code clean up

* UI Polish Notification

* UI Polish

* code clean up

* UI Polish - OOO

* fix observable for email interval

* fix ooo

* fix ooo

* added setting_row_label component

* further clean up

* UI Polish - Display - [ IN PROGRESS ]

* UI Polish - Display - [ IN PROGRESS ]

* UI Polish - Timezone Select [ IN PROGRESS ]

* Update index.test.tsx.snap

* Update app/screens/settings/notification_email/notification_email.tsx

Co-authored-by: Daniel Espino García <larkox@gmail.com>

* refactor after review

* update option_item so that action can accept type React.Dispatch<React.SetStateAction

* UI - Polish - Display Theme

UI Polish - Display/Theme [ IN PROGRESS ]

UI - Polish - Display Save button

* UI - Polish - Display Clock

UI - Polish - Display Clock

* UI Polish - Display - Timezone

UI Polish - Display Timezone

added the save button

UI Polish - Display/TZ

UI Polish - Display Timezone

minor refactoring

code clean up

code clean up

* UI Polish - Adv Settings

* UI Polish - Settings/About

UI Polish - Settings/About

* UI Polish - Radio Button

UI Polish - Radio Button

* UI Polish - Android Polishing [ IN PROGRESS ]

* UI Polish - Timezone

fix timezone

fix timezone select

fix timezone select ui

Update index.tsx

* UI Polish - Display/Theme

UI Polish - Custom Theme - Checked Radio btn

* Update en.json

* tweaks to settings styles

* further tweaks to spacing

* Revert "Merge branch 'gekidou-settings-finale' of https://github.com/mattermost/mattermost-mobile into gekidou-settings-finale"

This reverts commit f1fd26987e, reversing
changes made to 684ba6a19c.

* added space before 'default'

* Update index.test.tsx.snap

* Revert "Revert "Merge branch 'gekidou-settings-finale' of https://github.com/mattermost/mattermost-mobile into gekidou-settings-finale""

This reverts commit ce77127cb2.

Co-authored-by: Daniel Espino García <larkox@gmail.com>
Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
2022-07-27 22:35:57 +04:00

326 lines
12 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useCallback, useMemo} from 'react';
import {useIntl} from 'react-intl';
import {Alert, Text, View} from 'react-native';
import DeviceInfo from 'react-native-device-info';
import Config from '@assets/config.json';
import CompassIcon from '@components/compass_icon';
import FormattedText from '@components/formatted_text';
import AboutLinks from '@constants/about_links';
import {useTheme} from '@context/theme';
import {t} from '@i18n';
import SettingContainer from '@screens/settings/setting_container';
import SettingSeparator from '@screens/settings/settings_separator';
import {preventDoubleTap} from '@utils/tap';
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
import {typography} from '@utils/typography';
import {tryOpenURL} from '@utils/url';
import LearnMore from './learn_more';
import Subtitle from './subtitle';
import Title from './title';
import TosPrivacyContainer from './tos_privacy';
const MATTERMOST_BUNDLE_IDS = ['com.mattermost.rnbeta', 'com.mattermost.rn'];
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
logoContainer: {
alignItems: 'center',
paddingHorizontal: 20,
marginTop: 20,
},
lineStyles: {
width: '100%',
marginTop: 40,
marginBottom: 24,
},
leftHeading: {
...typography('Body', 200, 'SemiBold'),
marginRight: 8,
color: theme.centerChannelColor,
},
rightHeading: {
...typography('Body', 200, 'Regular'),
color: theme.centerChannelColor,
},
infoContainer: {
flexDirection: 'column',
paddingHorizontal: 20,
},
info: {
color: theme.centerChannelColor,
...typography('Body', 200, 'Regular'),
},
licenseContainer: {
flexDirection: 'row',
marginTop: 20,
},
noticeContainer: {
flexDirection: 'column',
},
noticeLink: {
color: theme.linkColor,
...typography('Body', 50, 'Regular'),
},
hashContainer: {
flexDirection: 'column',
},
footerTitleText: {
color: changeOpacity(theme.centerChannelColor, 0.64),
...typography('Body', 50, 'SemiBold'),
},
footerText: {
color: changeOpacity(theme.centerChannelColor, 0.64),
...typography('Body', 50),
marginBottom: 10,
},
copyrightText: {
marginBottom: 0,
},
tosPrivacyContainer: {
flexDirection: 'row',
marginBottom: 10,
},
group: {
flexDirection: 'row',
},
};
});
type AboutProps = {
config: ClientConfig;
license: ClientLicense;
}
const About = ({config, license}: AboutProps) => {
const intl = useIntl();
const theme = useTheme();
const styles = getStyleSheet(theme);
const openURL = useCallback((url: string) => {
const onError = () => {
Alert.alert(
intl.formatMessage({
id: 'settings.link.error.title',
defaultMessage: 'Error',
}),
intl.formatMessage({
id: 'settings.link.error.text',
defaultMessage: 'Unable to open the link.',
}),
);
};
tryOpenURL(url, onError);
}, []);
const handleAboutTeam = useCallback(preventDoubleTap(() => {
return openURL(Config.AboutTeamURL);
}), []);
const handleAboutEnterprise = useCallback(preventDoubleTap(() => {
return openURL(Config.AboutEnterpriseURL);
}), []);
const handlePlatformNotice = useCallback(preventDoubleTap(() => {
return openURL(Config.PlatformNoticeURL);
}), []);
const handleMobileNotice = useCallback(preventDoubleTap(() => {
return openURL(Config.MobileNoticeURL);
}), []);
const handleTermsOfService = useCallback(preventDoubleTap(() => {
return openURL(AboutLinks.TERMS_OF_SERVICE);
}), []);
const handlePrivacyPolicy = useCallback(preventDoubleTap(() => {
return openURL(AboutLinks.PRIVACY_POLICY);
}), []);
const serverVersion = useMemo(() => {
const buildNumber = config.BuildNumber;
const version = config.Version;
let id = t('settings.about.serverVersion');
let defaultMessage = '{version} (Build {number})';
let values: {version: string; number?: string} = {
version,
number: buildNumber,
};
if (buildNumber === version) {
id = t('settings.about.serverVersionNoBuild');
defaultMessage = '{version}';
values = {
version,
number: undefined,
};
}
return {
id, defaultMessage, values,
};
}, [config]);
return (
<SettingContainer>
<View style={styles.logoContainer}>
<CompassIcon
color={theme.centerChannelColor}
name='mattermost'
size={88}
testID='about.logo'
/>
<Title
config={config}
license={license}
/>
<Subtitle config={config}/>
<SettingSeparator lineStyles={styles.lineStyles}/>
</View>
<View style={styles.infoContainer}>
<View style={styles.group}>
<Text style={styles.leftHeading}>
{intl.formatMessage({id: 'settings.about.version', defaultMessage: 'App Version:'})}
</Text>
<Text style={styles.rightHeading}>
{intl.formatMessage({id: 'settings.about.build', defaultMessage: '{version} (Build {number})'},
{version: DeviceInfo.getVersion(), number: DeviceInfo.getBuildNumber()})}
</Text>
</View>
<View style={styles.group}>
<Text style={styles.leftHeading}>
{intl.formatMessage({id: 'settings.about.serverVersion', defaultMessage: 'Server Version:'})}
</Text>
<Text style={styles.rightHeading}>
{intl.formatMessage({id: serverVersion.id, defaultMessage: serverVersion.defaultMessage}, serverVersion.values)}
</Text>
</View>
<View style={styles.group}>
<Text style={styles.leftHeading}>
{intl.formatMessage({id: 'settings.about.database', defaultMessage: 'Database:'})}
</Text>
<Text style={styles.rightHeading}>
{intl.formatMessage({id: 'settings.about.database.value', defaultMessage: `${config.SQLDriverName}`})}
</Text>
</View>
{license.IsLicensed === 'true' && (
<View style={styles.licenseContainer}>
<FormattedText
defaultMessage='Licensed to: {company}'
id={t('settings.about.licensed')}
style={styles.info}
testID='about.licensee'
values={{company: license.Company}}
/>
</View>
)}
<LearnMore
config={config}
onHandleAboutEnterprise={handleAboutEnterprise}
onHandleAboutTeam={handleAboutTeam}
/>
{!MATTERMOST_BUNDLE_IDS.includes(DeviceInfo.getBundleId()) &&
<FormattedText
defaultMessage='{site} is powered by Mattermost'
id={t('settings.about.powered_by')}
style={styles.footerText}
testID='about.powered_by'
values={{site: config.SiteName}}
/>
}
<FormattedText
defaultMessage='Copyright 2015-{currentYear} Mattermost, Inc. All rights reserved'
id={t('settings.about.copyright')}
style={[styles.footerText, styles.copyrightText]}
testID='about.copyright'
values={{currentYear: new Date().getFullYear()}}
/>
<View style={styles.tosPrivacyContainer}>
<TosPrivacyContainer
config={config}
onPressPrivacyPolicy={handlePrivacyPolicy}
onPressTOS={handleTermsOfService}
/>
</View>
<View style={styles.noticeContainer}>
<FormattedText
id={t('settings.notice_text')}
defaultMessage='Mattermost is made possible by the open source software used in our {platform} and {mobile}.'
style={styles.footerText}
values={{
platform: (
<FormattedText
defaultMessage='server'
id={t('settings.notice_platform_link')}
onPress={handlePlatformNotice}
style={styles.noticeLink}
/>
),
mobile: (
<FormattedText
defaultMessage='mobile apps'
id={t('settings.notice_mobile_link')}
onPress={handleMobileNotice}
style={[styles.noticeLink, {marginLeft: 5}]}
/>
),
}}
testID='about.notice_text'
/>
</View>
<View style={styles.hashContainer}>
<View style={styles.footerGroup}>
<FormattedText
defaultMessage='Build Hash:'
id={t('about.hash')}
style={styles.footerTitleText}
testID='about.build_hash.title'
/>
<Text
style={styles.footerText}
testID='about.build_hash.value'
>
{config.BuildHash}
</Text>
</View>
<View style={styles.footerGroup}>
<FormattedText
defaultMessage='EE Build Hash:'
id={t('about.hashee')}
style={styles.footerTitleText}
testID='about.build_hash_enterprise.title'
/>
<Text
style={styles.footerText}
testID='about.build_hash_enterprise.value'
>
{config.BuildHashEnterprise}
</Text>
</View>
</View>
<View style={[styles.footerGroup, {marginBottom: 20}]}>
<FormattedText
defaultMessage='Build Date:'
id={t('about.date')}
style={styles.footerTitleText}
testID='about.build_date.title'
/>
<Text
style={styles.footerText}
testID='about.build_date.value'
>
{config.BuildDate}
</Text>
</View>
</View>
</SettingContainer>
);
};
export default About;