feat(settings/native): changed FormSectionAccordion.js to FormSection.tsx

This commit is contained in:
Calin-Teodor 2023-01-23 17:58:11 +02:00 committed by Saúl Ibarra Corretgé
parent 9775ad25ca
commit 0251201e93
4 changed files with 67 additions and 104 deletions

View File

@ -0,0 +1,46 @@
import React, { ReactChildren } from 'react';
import { WithTranslation } from 'react-i18next';
import { Text, View } from 'react-native';
import { translate } from '../../../base/i18n/functions';
// @ts-ignore
import styles from './styles';
/**
* The type of the React {@code Component} props of {@link FormSection}.
*/
interface IProps extends WithTranslation {
/**
* The children to be displayed within this Link.
*/
children: ReactChildren;
/**
* The i18n key of the text label of the section.
*/
label: string;
}
/**
* Section accordion on settings form.
*
* @returns {React$Element<any>}
*/
function FormSection({ children, label, t }: IProps) {
return (
<View>
<View
style = { styles.formSectionTitleContent }>
<Text style = { styles.formSectionTitleText }>
{ t(label) }
</Text>
</View>
{ children }
</View>
);
}
export default translate(FormSection);

View File

@ -1,84 +0,0 @@
// @flow
import React, { useCallback, useState } from 'react';
import { List } from 'react-native-paper';
import { translate } from '../../../base/i18n';
import { Icon, IconArrowDown, IconArrowUp } from '../../../base/icons';
import styles from './styles';
/**
* The type of the React {@code Component} props of {@link FormSectionAccordion}.
*/
type Props = {
/**
* Is the section an accordion or not.
*/
accordion: boolean,
/**
* The children to be displayed within this Link.
*/
children: React$Node,
/**
* Whether the accordion is expandable.
*/
expandable: boolean,
/**
* The i18n key of the text label of the section.
*/
label: string,
/**
* An external style object passed to the component.
*/
style: Object,
/**
* Invoked to obtain translated strings.
*/
t: Function
}
/**
* Section accordion on settings form.
*
* @returns {React$Element<any>}
*/
function FormSectionAccordion({ accordion, children, expandable, label, style, t }: Props) {
const [ expandSection, setExpandSection ] = useState(false);
const onPress = useCallback(() => {
setExpandSection(!expandSection);
});
return (
<List.Accordion
expanded = { expandSection || !expandable }
onPress = { onPress }
/* eslint-disable-next-line react/jsx-no-bind */
right = { props =>
accordion && <Icon
{ ...props }
src = { expandSection ? IconArrowUp : IconArrowDown }
style = { styles.section } /> }
style = { [
styles.formSectionTitle,
style
] }
theme = {{
colors: {
background: 'transparent'
}
}}
title = { t(label) }
titleStyle = { styles.formSectionTitleText }>
{ children }
</List.Accordion>
);
}
export default translate(FormSectionAccordion);

View File

@ -37,7 +37,7 @@ import { isServerURLChangeEnabled, normalizeUserInputURL } from '../../functions
// @ts-ignore // @ts-ignore
import FormRow from './FormRow'; import FormRow from './FormRow';
// @ts-ignore // @ts-ignore
import FormSectionAccordion from './FormSectionAccordion'; import FormSection from './FormSection';
// @ts-ignore // @ts-ignore
import styles from './styles'; import styles from './styles';
@ -305,7 +305,8 @@ class SettingsView extends Component<IProps, IState> {
participantId = { this.props._localParticipantId } participantId = { this.props._localParticipantId }
size = { AVATAR_SIZE } /> size = { AVATAR_SIZE } />
</View> </View>
<FormSectionAccordion {/* @ts-ignore */}
<FormSection
label = 'settingsView.profileSection'> label = 'settingsView.profileSection'>
<Input <Input
// @ts-ignore // @ts-ignore
@ -327,8 +328,9 @@ class SettingsView extends Component<IProps, IState> {
placeholder = { t('settingsView.emailPlaceholderText') } placeholder = { t('settingsView.emailPlaceholderText') }
textContentType = { 'emailAddress' } // iOS only textContentType = { 'emailAddress' } // iOS only
value = { email } /> value = { email } />
</FormSectionAccordion> </FormSection>
<FormSectionAccordion {/* @ts-ignore */}
<FormSection
label = 'settingsView.conferenceSection'> label = 'settingsView.conferenceSection'>
<Input <Input
// @ts-ignore // @ts-ignore
@ -375,8 +377,9 @@ class SettingsView extends Component<IProps, IState> {
// @ts-ignore // @ts-ignore
onChange = { this._onDisableSelfView } /> onChange = { this._onDisableSelfView } />
</FormRow> </FormRow>
</FormSectionAccordion> </FormSection>
<FormSectionAccordion {/* @ts-ignore */}
<FormSection
label = 'settingsView.links'> label = 'settingsView.links'>
<Button <Button
accessibilityLabel = 'settingsView.help' accessibilityLabel = 'settingsView.help'
@ -397,17 +400,20 @@ class SettingsView extends Component<IProps, IState> {
labelKey = 'settingsView.privacy' labelKey = 'settingsView.privacy'
onClick = { this._onShowPrivacyPressed } onClick = { this._onShowPrivacyPressed }
type = { BUTTON_TYPES.TERTIARY } /> type = { BUTTON_TYPES.TERTIARY } />
</FormSectionAccordion> </FormSection>
<FormSectionAccordion {/* @ts-ignore */}
<FormSection
label = 'settingsView.buildInfoSection'> label = 'settingsView.buildInfoSection'>
{/* @ts-ignore */}
<FormRow <FormRow
label = 'settingsView.version'> label = 'settingsView.version'>
<Text style = { styles.text }> <Text style = { styles.text }>
{`${AppInfo.version} build ${AppInfo.buildNumber}`} {`${AppInfo.version} build ${AppInfo.buildNumber}`}
</Text> </Text>
</FormRow> </FormRow>
</FormSectionAccordion> </FormSection>
<FormSectionAccordion {/* @ts-ignore */}
<FormSection
label = 'settingsView.advanced'> label = 'settingsView.advanced'>
{ Platform.OS === 'android' && ( { Platform.OS === 'android' && (
<> <>
@ -441,7 +447,7 @@ class SettingsView extends Component<IProps, IState> {
onChange = { this._onDisableCrashReporting } /> onChange = { this._onDisableCrashReporting } />
</FormRow> </FormRow>
)} )}
</FormSectionAccordion> </FormSection>
</ScrollView> </ScrollView>
</JitsiScreen> </JitsiScreen>
); );

View File

@ -91,24 +91,19 @@ export default {
/** /**
* Style for the form section separator titles. * Style for the form section separator titles.
*/ */
formSectionTitle: {
formSectionTitleContent: {
backgroundColor: BaseTheme.palette.ui02, backgroundColor: BaseTheme.palette.ui02,
paddingBottom: 0, paddingVertical: BaseTheme.spacing[1]
paddingTop: 0
}, },
formSectionTitleText: { formSectionTitleText: {
...BaseTheme.typography.bodyShortRegular,
color: BaseTheme.palette.text01, color: BaseTheme.palette.text01,
fontSize: 14,
opacity: 0.6, opacity: 0.6,
textAlign: 'center' textAlign: 'center'
}, },
section: {
color: BaseTheme.palette.icon01,
fontSize: 14
},
/** /**
* Global {@code Text} color for the components. * Global {@code Text} color for the components.
*/ */