1
1
import { Platform } from 'react-native' ;
2
2
import { PressableEvent } from './PressableProps' ;
3
- import { PressableStateMachine } from './StateMachine' ;
3
+ import { StateDefinition } from './StateMachine' ;
4
4
5
5
export enum StateMachineEvent {
6
6
NATIVE_BEGIN = 'nativeBegin' ,
@@ -9,11 +9,11 @@ export enum StateMachineEvent {
9
9
LONG_PRESS_TOUCHES_DOWN = 'longPressTouchesDown' ,
10
10
}
11
11
12
- function getAndroidStateMachine (
12
+ function getAndroidStatesConfig (
13
13
handlePressIn : ( event : PressableEvent ) => void ,
14
14
handlePressOut : ( event : PressableEvent ) => void
15
15
) {
16
- return new PressableStateMachine ( [
16
+ return [
17
17
{
18
18
eventName : StateMachineEvent . NATIVE_BEGIN ,
19
19
} ,
@@ -25,14 +25,14 @@ function getAndroidStateMachine(
25
25
eventName : StateMachineEvent . FINALIZE ,
26
26
callback : handlePressOut ,
27
27
} ,
28
- ] ) ;
28
+ ] ;
29
29
}
30
30
31
- function getIosStateMachine (
31
+ function getIosStatesConfig (
32
32
handlePressIn : ( event : PressableEvent ) => void ,
33
33
handlePressOut : ( event : PressableEvent ) => void
34
34
) {
35
- return new PressableStateMachine ( [
35
+ return [
36
36
{
37
37
eventName : StateMachineEvent . LONG_PRESS_TOUCHES_DOWN ,
38
38
} ,
@@ -44,14 +44,14 @@ function getIosStateMachine(
44
44
eventName : StateMachineEvent . FINALIZE ,
45
45
callback : handlePressOut ,
46
46
} ,
47
- ] ) ;
47
+ ] ;
48
48
}
49
49
50
- function getWebStateMachine (
50
+ function getWebStatesConfig (
51
51
handlePressIn : ( event : PressableEvent ) => void ,
52
52
handlePressOut : ( event : PressableEvent ) => void
53
53
) {
54
- return new PressableStateMachine ( [
54
+ return [
55
55
{
56
56
eventName : StateMachineEvent . NATIVE_BEGIN ,
57
57
} ,
@@ -66,14 +66,14 @@ function getWebStateMachine(
66
66
eventName : StateMachineEvent . FINALIZE ,
67
67
callback : handlePressOut ,
68
68
} ,
69
- ] ) ;
69
+ ] ;
70
70
}
71
71
72
- function getMacosStateMachine (
72
+ function getMacosStatesConfig (
73
73
handlePressIn : ( event : PressableEvent ) => void ,
74
74
handlePressOut : ( event : PressableEvent ) => void
75
75
) {
76
- return new PressableStateMachine ( [
76
+ return [
77
77
{
78
78
eventName : StateMachineEvent . LONG_PRESS_TOUCHES_DOWN ,
79
79
} ,
@@ -88,38 +88,38 @@ function getMacosStateMachine(
88
88
eventName : StateMachineEvent . FINALIZE ,
89
89
callback : handlePressOut ,
90
90
} ,
91
- ] ) ;
91
+ ] ;
92
92
}
93
93
94
- function getUniversalStateMachine (
94
+ function getUniversalStatesConfig (
95
95
handlePressIn : ( event : PressableEvent ) => void ,
96
96
handlePressOut : ( event : PressableEvent ) => void
97
97
) {
98
- return new PressableStateMachine ( [
98
+ return [
99
99
{
100
100
eventName : StateMachineEvent . FINALIZE ,
101
101
callback : ( event : PressableEvent ) => {
102
102
handlePressIn ( event ) ;
103
103
handlePressOut ( event ) ;
104
104
} ,
105
105
} ,
106
- ] ) ;
106
+ ] ;
107
107
}
108
108
109
- export function getConfiguredStateMachine (
109
+ export function getStatesConfig (
110
110
handlePressIn : ( event : PressableEvent ) => void ,
111
111
handlePressOut : ( event : PressableEvent ) => void
112
- ) {
112
+ ) : StateDefinition [ ] {
113
113
if ( Platform . OS === 'android' ) {
114
- return getAndroidStateMachine ( handlePressIn , handlePressOut ) ;
114
+ return getAndroidStatesConfig ( handlePressIn , handlePressOut ) ;
115
115
} else if ( Platform . OS === 'ios' ) {
116
- return getIosStateMachine ( handlePressIn , handlePressOut ) ;
116
+ return getIosStatesConfig ( handlePressIn , handlePressOut ) ;
117
117
} else if ( Platform . OS === 'web' ) {
118
- return getWebStateMachine ( handlePressIn , handlePressOut ) ;
118
+ return getWebStatesConfig ( handlePressIn , handlePressOut ) ;
119
119
} else if ( Platform . OS === 'macos' ) {
120
- return getMacosStateMachine ( handlePressIn , handlePressOut ) ;
120
+ return getMacosStatesConfig ( handlePressIn , handlePressOut ) ;
121
121
} else {
122
122
// Unknown platform - using minimal universal setup.
123
- return getUniversalStateMachine ( handlePressIn , handlePressOut ) ;
123
+ return getUniversalStatesConfig ( handlePressIn , handlePressOut ) ;
124
124
}
125
125
}
0 commit comments