ref(ui-components) Improve native and web Switch (#12061)

Bring Switch component more in line
Convert some files to TS
This commit is contained in:
Robert Pintilii
2022-08-24 12:46:22 +03:00
committed by GitHub
parent 6d39d13af7
commit 8dd71a921b
11 changed files with 153 additions and 114 deletions

View File

@@ -1,22 +1,25 @@
// @flow
import React from 'react';
import { Switch, View } from 'react-native';
import { WithTranslation } from 'react-i18next';
import { View } from 'react-native';
import { translate } from '../../../base/i18n';
import { connect } from '../../../base/redux';
import { translate } from '../../../base/i18n/functions';
import { connect } from '../../../base/redux/functions';
import Switch from '../../../base/ui/components/native/Switch';
import {
DISABLED_TRACK_COLOR,
ENABLED_TRACK_COLOR,
THUMB_COLOR
// @ts-ignore
} from '../../../settings/components/native/styles';
// @ts-ignore
import styles from './styles';
/**
* The type of the React {@code Component} props of {@link LobbyModeSwitch}.
*/
type Props = {
interface Props extends WithTranslation {
/**
* True if the lobby mode is currently enabled for this conference.
@@ -26,8 +29,8 @@ type Props = {
/**
* Callback to be invoked when handling enable-disable lobby mode switch.
*/
onToggleLobbyMode: Function
};
onToggleLobbyMode: (on?: boolean) => void;
}
/**
* Component meant to Enable/Disable lobby mode.
@@ -43,14 +46,14 @@ function LobbyModeSwitch(
return (
<View style = { styles.lobbySwitchContainer }>
<Switch
onValueChange = { onToggleLobbyMode }
checked = { lobbyEnabled }
onChange = { onToggleLobbyMode }
style = { styles.lobbySwitchIcon }
thumbColor = { THUMB_COLOR }
trackColor = {{
true: ENABLED_TRACK_COLOR,
false: DISABLED_TRACK_COLOR
}}
value = { lobbyEnabled } />
}} />
</View>
);
}