mattermost-mobile/app/components/menu_item/index.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 f1fd26987ee5b1854366573b5822c9d0b919d83a, reversing
changes made to 684ba6a19c5962353ce61add2cc9cf10c8f9d3d4.

* 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 ce77127cb20a3668510a82122325f1642ec7bb60.

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

173 lines
5 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {ReactNode} from 'react';
import {Platform, StyleProp, TextStyle, View, ViewStyle} from 'react-native';
import CompassIcon from '@components/compass_icon';
import FormattedText from '@components/formatted_text';
import TouchableWithFeedback from '@components/touchable_with_feedback';
import {useTheme} from '@context/theme';
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
export const ITEM_HEIGHT = 50;
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
container: {
flexDirection: 'row',
minHeight: ITEM_HEIGHT,
},
iconContainer: {
width: 45,
height: ITEM_HEIGHT,
alignItems: 'center',
justifyContent: 'center',
marginLeft: 5,
},
icon: {
color: changeOpacity(theme.centerChannelColor, 0.64),
fontSize: 24,
},
labelContainer: {
flex: 1,
justifyContent: 'center',
paddingVertical: 14,
},
centerLabel: {
textAlign: 'center',
textAlignVertical: 'center',
},
label: {
color: changeOpacity(theme.centerChannelColor, 0.5),
fontSize: 17,
textAlignVertical: 'center',
includeFontPadding: false,
},
divider: {
backgroundColor: changeOpacity(theme.centerChannelColor, 0.12),
height: 1,
},
chevron: {
alignSelf: 'center',
color: changeOpacity(theme.centerChannelColor, 0.64),
fontSize: 24,
marginRight: 8,
},
linkContainer: {
marginHorizontal: 15,
color: theme.linkColor,
},
mainContainer: {
flexDirection: 'column',
},
};
});
export type MenuItemProps = {
centered?: boolean;
chevronStyle?: StyleProp<ViewStyle>;
containerStyle?: StyleProp<ViewStyle>;
defaultMessage?: string;
i18nId?: string;
iconContainerStyle?: StyleProp<ViewStyle>;
iconName?: string;
isDestructor?: boolean;
isLink?: boolean;
labelComponent?: ReactNode;
labelStyle?: StyleProp<TextStyle>;
leftComponent?: ReactNode;
messageValues?: Record<string, any>;
onPress: () => void;
rightComponent?: ReactNode;
separator?: boolean;
separatorStyle?: StyleProp<ViewStyle>;
showArrow?: boolean;
testID: string;
};
const MenuItem = ({
centered,
chevronStyle,
containerStyle,
defaultMessage = '',
i18nId,
iconContainerStyle,
iconName,
isDestructor = false,
isLink = false,
labelComponent,
labelStyle,
leftComponent,
messageValues,
onPress,
rightComponent,
separator = true,
separatorStyle,
showArrow = false,
testID,
}: MenuItemProps) => {
const theme = useTheme();
const style = getStyleSheet(theme);
let icon;
if (leftComponent) {
icon = leftComponent;
} else if (iconName) {
icon = (
<CompassIcon
name={iconName}
style={[style.icon, isDestructor && {color: theme.errorTextColor}]}
/>
);
}
let label;
if (labelComponent) {
label = labelComponent;
} else if (i18nId) {
label = (
<FormattedText
id={i18nId}
defaultMessage={defaultMessage}
style={[
style.label,
labelStyle,
isDestructor && {color: theme.errorTextColor},
centered ? style.centerLabel : {},
isLink && style.linkContainer,
]}
values={messageValues}
/>
);
}
return (
<TouchableWithFeedback
testID={testID}
onPress={onPress}
underlayColor={changeOpacity(theme.centerChannelColor, Platform.select({android: 0.1, ios: 0.3}) || 0.3)}
>
<View style={style.mainContainer}>
<View style={[style.container, containerStyle]}>
{icon && (
<View style={[style.iconContainer, iconContainerStyle]}>
{icon}
</View>
)}
<View style={style.labelContainer}>
{label}
</View>
{rightComponent}
{Boolean(showArrow) && (
<CompassIcon
name='chevron-right'
style={[style.chevron, chevronStyle]}
/>
)}
</View>
{Boolean(separator) && (<View style={[style.divider, separatorStyle]}/>)}
</View>
</TouchableWithFeedback>
);
};
export default MenuItem;