chore: remove switch color

This commit is contained in:
GleidsonDaniel 2024-03-15 15:42:57 -03:00
parent fa4a3d3951
commit 624c67f048
14 changed files with 53 additions and 54 deletions

View File

@ -0,0 +1,17 @@
import { Switch as RNSwitch, SwitchProps } from 'react-native';
import React from 'react';
import { useTheme } from '../../theme';
const Switch = (props: SwitchProps): React.ReactElement => {
const { colors } = useTheme();
const trackColor = {
false: colors.buttonBackgroundDangerPress,
true: colors.buttonBackgroundSuccessPress
};
return <RNSwitch trackColor={trackColor} {...props} />;
};
export default Switch;

View File

@ -1,9 +1,9 @@
import React, { memo, useEffect, useState } from 'react';
import { Switch, View } from 'react-native';
import { View } from 'react-native';
import * as List from '../../../../containers/List';
import styles from './styles';
import { SWITCH_TRACK_COLOR, themes } from '../../../../lib/constants';
import { themes } from '../../../../lib/constants';
import { useTheme } from '../../../../theme';
import { IUser } from '../../../../definitions';
import { showConfirmationAlert } from '../../../../lib/methods/helpers/info';
@ -11,6 +11,7 @@ import I18n from '../../../../i18n';
import { changeLivechatStatus, isOmnichannelStatusAvailable } from '../../lib';
import OmnichannelQueue from './OmnichannelQueue';
import { isOmnichannelModuleAvailable } from '../../../../lib/methods';
import Switch from '../../../../containers/Switch';
interface IOmnichannelStatus {
searching: boolean;
@ -64,7 +65,7 @@ const OmnichannelStatus = memo(({ searching, goQueue, queueSize, user }: IOmnich
onPress={toggleLivechat}
right={() => (
<View style={styles.omnichannelRightContainer}>
<Switch value={status} trackColor={SWITCH_TRACK_COLOR} onValueChange={toggleLivechat} />
<Switch value={status} onValueChange={toggleLivechat} />
</View>
)}
/>

View File

@ -1,12 +1,5 @@
export const BACKGROUND_PUSH_COLOR = '#F5455C';
export const SWITCH_TRACK_COLOR = {
false: '#f5455c',
true: '#2de0a5'
};
// TODO: Remove this after the new colors are implemented
const newColors = {
surfaceLight: '#FFFFFF',

View File

@ -8,7 +8,6 @@ import SafeAreaView from '../../containers/SafeAreaView';
import StatusBar from '../../containers/StatusBar';
import { ISubscription } from '../../definitions';
import I18n from '../../i18n';
import { SWITCH_TRACK_COLOR } from '../../lib/constants';
import { events, logEvent } from '../../lib/methods/helpers/log';
import { Services } from '../../lib/services';
import { ChatsStackParamList } from '../../stacks/types';
@ -126,7 +125,6 @@ const AutoTranslateView = (): React.ReactElement => {
<Switch
testID='auto-translate-view-switch'
value={enableAutoTranslate}
trackColor={SWITCH_TRACK_COLOR}
onValueChange={toggleAutoTranslate}
/>
)}

View File

@ -1,10 +1,10 @@
import React from 'react';
import { StyleSheet, Switch, Text, View, SwitchProps } from 'react-native';
import { StyleSheet, Text, View, SwitchProps } from 'react-native';
import I18n from '../../../i18n';
import { SWITCH_TRACK_COLOR } from '../../../lib/constants';
import { useTheme } from '../../../theme';
import sharedStyles from '../../Styles';
import Switch from '../../../containers/Switch';
const styles = StyleSheet.create({
switchContainer: {
@ -51,7 +51,6 @@ export const SwitchItem = ({ id, value, label, hint, onValueChange, disabled = f
value={value}
onValueChange={onValueChange}
testID={`create-channel-${id}`}
trackColor={SWITCH_TRACK_COLOR}
disabled={disabled}
/>
</View>

View File

@ -1,6 +1,6 @@
import React from 'react';
import { connect } from 'react-redux';
import { ScrollView, Switch, Text } from 'react-native';
import { ScrollView, Text } from 'react-native';
import { StackNavigationOptions } from '@react-navigation/stack';
import { sendLoadingEvent } from '../../containers/Loading';
@ -21,9 +21,10 @@ import SelectUsers from './SelectUsers';
import SelectChannel from './SelectChannel';
import { ICreateChannelViewProps, IResult, IError, ICreateChannelViewState } from './interfaces';
import { IApplicationState, ISearchLocal, ISubscription } from '../../definitions';
import { E2E_ROOM_TYPES, SWITCH_TRACK_COLOR, themes } from '../../lib/constants';
import { E2E_ROOM_TYPES, themes } from '../../lib/constants';
import { getRoomTitle, showErrorAlert } from '../../lib/methods/helpers';
import * as List from '../../containers/List';
import Switch from '../../containers/Switch';
class CreateChannelView extends React.Component<ICreateChannelViewProps, ICreateChannelViewState> {
private channel: ISubscription;
@ -184,9 +185,7 @@ class CreateChannelView extends React.Component<ICreateChannelViewProps, ICreate
<List.Item
title='Encrypted'
testID='room-actions-encrypt'
right={() => (
<Switch value={encrypted} onValueChange={this.onEncryptedChange} trackColor={SWITCH_TRACK_COLOR} />
)}
right={() => <Switch value={encrypted} onValueChange={this.onEncryptedChange} />}
/>
</>
) : null}

View File

@ -1,13 +1,14 @@
import React, { PureComponent } from 'react';
import { Animated, Easing, Switch, Text, TouchableWithoutFeedback, View } from 'react-native';
import { Animated, Easing, Text, TouchableWithoutFeedback, View } from 'react-native';
import Touch from '../../containers/Touch';
import { CustomIcon, TIconsName } from '../../containers/CustomIcon';
import Check from '../../containers/Check';
import I18n from '../../i18n';
import { SWITCH_TRACK_COLOR, themes } from '../../lib/constants';
import { themes } from '../../lib/constants';
import styles from './styles';
import { TSupportedThemes } from '../../theme';
import Switch from '../../containers/Switch';
const ANIMATION_DURATION = 200;
const ANIMATION_PROPS = {
@ -124,7 +125,7 @@ export default class DirectoryOptions extends PureComponent<IDirectoryOptionsPro
{I18n.t('Search_global_users_description')}
</Text>
</View>
<Switch value={globalUsers} onValueChange={toggleWorkspace} trackColor={SWITCH_TRACK_COLOR} />
<Switch value={globalUsers} onValueChange={toggleWorkspace} />
</View>
</>
) : null}

View File

@ -1,6 +1,6 @@
import { RouteProp, useNavigation, useRoute } from '@react-navigation/core';
import React, { useEffect, useState } from 'react';
import { Switch, Text } from 'react-native';
import { Text } from 'react-native';
import { StackNavigationProp } from '@react-navigation/stack';
import { TActionSheetOptionsItem, useActionSheet } from '../../containers/ActionSheet';
@ -10,7 +10,6 @@ import SafeAreaView from '../../containers/SafeAreaView';
import StatusBar from '../../containers/StatusBar';
import { IRoomNotifications, TRoomNotificationsModel } from '../../definitions';
import I18n from '../../i18n';
import { SWITCH_TRACK_COLOR } from '../../lib/constants';
import { useAppSelector } from '../../lib/hooks';
import { showErrorAlertWithEMessage } from '../../lib/methods/helpers';
import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion';
@ -20,6 +19,7 @@ import { ChatsStackParamList } from '../../stacks/types';
import { useTheme } from '../../theme';
import sharedStyles from '../Styles';
import { OPTIONS } from './options';
import Switch from '../../containers/Switch';
type TOptions = keyof typeof OPTIONS;
type TRoomNotifications = keyof IRoomNotifications;
@ -80,7 +80,6 @@ const RenderSwitch = ({ preference, room, onChangeValue }: IBaseParams) => {
<Switch
value={switchValue}
testID={preference as string}
trackColor={SWITCH_TRACK_COLOR}
onValueChange={value => {
onChangeValue(preference, { [preference]: switchValue ? '1' : '0' }, () => setSwitchValue(switchValue));
setSwitchValue(value);

View File

@ -3,7 +3,7 @@ import { Q } from '@nozbe/watermelondb';
import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack';
import isEmpty from 'lodash/isEmpty';
import React from 'react';
import { Share, Switch, Text, View } from 'react-native';
import { Share, Text, View } from 'react-native';
import { connect } from 'react-redux';
import { Observable, Subscription } from 'rxjs';
import { CompositeNavigationProp } from '@react-navigation/native';
@ -32,7 +32,7 @@ import Touch from '../../containers/Touch';
import sharedStyles from '../Styles';
import styles from './styles';
import { ERoomType } from '../../definitions/ERoomType';
import { E2E_ROOM_TYPES, SWITCH_TRACK_COLOR, themes } from '../../lib/constants';
import { E2E_ROOM_TYPES, themes } from '../../lib/constants';
import { getPermalinkChannel } from '../../lib/methods';
import {
canAutoTranslate as canAutoTranslateMethod,
@ -53,6 +53,7 @@ import { ILivechatDepartment } from '../../definitions/ILivechatDepartment';
import { ILivechatTag } from '../../definitions/ILivechatTag';
import CallSection from './components/CallSection';
import { TNavigation } from '../../stacks/stackType';
import Switch from '../../containers/Switch';
type StackType = ChatsStackParamList & TNavigation;
@ -353,7 +354,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
hasPermission = canToggleEncryption;
}
return (
<Switch value={encrypted} trackColor={SWITCH_TRACK_COLOR} onValueChange={this.toggleEncrypted} disabled={!hasPermission} />
<Switch value={encrypted} onValueChange={this.toggleEncrypted} disabled={!hasPermission} />
);
};

View File

@ -1,9 +1,10 @@
import React from 'react';
import { Switch, Text, TextStyle, View, ViewStyle } from 'react-native';
import { Text, TextStyle, View, ViewStyle } from 'react-native';
import { TSupportedThemes } from '../../theme';
import { SWITCH_TRACK_COLOR, themes } from '../../lib/constants';
import { themes } from '../../lib/constants';
import styles from './styles';
import Switch from '../../containers/Switch';
interface ISwitchContainer {
value: boolean;
@ -51,7 +52,6 @@ const SwitchContainer: React.FC<ISwitchContainer> = React.memo(
onValueChange={onValueChange}
value={value}
disabled={disabled}
trackColor={SWITCH_TRACK_COLOR}
testID={testID}
/>
{rightLabelPrimary && (

View File

@ -1,5 +1,4 @@
import React from 'react';
import { Switch } from 'react-native';
import { connect } from 'react-redux';
import { StackNavigationOptions } from '@react-navigation/stack';
import { Subscription } from 'rxjs';
@ -10,11 +9,12 @@ import StatusBar from '../containers/StatusBar';
import * as List from '../containers/List';
import database from '../lib/database';
import { changePasscode, checkHasPasscode, supportedBiometryLabel } from '../lib/methods/helpers/localAuthentication';
import { BIOMETRY_ENABLED_KEY, DEFAULT_AUTO_LOCK, themes, SWITCH_TRACK_COLOR } from '../lib/constants';
import { BIOMETRY_ENABLED_KEY, DEFAULT_AUTO_LOCK, themes } from '../lib/constants';
import SafeAreaView from '../containers/SafeAreaView';
import { events, logEvent } from '../lib/methods/helpers/log';
import userPreferences from '../lib/methods/userPreferences';
import { IApplicationState, TServerModel } from '../definitions';
import Switch from '../containers/Switch';
const DEFAULT_BIOMETRY = false;
@ -194,14 +194,12 @@ class ScreenLockConfigView extends React.Component<IScreenLockConfigViewProps, I
renderAutoLockSwitch = () => {
const { autoLock } = this.state;
const { Force_Screen_Lock } = this.props;
return (
<Switch value={autoLock} trackColor={SWITCH_TRACK_COLOR} onValueChange={this.toggleAutoLock} disabled={Force_Screen_Lock} />
);
return <Switch value={autoLock} onValueChange={this.toggleAutoLock} disabled={Force_Screen_Lock} />;
};
renderBiometrySwitch = () => {
const { biometry } = this.state;
return <Switch value={biometry} trackColor={SWITCH_TRACK_COLOR} onValueChange={this.toggleBiometry} />;
return <Switch value={biometry} onValueChange={this.toggleBiometry} />;
};
renderAutoLockItems = () => {

View File

@ -1,13 +1,12 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
import { StackNavigationProp } from '@react-navigation/stack';
import React, { useEffect, useState } from 'react';
import { Switch } from 'react-native';
import * as List from '../containers/List';
import SafeAreaView from '../containers/SafeAreaView';
import StatusBar from '../containers/StatusBar';
import I18n from '../i18n';
import { ANALYTICS_EVENTS_KEY, CRASH_REPORT_KEY, isFDroidBuild, SWITCH_TRACK_COLOR } from '../lib/constants';
import { ANALYTICS_EVENTS_KEY, CRASH_REPORT_KEY, isFDroidBuild } from '../lib/constants';
import { useAppSelector } from '../lib/hooks';
import useServer from '../lib/methods/useServer';
import { SettingsStackParamList } from '../stacks/types';
@ -20,6 +19,7 @@ import {
toggleAnalyticsEventsReport,
toggleCrashErrorsReport
} from '../lib/methods/helpers/log';
import Switch from '../containers/Switch';
interface ISecurityPrivacyViewProps {
navigation: StackNavigationProp<SettingsStackParamList, 'SecurityPrivacyView'>;
@ -99,7 +99,7 @@ const SecurityPrivacyView = ({ navigation }: ISecurityPrivacyViewProps): JSX.Ele
title='Log_analytics_events'
testID='security-privacy-view-analytics-events'
right={() => (
<Switch value={analyticsEventsState} trackColor={SWITCH_TRACK_COLOR} onValueChange={toggleAnalyticsEvents} />
<Switch value={analyticsEventsState} onValueChange={toggleAnalyticsEvents} />
)}
/>
<List.Separator />
@ -107,7 +107,7 @@ const SecurityPrivacyView = ({ navigation }: ISecurityPrivacyViewProps): JSX.Ele
title='Send_crash_report'
testID='security-privacy-view-crash-report'
right={() => (
<Switch value={crashReportState} trackColor={SWITCH_TRACK_COLOR} onValueChange={toggleCrashReport} />
<Switch value={crashReportState} onValueChange={toggleCrashReport} />
)}
/>
<List.Separator />

View File

@ -1,5 +1,4 @@
import React, { useEffect, useLayoutEffect, useState } from 'react';
import { Switch } from 'react-native';
import { StackNavigationProp } from '@react-navigation/stack';
import { CompositeNavigationProp, useNavigation } from '@react-navigation/native';
@ -17,7 +16,8 @@ import ListPicker from './ListPicker';
import log from '../../lib/methods/helpers/log';
import { MasterDetailInsideStackParamList } from '../../stacks/MasterDetailStack/types';
import { useUserPreferences } from '../../lib/methods';
import { NOTIFICATION_IN_APP_VIBRATION, SWITCH_TRACK_COLOR } from '../../lib/constants';
import { NOTIFICATION_IN_APP_VIBRATION } from '../../lib/constants';
import Switch from '../../containers/Switch';
type TNavigation = CompositeNavigationProp<
StackNavigationProp<ProfileStackParamList, 'UserNotificationPrefView'>,
@ -129,9 +129,7 @@ const UserNotificationPreferencesView = () => {
<List.Item
title='Vibrate'
testID='user-notification-preference-view-in-app-vibration'
right={() => (
<Switch value={inAppVibration} trackColor={SWITCH_TRACK_COLOR} onValueChange={toggleInAppVibration} />
)}
right={() => <Switch value={inAppVibration} onValueChange={toggleInAppVibration} />}
/>
<List.Separator />
</List.Section>

View File

@ -1,6 +1,5 @@
import { StackNavigationProp } from '@react-navigation/stack';
import React, { useEffect } from 'react';
import { Switch } from 'react-native';
import { useDispatch } from 'react-redux';
import { setUser } from '../../actions/login';
@ -10,12 +9,12 @@ import { compareServerVersion } from '../../lib/methods/helpers';
import SafeAreaView from '../../containers/SafeAreaView';
import StatusBar from '../../containers/StatusBar';
import * as List from '../../containers/List';
import { SWITCH_TRACK_COLOR } from '../../lib/constants';
import { getUserSelector } from '../../selectors/login';
import { ProfileStackParamList } from '../../stacks/types';
import { Services } from '../../lib/services';
import { useAppSelector } from '../../lib/hooks';
import ListPicker from './ListPicker';
import Switch from '../../containers/Switch';
interface IUserPreferencesViewProps {
navigation: StackNavigationProp<ProfileStackParamList, 'UserPreferencesView'>;
@ -56,10 +55,6 @@ const UserPreferencesView = ({ navigation }: IUserPreferencesViewProps): JSX.Ele
}
};
const renderMessageParserSwitch = (value: boolean) => (
<Switch value={value} trackColor={SWITCH_TRACK_COLOR} onValueChange={toggleMessageParser} />
);
return (
<SafeAreaView testID='preferences-view'>
<StatusBar />
@ -80,7 +75,7 @@ const UserPreferencesView = ({ navigation }: IUserPreferencesViewProps): JSX.Ele
<List.Item
title='Enable_Message_Parser'
testID='preferences-view-enable-message-parser'
right={() => renderMessageParserSwitch(enableMessageParserEarlyAdoption)}
right={() => <Switch value={enableMessageParserEarlyAdoption} onValueChange={toggleMessageParser} />}
/>
<List.Separator />
</List.Section>