@proximus/lavender-switch-native 0.1.0-alpha.4 → 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PxSwitch.js +130 -0
- package/package.json +10 -30
- package/CHANGELOG.md +0 -55
- package/src/PxSwitch.tsx +0 -233
- package/tsconfig.json +0 -8
- /package/{src/index.ts → dist/index.js} +0 -0
package/dist/PxSwitch.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { Animated, StyleSheet, TouchableWithoutFeedback, View, } from 'react-native';
|
|
3
|
+
import { Directions, FlingGestureHandler, State, } from 'react-native-gesture-handler';
|
|
4
|
+
import { a11y, e2eID } from '@proximus/lavender-common-native';
|
|
5
|
+
import { ThemeContext, } from '@proximus/lavender-styling-native';
|
|
6
|
+
const defaults = {
|
|
7
|
+
circleSize: 20,
|
|
8
|
+
duration: 200,
|
|
9
|
+
interpolationRange: 100,
|
|
10
|
+
};
|
|
11
|
+
export class PxSwitch extends Component {
|
|
12
|
+
static defaultProps = {
|
|
13
|
+
disabled: false,
|
|
14
|
+
value: false,
|
|
15
|
+
type: 'primary',
|
|
16
|
+
};
|
|
17
|
+
static contextType = ThemeContext;
|
|
18
|
+
constructor(props) {
|
|
19
|
+
super(props);
|
|
20
|
+
const { value } = props;
|
|
21
|
+
this.state = {
|
|
22
|
+
containerBackgroundColor: new Animated.Value(value ? defaults.interpolationRange : -defaults.interpolationRange),
|
|
23
|
+
transformSwitch: new Animated.Value(value ? defaults.circleSize - 10 : -defaults.circleSize + 10),
|
|
24
|
+
value: value || false,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
componentDidUpdate(prevProps) {
|
|
28
|
+
const { disabled, value } = this.props;
|
|
29
|
+
if (prevProps.value !== value && !disabled) {
|
|
30
|
+
this._animateSwitch(!!value);
|
|
31
|
+
this.setState({ value: !!value });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
_handleSwitch = (activate) => {
|
|
35
|
+
const { onValueChange, disabled, lookOnlyProps } = this.props;
|
|
36
|
+
if (!disabled) {
|
|
37
|
+
if (lookOnlyProps) {
|
|
38
|
+
if (onValueChange) {
|
|
39
|
+
onValueChange(!this.props.value);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const { value } = this.state;
|
|
44
|
+
this._animateSwitch(activate ?? !value);
|
|
45
|
+
this.setState({ value: activate ?? !value }, () => {
|
|
46
|
+
if (onValueChange) {
|
|
47
|
+
onValueChange(this.state.value);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
_animateSwitch = (value) => {
|
|
54
|
+
Animated.parallel([
|
|
55
|
+
Animated.spring(this.state.transformSwitch, {
|
|
56
|
+
useNativeDriver: true,
|
|
57
|
+
toValue: value ? defaults.circleSize - 10 : -defaults.circleSize + 10,
|
|
58
|
+
}),
|
|
59
|
+
Animated.timing(this.state.containerBackgroundColor, {
|
|
60
|
+
duration: defaults.duration,
|
|
61
|
+
useNativeDriver: true,
|
|
62
|
+
toValue: value
|
|
63
|
+
? defaults.interpolationRange
|
|
64
|
+
: -defaults.interpolationRange,
|
|
65
|
+
}),
|
|
66
|
+
]).start();
|
|
67
|
+
};
|
|
68
|
+
render() {
|
|
69
|
+
const { containerBackgroundColor, value } = this.state;
|
|
70
|
+
const { testID, disabled, ...accessibilityProps } = this.props;
|
|
71
|
+
const containerBackground = containerBackgroundColor.interpolate({
|
|
72
|
+
inputRange: [-defaults.interpolationRange, defaults.interpolationRange],
|
|
73
|
+
outputRange: [
|
|
74
|
+
this.context?.theme?.t('ColorBackgroundContainerStrongDefault'),
|
|
75
|
+
this.context?.theme?.t('ColorBackgroundPurposeSuccessDefault'),
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
return (React.createElement(FlingGestureHandler, { direction: Directions.LEFT, numberOfPointers: 1, onHandlerStateChange: ({ nativeEvent }) => {
|
|
79
|
+
if (nativeEvent.state === State.ACTIVE && value) {
|
|
80
|
+
this._handleSwitch(false);
|
|
81
|
+
}
|
|
82
|
+
} },
|
|
83
|
+
React.createElement(FlingGestureHandler, { direction: Directions.RIGHT, numberOfPointers: 1, onHandlerStateChange: ({ nativeEvent }) => {
|
|
84
|
+
if (nativeEvent.state === State.ACTIVE && !value) {
|
|
85
|
+
this._handleSwitch(true);
|
|
86
|
+
}
|
|
87
|
+
} },
|
|
88
|
+
React.createElement(View, { style: [this.props.containerStyle] },
|
|
89
|
+
React.createElement(TouchableWithoutFeedback, { disabled: disabled, onPress: () => this._handleSwitch(), accessible: true, ...e2eID(testID), ...a11y({
|
|
90
|
+
accessible: true,
|
|
91
|
+
accessibilityRole: 'switch',
|
|
92
|
+
accessibilityLabel: this.props.labelAccessibilityProp?.accessibilityLabel,
|
|
93
|
+
accessibilityHint: this.props.labelAccessibilityProp?.accessibilityHint,
|
|
94
|
+
accessibilityState: {
|
|
95
|
+
disabled,
|
|
96
|
+
selected: value,
|
|
97
|
+
},
|
|
98
|
+
...accessibilityProps,
|
|
99
|
+
}) },
|
|
100
|
+
React.createElement(Animated.View, { style: [
|
|
101
|
+
styles.track,
|
|
102
|
+
{
|
|
103
|
+
backgroundColor: containerBackground,
|
|
104
|
+
borderRadius: this.context?.theme?.t('RadiusPill').number,
|
|
105
|
+
width: this.context?.theme?.t('SizeActionInputSwitchWidth').number,
|
|
106
|
+
padding: this.context?.theme?.t('Padding3xsMobile').number,
|
|
107
|
+
},
|
|
108
|
+
disabled && {
|
|
109
|
+
backgroundColor: this.context?.theme?.t('ColorBackgroundStateDisabledDefault'),
|
|
110
|
+
},
|
|
111
|
+
] },
|
|
112
|
+
React.createElement(Animated.View, { style: [
|
|
113
|
+
{
|
|
114
|
+
width: this.context?.theme?.t('SizeIconM').number,
|
|
115
|
+
height: this.context?.theme?.t('SizeIconM').number,
|
|
116
|
+
borderRadius: this.context?.theme?.t('RadiusPill').number,
|
|
117
|
+
backgroundColor: disabled
|
|
118
|
+
? this.context?.theme?.t('ColorBackgroundStateDisabledDefault')
|
|
119
|
+
: this.context?.theme?.t('ColorBackgroundContainerLightDefault'),
|
|
120
|
+
transform: [{ translateX: this.state.transformSwitch }],
|
|
121
|
+
},
|
|
122
|
+
] })))))));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const styles = StyleSheet.create({
|
|
126
|
+
track: {
|
|
127
|
+
flexDirection: 'row',
|
|
128
|
+
justifyContent: 'center',
|
|
129
|
+
},
|
|
130
|
+
});
|
package/package.json
CHANGED
|
@@ -1,41 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-switch-native",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
4
|
"description": "Lavender react native switch component",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
7
10
|
"type": "module",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"clean": "rm -rf dist",
|
|
10
|
-
"prepublish": "yarn clean && yarn build",
|
|
11
|
-
"build": "npx tsc -p tsconfig.json"
|
|
12
|
-
},
|
|
13
11
|
"peerDependencies": {
|
|
14
|
-
"@proximus/lavender-common-native": "
|
|
15
|
-
"@proximus/lavender-icon-native": "
|
|
16
|
-
"@proximus/lavender-styling-native": "
|
|
17
|
-
"@proximus/lavender-texts-native": "
|
|
12
|
+
"@proximus/lavender-common-native": "*",
|
|
13
|
+
"@proximus/lavender-icon-native": "*",
|
|
14
|
+
"@proximus/lavender-styling-native": "*",
|
|
15
|
+
"@proximus/lavender-texts-native": "*",
|
|
18
16
|
"react-native-gesture-handler": "*"
|
|
19
17
|
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"@proximus/lavender-common-native": "0.1.0-alpha.4",
|
|
22
|
-
"@proximus/lavender-icon-native": "0.1.0-alpha.4",
|
|
23
|
-
"@proximus/lavender-styling-native": "0.1.0-alpha.3",
|
|
24
|
-
"@proximus/lavender-texts-native": "0.1.0-alpha.4"
|
|
25
|
-
},
|
|
26
18
|
"publishConfig": {
|
|
27
19
|
"access": "public"
|
|
28
|
-
}
|
|
29
|
-
"lerna": {
|
|
30
|
-
"command": {
|
|
31
|
-
"publish": {
|
|
32
|
-
"assets": [
|
|
33
|
-
"dist",
|
|
34
|
-
"src",
|
|
35
|
-
"package.json"
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"gitHead": "6e9252a716a08ededdfbfd6f5b1db70ab21e026e"
|
|
20
|
+
}
|
|
41
21
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [0.1.0-alpha.4](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-switch-native@0.1.0-alpha.3...@proximus/lavender-switch-native@0.1.0-alpha.4) (2025-09-19)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @proximus/lavender-switch-native
|
|
9
|
-
|
|
10
|
-
# [0.1.0-alpha.3](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-switch-native@0.1.0-alpha.2...@proximus/lavender-switch-native@0.1.0-alpha.3) (2025-09-12)
|
|
11
|
-
|
|
12
|
-
**Note:** Version bump only for package @proximus/lavender-switch-native
|
|
13
|
-
|
|
14
|
-
# [0.1.0-alpha.2](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-switch-native@0.1.0-alpha.1...@proximus/lavender-switch-native@0.1.0-alpha.2) (2025-09-05)
|
|
15
|
-
|
|
16
|
-
### Features
|
|
17
|
-
|
|
18
|
-
- **BCRI-4279213:** update token architecture and component styles ([#18](https://github.com/Pxs-Corporate/react-native-lavender/issues/18)) ([2fabf41](https://github.com/Pxs-Corporate/react-native-lavender/commit/2fabf416ce069e9756daa868c3012181db87e7f5))
|
|
19
|
-
|
|
20
|
-
# [0.1.0-alpha.1](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-switch-native@0.1.0-alpha.0...@proximus/lavender-switch-native@0.1.0-alpha.1) (2025-08-13)
|
|
21
|
-
|
|
22
|
-
### Bug Fixes
|
|
23
|
-
|
|
24
|
-
- **BCRI-4210372:** fix types field in modules ([68ac126](https://github.com/Pxs-Corporate/react-native-lavender/commit/68ac12657112473ae9e0e683076b1d9172be9ce6))
|
|
25
|
-
|
|
26
|
-
# 0.1.0-alpha.0 (2025-08-13)
|
|
27
|
-
|
|
28
|
-
### Bug Fixes
|
|
29
|
-
|
|
30
|
-
- **BCRI-000000:** switch using tokens ([0442cc0](https://github.com/Pxs-Corporate/react-native-lavender/commit/0442cc0aba3fcbbcb21938da0747ea593d413bf6))
|
|
31
|
-
- **BCRI-00000:** mendix widgets ids for backward compatibility ([69e61fd](https://github.com/Pxs-Corporate/react-native-lavender/commit/69e61fde51b203b947ec7a1094f10067a1ecfdbb))
|
|
32
|
-
|
|
33
|
-
### Features
|
|
34
|
-
|
|
35
|
-
- **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
|
|
36
|
-
- **BCRI-3651771:** switch module ([d6f8151](https://github.com/Pxs-Corporate/react-native-lavender/commit/d6f81510e13ca3634f843caa0286c444373a039c))
|
|
37
|
-
- **BCRI-3660857:** cell components ([af9e45c](https://github.com/Pxs-Corporate/react-native-lavender/commit/af9e45cefc20d08d2338380ff4cd8cd6851abe24))
|
|
38
|
-
- **BCRI-4002610:** update icon handling and remove deprecated font references ([4399fe4](https://github.com/Pxs-Corporate/react-native-lavender/commit/4399fe4bff06aa70f5c29705fcc89d5243b0e3e7))
|
|
39
|
-
- **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
|
|
40
|
-
- **BCRI-4210372:** fix bad version numbers ([bc6a8ba](https://github.com/Pxs-Corporate/react-native-lavender/commit/bc6a8ba48c15347442f2ac38dacae7ffba3d95eb))
|
|
41
|
-
|
|
42
|
-
# (2025-08-13)
|
|
43
|
-
|
|
44
|
-
### Bug Fixes
|
|
45
|
-
|
|
46
|
-
- **BCRI-000000:** switch using tokens ([0442cc0](https://github.com/Pxs-Corporate/react-native-lavender/commit/0442cc0aba3fcbbcb21938da0747ea593d413bf6))
|
|
47
|
-
- **BCRI-00000:** mendix widgets ids for backward compatibility ([69e61fd](https://github.com/Pxs-Corporate/react-native-lavender/commit/69e61fde51b203b947ec7a1094f10067a1ecfdbb))
|
|
48
|
-
|
|
49
|
-
### Features
|
|
50
|
-
|
|
51
|
-
- **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
|
|
52
|
-
- **BCRI-3651771:** switch module ([d6f8151](https://github.com/Pxs-Corporate/react-native-lavender/commit/d6f81510e13ca3634f843caa0286c444373a039c))
|
|
53
|
-
- **BCRI-3660857:** cell components ([af9e45c](https://github.com/Pxs-Corporate/react-native-lavender/commit/af9e45cefc20d08d2338380ff4cd8cd6851abe24))
|
|
54
|
-
- **BCRI-4002610:** update icon handling and remove deprecated font references ([4399fe4](https://github.com/Pxs-Corporate/react-native-lavender/commit/4399fe4bff06aa70f5c29705fcc89d5243b0e3e7))
|
|
55
|
-
- **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
|
package/src/PxSwitch.tsx
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
AccessibilityProps,
|
|
4
|
-
Animated,
|
|
5
|
-
StyleProp,
|
|
6
|
-
StyleSheet,
|
|
7
|
-
TouchableWithoutFeedback,
|
|
8
|
-
View,
|
|
9
|
-
ViewStyle,
|
|
10
|
-
} from 'react-native';
|
|
11
|
-
import {
|
|
12
|
-
Directions,
|
|
13
|
-
FlingGestureHandler,
|
|
14
|
-
State,
|
|
15
|
-
} from 'react-native-gesture-handler';
|
|
16
|
-
|
|
17
|
-
import { a11y, e2eID } from '@proximus/lavender-common-native';
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
ITheme,
|
|
21
|
-
IThemeContext,
|
|
22
|
-
ThemeContext,
|
|
23
|
-
} from '@proximus/lavender-styling-native';
|
|
24
|
-
|
|
25
|
-
export interface ISwitchProps extends AccessibilityProps {
|
|
26
|
-
onValueChange: (value: boolean) => void;
|
|
27
|
-
disabled?: boolean;
|
|
28
|
-
lookOnlyProps?: boolean;
|
|
29
|
-
value?: boolean;
|
|
30
|
-
testID?: string;
|
|
31
|
-
labelAccessibilityProp?: AccessibilityProps;
|
|
32
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
33
|
-
hasLabel?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface IState {
|
|
37
|
-
value: boolean;
|
|
38
|
-
transformSwitch: Animated.Value;
|
|
39
|
-
containerBackgroundColor: Animated.Value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const defaults = {
|
|
43
|
-
circleSize: 20,
|
|
44
|
-
duration: 200,
|
|
45
|
-
interpolationRange: 100,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export class PxSwitch extends Component<ISwitchProps, IState> {
|
|
49
|
-
static defaultProps = {
|
|
50
|
-
disabled: false,
|
|
51
|
-
value: false,
|
|
52
|
-
type: 'primary',
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
static contextType = ThemeContext;
|
|
56
|
-
|
|
57
|
-
constructor(props: ISwitchProps) {
|
|
58
|
-
super(props);
|
|
59
|
-
|
|
60
|
-
const { value } = props;
|
|
61
|
-
this.state = {
|
|
62
|
-
containerBackgroundColor: new Animated.Value(
|
|
63
|
-
value ? defaults.interpolationRange : -defaults.interpolationRange
|
|
64
|
-
),
|
|
65
|
-
transformSwitch: new Animated.Value(
|
|
66
|
-
value ? defaults.circleSize - 10 : -defaults.circleSize + 10
|
|
67
|
-
),
|
|
68
|
-
value: value || false,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
componentDidUpdate(prevProps: ISwitchProps) {
|
|
73
|
-
const { disabled, value } = this.props;
|
|
74
|
-
|
|
75
|
-
if (prevProps.value !== value && !disabled) {
|
|
76
|
-
this._animateSwitch(!!value);
|
|
77
|
-
this.setState({ value: !!value });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
_handleSwitch = (activate?: boolean) => {
|
|
82
|
-
const { onValueChange, disabled, lookOnlyProps } = this.props;
|
|
83
|
-
|
|
84
|
-
if (!disabled) {
|
|
85
|
-
if (lookOnlyProps) {
|
|
86
|
-
if (onValueChange) {
|
|
87
|
-
onValueChange(!this.props.value);
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
const { value } = this.state;
|
|
91
|
-
this._animateSwitch(activate ?? !value);
|
|
92
|
-
this.setState({ value: activate ?? !value }, () => {
|
|
93
|
-
if (onValueChange) {
|
|
94
|
-
onValueChange(this.state.value);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
_animateSwitch = (value: boolean) => {
|
|
102
|
-
Animated.parallel([
|
|
103
|
-
Animated.spring(this.state.transformSwitch, {
|
|
104
|
-
useNativeDriver: true,
|
|
105
|
-
toValue: value ? defaults.circleSize - 10 : -defaults.circleSize + 10,
|
|
106
|
-
}),
|
|
107
|
-
Animated.timing(this.state.containerBackgroundColor, {
|
|
108
|
-
duration: defaults.duration,
|
|
109
|
-
useNativeDriver: true,
|
|
110
|
-
toValue: value
|
|
111
|
-
? defaults.interpolationRange
|
|
112
|
-
: -defaults.interpolationRange,
|
|
113
|
-
}),
|
|
114
|
-
]).start();
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
render() {
|
|
118
|
-
const { containerBackgroundColor, value } = this.state;
|
|
119
|
-
|
|
120
|
-
const { testID, disabled, ...accessibilityProps } = this.props;
|
|
121
|
-
|
|
122
|
-
const containerBackground = containerBackgroundColor.interpolate({
|
|
123
|
-
inputRange: [-defaults.interpolationRange, defaults.interpolationRange],
|
|
124
|
-
outputRange: [
|
|
125
|
-
((this.context as IThemeContext)?.theme as ITheme)?.t(
|
|
126
|
-
'ColorBackgroundContainerStrongDefault'
|
|
127
|
-
),
|
|
128
|
-
((this.context as IThemeContext)?.theme as ITheme)?.t(
|
|
129
|
-
'ColorBackgroundPurposeSuccessDefault'
|
|
130
|
-
),
|
|
131
|
-
],
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<FlingGestureHandler
|
|
136
|
-
direction={Directions.LEFT}
|
|
137
|
-
numberOfPointers={1}
|
|
138
|
-
onHandlerStateChange={({ nativeEvent }) => {
|
|
139
|
-
if (nativeEvent.state === State.ACTIVE && value) {
|
|
140
|
-
this._handleSwitch(false);
|
|
141
|
-
}
|
|
142
|
-
}}
|
|
143
|
-
>
|
|
144
|
-
<FlingGestureHandler
|
|
145
|
-
direction={Directions.RIGHT}
|
|
146
|
-
numberOfPointers={1}
|
|
147
|
-
onHandlerStateChange={({ nativeEvent }) => {
|
|
148
|
-
if (nativeEvent.state === State.ACTIVE && !value) {
|
|
149
|
-
this._handleSwitch(true);
|
|
150
|
-
}
|
|
151
|
-
}}
|
|
152
|
-
>
|
|
153
|
-
<View style={[this.props.containerStyle]}>
|
|
154
|
-
<TouchableWithoutFeedback
|
|
155
|
-
disabled={disabled}
|
|
156
|
-
onPress={() => this._handleSwitch()}
|
|
157
|
-
accessible={false}
|
|
158
|
-
{...e2eID(testID)}
|
|
159
|
-
{...a11y({
|
|
160
|
-
accessible: true,
|
|
161
|
-
accessibilityRole: 'switch',
|
|
162
|
-
accessibilityLabel:
|
|
163
|
-
this.props.labelAccessibilityProp?.accessibilityLabel,
|
|
164
|
-
accessibilityHint:
|
|
165
|
-
this.props.labelAccessibilityProp?.accessibilityHint,
|
|
166
|
-
accessibilityState: {
|
|
167
|
-
disabled,
|
|
168
|
-
selected: value,
|
|
169
|
-
},
|
|
170
|
-
...accessibilityProps,
|
|
171
|
-
})}
|
|
172
|
-
>
|
|
173
|
-
<Animated.View
|
|
174
|
-
style={[
|
|
175
|
-
styles.track,
|
|
176
|
-
{
|
|
177
|
-
backgroundColor: containerBackground,
|
|
178
|
-
borderRadius: (
|
|
179
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
180
|
-
)?.t('RadiusPill').number,
|
|
181
|
-
width: (
|
|
182
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
183
|
-
)?.t('SizeActionInputSwitchWidth').number,
|
|
184
|
-
padding: (
|
|
185
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
186
|
-
)?.t('Padding3xsMobile').number,
|
|
187
|
-
},
|
|
188
|
-
disabled && {
|
|
189
|
-
backgroundColor: (
|
|
190
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
191
|
-
)?.t('ColorBackgroundStateDisabledDefault'),
|
|
192
|
-
},
|
|
193
|
-
]}
|
|
194
|
-
>
|
|
195
|
-
<Animated.View
|
|
196
|
-
style={[
|
|
197
|
-
{
|
|
198
|
-
width: (
|
|
199
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
200
|
-
)?.t('SizeIconM').number,
|
|
201
|
-
height: (
|
|
202
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
203
|
-
)?.t('SizeIconM').number,
|
|
204
|
-
|
|
205
|
-
borderRadius: (
|
|
206
|
-
(this.context as IThemeContext)?.theme as ITheme
|
|
207
|
-
)?.t('RadiusPill').number,
|
|
208
|
-
backgroundColor: disabled
|
|
209
|
-
? ((this.context as IThemeContext)?.theme as ITheme)?.t(
|
|
210
|
-
'ColorBackgroundStateDisabledDefault'
|
|
211
|
-
)
|
|
212
|
-
: ((this.context as IThemeContext)?.theme as ITheme)?.t(
|
|
213
|
-
'ColorBackgroundContainerLightDefault'
|
|
214
|
-
),
|
|
215
|
-
transform: [{ translateX: this.state.transformSwitch }],
|
|
216
|
-
},
|
|
217
|
-
]}
|
|
218
|
-
></Animated.View>
|
|
219
|
-
</Animated.View>
|
|
220
|
-
</TouchableWithoutFeedback>
|
|
221
|
-
</View>
|
|
222
|
-
</FlingGestureHandler>
|
|
223
|
-
</FlingGestureHandler>
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const styles = StyleSheet.create({
|
|
229
|
-
track: {
|
|
230
|
-
flexDirection: 'row',
|
|
231
|
-
justifyContent: 'center',
|
|
232
|
-
},
|
|
233
|
-
});
|
package/tsconfig.json
DELETED
|
File without changes
|