mattermost-mobile/app/screens/settings/setting_option.tsx
Avinash Lingaloo c1a39094c6
MM-39711 Gekidou Settings - Display Main Screen (#6287)
* added chevron to menu item component

* starting with the skeleton

* starting with the skeleton

* starting with the skeleton

* starting with the skeleton

* remove extra line

* tested on tablets

* some corrections

* corrections as per review

* starting with notification skeleton

* attached notification settings to navigation

* added auto responder

* update translation

* update snapshot

* updated snapshot

* correction after review

* removed unnecessary screen

* refactored

* updated the testIDs

* Update Package.resolved

* refactor

* removed Mattermost as default server name

* fix ts

* refactored settings constant

* display settings skeleton

- pending: query for allowed themes

* added 'allowedThemes' query

* correction after review

* correction after review

* removed extra notification_settings line

* Update en.json

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-05-19 17:14:29 +04:00

46 lines
1.5 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Platform} from 'react-native';
import MenuItem, {MenuItemProps} from '@components/menu_item';
import {useTheme} from '@context/theme';
import {makeStyleSheetFromTheme} from '@utils/theme';
import {typography} from '@utils/typography';
import Options, {DisplayOptionConfig, NotificationsOptionConfig, SettingOptionConfig} from './constant';
type SettingsConfig = keyof typeof SettingOptionConfig | keyof typeof NotificationsOptionConfig| keyof typeof DisplayOptionConfig
type SettingOptionProps = {
optionName: SettingsConfig;
onPress: () => void;
} & Omit<MenuItemProps, 'testID'| 'theme'>;
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
return {
menuLabel: {
color: theme.centerChannelColor,
...typography('Body', 200),
},
};
});
const SettingOption = ({onPress, optionName, ...rest}: SettingOptionProps) => {
const theme = useTheme();
const styles = getStyleSheet(theme);
const props = {...rest, ...Options[optionName]} as unknown as Omit<MenuItemProps, 'onPress'| 'theme'>;
return (
<MenuItem
labelStyle={styles.menuLabel}
onPress={onPress}
separator={true}
showArrow={Platform.select({ios: true, default: false})}
theme={theme}
{...props}
/>
);
};
export default SettingOption;