|
|
|
@ -2,10 +2,19 @@ import Slider from 'rc-slider';
|
|
|
|
|
|
|
|
|
|
import { isNumber } from 'lodash';
|
|
|
|
|
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import useUpdate from 'react-use/lib/useUpdate';
|
|
|
|
|
import styled from 'styled-components';
|
|
|
|
|
import { Flex } from '../basic/Flex';
|
|
|
|
|
import { SessionSettingsItemWrapper } from './SessionSettingListItem';
|
|
|
|
|
|
|
|
|
|
const StyledZoomValue = styled.p`
|
|
|
|
|
min-width: 40px;
|
|
|
|
|
margin-inline-start: var(--margins-lg);
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
export const ZoomingSessionSlider = (props: { onSliderChange?: (value: number) => void }) => {
|
|
|
|
|
const [value, setValue] = useState(window.getSettingValue('zoom-factor-setting') || 100);
|
|
|
|
|
const forceUpdate = useUpdate();
|
|
|
|
|
const handleSlider = async (val: number | Array<number>) => {
|
|
|
|
|
const newSetting = isNumber(val) ? val : val?.[0] || 1;
|
|
|
|
@ -15,26 +24,30 @@ export const ZoomingSessionSlider = (props: { onSliderChange?: (value: number) =
|
|
|
|
|
window.updateZoomFactor();
|
|
|
|
|
forceUpdate();
|
|
|
|
|
};
|
|
|
|
|
const currentValueFromSettings = window.getSettingValue('zoom-factor-setting') || 100;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<SessionSettingsItemWrapper title={window.i18n('zoomFactorSettingTitle')} inline={false}>
|
|
|
|
|
<div className="slider-wrapper">
|
|
|
|
|
<Flex
|
|
|
|
|
container={true}
|
|
|
|
|
justifyContent={'flex-start'}
|
|
|
|
|
alignItems={'center'}
|
|
|
|
|
margin={'var(--margins-lg) var(--margins-sm)'}
|
|
|
|
|
>
|
|
|
|
|
<Slider
|
|
|
|
|
dots={true}
|
|
|
|
|
step={20}
|
|
|
|
|
min={60}
|
|
|
|
|
max={200}
|
|
|
|
|
defaultValue={currentValueFromSettings}
|
|
|
|
|
onChange={e => {
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={(val: number | Array<number>) => {
|
|
|
|
|
setValue(isNumber(val) ? val : val?.[0] || 1);
|
|
|
|
|
}}
|
|
|
|
|
onChangeComplete={e => {
|
|
|
|
|
void handleSlider(e);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div className="slider-info">
|
|
|
|
|
<p>{currentValueFromSettings}%</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<StyledZoomValue>{value}%</StyledZoomValue>
|
|
|
|
|
</Flex>
|
|
|
|
|
</SessionSettingsItemWrapper>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|