react-native-ui-lib 7.44.0-snapshot.7228 → 7.44.0-snapshot.7233
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/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +7 -4
- package/lib/components/SafeArea/SafeAreaInsetsManager.js +9 -9
- package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +271 -0
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/src/commons/Constants.js +2 -10
- package/src/components/modal/index.d.ts +5 -0
- package/src/components/modal/index.js +14 -10
- package/src/components/modal/modal.api.json +5 -0
- package/src/components/segmentedControl/index.js +3 -3
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
type SafeAreaInsetsType = {
|
|
1
|
+
export type SafeAreaInsetsType = {
|
|
2
2
|
top: number;
|
|
3
3
|
left: number;
|
|
4
4
|
bottom: number;
|
|
5
5
|
right: number;
|
|
6
6
|
} | null;
|
|
7
|
+
export type SafeAreaChangedDelegateType = {
|
|
8
|
+
onSafeAreaInsetsDidChangeEvent?: (insets: SafeAreaInsetsType) => void;
|
|
9
|
+
};
|
|
7
10
|
declare class SafeAreaInsetsManager {
|
|
8
11
|
_defaultInsets: SafeAreaInsetsType;
|
|
9
12
|
_safeAreaInsets: SafeAreaInsetsType;
|
|
10
|
-
_safeAreaChangedDelegates: Array<
|
|
13
|
+
_safeAreaChangedDelegates: Array<SafeAreaChangedDelegateType>;
|
|
11
14
|
_nativeModule: any;
|
|
12
15
|
constructor();
|
|
13
16
|
setupNativeConnection(): void;
|
|
@@ -16,8 +19,8 @@ declare class SafeAreaInsetsManager {
|
|
|
16
19
|
notifyDelegates(insets: SafeAreaInsetsType): void;
|
|
17
20
|
_updateInsets(): Promise<void>;
|
|
18
21
|
getSafeAreaInsets(): Promise<SafeAreaInsetsType>;
|
|
19
|
-
addSafeAreaChangedDelegate(delegate:
|
|
20
|
-
removeSafeAreaChangedDelegate(delegateToRemove:
|
|
22
|
+
addSafeAreaChangedDelegate(delegate: SafeAreaChangedDelegateType): void;
|
|
23
|
+
removeSafeAreaChangedDelegate(delegateToRemove: SafeAreaChangedDelegateType): void;
|
|
21
24
|
get defaultInsets(): SafeAreaInsetsType;
|
|
22
25
|
refreshSafeAreaInsets(): Promise<void>;
|
|
23
26
|
}
|
|
@@ -11,12 +11,7 @@ class SafeAreaInsetsManager {
|
|
|
11
11
|
bottom: 34,
|
|
12
12
|
right: 0
|
|
13
13
|
}; // Common iPhone safe area values
|
|
14
|
-
|
|
15
|
-
top: 47,
|
|
16
|
-
left: 0,
|
|
17
|
-
bottom: 34,
|
|
18
|
-
right: 0
|
|
19
|
-
};
|
|
14
|
+
|
|
20
15
|
_safeAreaChangedDelegates = [];
|
|
21
16
|
_nativeModule = null;
|
|
22
17
|
constructor() {
|
|
@@ -46,7 +41,7 @@ class SafeAreaInsetsManager {
|
|
|
46
41
|
}
|
|
47
42
|
setupEventListener() {
|
|
48
43
|
try {
|
|
49
|
-
// Use DeviceEventEmitter instead of NativeEventEmitter to avoid getConstants
|
|
44
|
+
// Use DeviceEventEmitter instead of NativeEventEmitter to avoid getConstants
|
|
50
45
|
DeviceEventEmitter.addListener('SafeAreaInsetsDidChangeEvent', data => {
|
|
51
46
|
if (data) {
|
|
52
47
|
SafeAreaInsetsCache = data;
|
|
@@ -83,8 +78,13 @@ class SafeAreaInsetsManager {
|
|
|
83
78
|
async _updateInsets() {
|
|
84
79
|
if (this._nativeModule && SafeAreaInsetsCache === null) {
|
|
85
80
|
try {
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
const insets = await this._nativeModule.getSafeAreaInsets();
|
|
82
|
+
if (insets) {
|
|
83
|
+
SafeAreaInsetsCache = insets;
|
|
84
|
+
this._safeAreaInsets = SafeAreaInsetsCache;
|
|
85
|
+
} else {
|
|
86
|
+
this._safeAreaInsets = this._defaultInsets;
|
|
87
|
+
}
|
|
88
88
|
} catch (error) {
|
|
89
89
|
console.warn('SafeAreaInsetsManager: Failed to get native insets:', error);
|
|
90
90
|
this._safeAreaInsets = this._defaultInsets;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import {NativeModules, DeviceEventEmitter} from 'react-native';
|
|
2
|
+
|
|
3
|
+
describe('SafeAreaInsetsManager', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
// Reset mocks
|
|
6
|
+
jest.clearAllMocks();
|
|
7
|
+
|
|
8
|
+
// Reset the SafeAreaInsetsCache by creating a fresh instance
|
|
9
|
+
jest.resetModules();
|
|
10
|
+
|
|
11
|
+
// Spy on console methods to verify logging
|
|
12
|
+
jest.spyOn(console, 'log').mockImplementation(() => {});
|
|
13
|
+
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
// Restore console methods
|
|
18
|
+
jest.restoreAllMocks();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('getSafeAreaInsets', () => {
|
|
22
|
+
it('should return default insets when native module is not available', async () => {
|
|
23
|
+
// Arrange
|
|
24
|
+
NativeModules.SafeAreaManager = null;
|
|
25
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
26
|
+
|
|
27
|
+
// Act
|
|
28
|
+
const result = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
29
|
+
|
|
30
|
+
// Assert
|
|
31
|
+
expect(result).toEqual({top: 47, left: 0, bottom: 34, right: 0});
|
|
32
|
+
expect(console.log).toHaveBeenCalledWith('SafeAreaInsetsManager: Native SafeAreaManager not available, using defaults');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should return insets from native module when available', async () => {
|
|
36
|
+
// Arrange
|
|
37
|
+
const mockInsets = {top: 50, left: 10, bottom: 30, right: 10};
|
|
38
|
+
NativeModules.SafeAreaManager = {
|
|
39
|
+
getSafeAreaInsets: jest.fn().mockResolvedValue(mockInsets)
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
43
|
+
|
|
44
|
+
// Act
|
|
45
|
+
const result = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
46
|
+
|
|
47
|
+
// Assert
|
|
48
|
+
expect(result).toEqual(mockInsets);
|
|
49
|
+
expect(NativeModules.SafeAreaManager.getSafeAreaInsets).toHaveBeenCalled();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it.skip('should return cached insets on subsequent calls', async () => {
|
|
53
|
+
// Arrange
|
|
54
|
+
const mockInsets = {top: 44, left: 0, bottom: 34, right: 0};
|
|
55
|
+
NativeModules.SafeAreaManager = {
|
|
56
|
+
getSafeAreaInsets: jest.fn().mockResolvedValue(mockInsets)
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
60
|
+
|
|
61
|
+
// Act
|
|
62
|
+
const result1 = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
63
|
+
const result2 = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
64
|
+
|
|
65
|
+
// Assert
|
|
66
|
+
expect(result1).toEqual(mockInsets);
|
|
67
|
+
expect(result2).toEqual(mockInsets);
|
|
68
|
+
expect(NativeModules.SafeAreaManager.getSafeAreaInsets).toHaveBeenCalledTimes(1); // Should only call native once due to caching
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should handle native module errors gracefully', async () => {
|
|
72
|
+
// Arrange
|
|
73
|
+
const mockError = new Error('Native module error');
|
|
74
|
+
NativeModules.SafeAreaManager = {
|
|
75
|
+
getSafeAreaInsets: jest.fn().mockRejectedValue(mockError)
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
79
|
+
|
|
80
|
+
// Act
|
|
81
|
+
const result = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
82
|
+
|
|
83
|
+
// Assert
|
|
84
|
+
expect(result).toEqual({top: 47, left: 0, bottom: 34, right: 0}); // Should fallback to defaults
|
|
85
|
+
expect(console.warn).toHaveBeenCalledWith('SafeAreaInsetsManager: Failed to get initial insets:', mockError);
|
|
86
|
+
expect(console.warn).toHaveBeenCalledWith('SafeAreaInsetsManager: Failed to get native insets:', mockError);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should handle native module setup errors gracefully', async () => {
|
|
90
|
+
// Arrange
|
|
91
|
+
Object.defineProperty(NativeModules, 'SafeAreaManager', {
|
|
92
|
+
get: () => {
|
|
93
|
+
throw new Error('Setup error');
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
98
|
+
|
|
99
|
+
// Act
|
|
100
|
+
const result = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
101
|
+
|
|
102
|
+
// Assert
|
|
103
|
+
expect(result).toEqual({top: 47, left: 0, bottom: 34, right: 0}); // Should fallback to defaults
|
|
104
|
+
expect(console.warn).toHaveBeenCalledWith('SafeAreaInsetsManager: Failed to connect to native module:', expect.any(Error));
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should update insets when they change during the test', async () => {
|
|
108
|
+
// Arrange
|
|
109
|
+
const initialInsets = {top: 44, left: 0, bottom: 34, right: 0};
|
|
110
|
+
const updatedInsets = {top: 50, left: 0, bottom: 40, right: 0};
|
|
111
|
+
|
|
112
|
+
NativeModules.SafeAreaManager = {
|
|
113
|
+
// TODO: this will need to be changed when the we get caching to work in tests ("should return cached insets on subsequent calls")
|
|
114
|
+
// getSafeAreaInsets: jest.fn().mockResolvedValueOnce(initialInsets).mockResolvedValueOnce(updatedInsets)
|
|
115
|
+
getSafeAreaInsets: jest
|
|
116
|
+
.fn()
|
|
117
|
+
.mockResolvedValueOnce(initialInsets)
|
|
118
|
+
.mockResolvedValueOnce(initialInsets)
|
|
119
|
+
.mockResolvedValueOnce(updatedInsets)
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
123
|
+
|
|
124
|
+
// Act & Assert - Initial insets
|
|
125
|
+
const result1 = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
126
|
+
expect(result1).toEqual(initialInsets);
|
|
127
|
+
|
|
128
|
+
// Force refresh of insets
|
|
129
|
+
await SafeAreaInsetsManager.refreshSafeAreaInsets();
|
|
130
|
+
|
|
131
|
+
// Simulate insets change event from native side
|
|
132
|
+
DeviceEventEmitter.emit('SafeAreaInsetsDidChangeEvent', updatedInsets);
|
|
133
|
+
|
|
134
|
+
// Get insets again - should reflect the change
|
|
135
|
+
const result2 = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
136
|
+
expect(result2).toEqual(updatedInsets);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should notify delegates when insets change during the test', async () => {
|
|
140
|
+
// Arrange
|
|
141
|
+
const initialInsets = {top: 44, left: 0, bottom: 34, right: 0};
|
|
142
|
+
const updatedInsets = {top: 50, left: 0, bottom: 40, right: 0};
|
|
143
|
+
|
|
144
|
+
NativeModules.SafeAreaManager = {
|
|
145
|
+
getSafeAreaInsets: jest.fn().mockResolvedValue(initialInsets)
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
149
|
+
|
|
150
|
+
// Add a mock delegate
|
|
151
|
+
const mockDelegate = {
|
|
152
|
+
onSafeAreaInsetsDidChangeEvent: jest.fn()
|
|
153
|
+
};
|
|
154
|
+
SafeAreaInsetsManager.addSafeAreaChangedDelegate(mockDelegate);
|
|
155
|
+
|
|
156
|
+
// Act - Get initial insets
|
|
157
|
+
await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
158
|
+
|
|
159
|
+
// Simulate insets change event from native side
|
|
160
|
+
DeviceEventEmitter.emit('SafeAreaInsetsDidChangeEvent', updatedInsets);
|
|
161
|
+
|
|
162
|
+
// Assert - Delegate should be notified
|
|
163
|
+
expect(mockDelegate.onSafeAreaInsetsDidChangeEvent).toHaveBeenCalledWith(updatedInsets);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('should handle refreshSafeAreaInsets correctly', async () => {
|
|
167
|
+
// Arrange
|
|
168
|
+
const initialInsets = {top: 44, left: 0, bottom: 34, right: 0};
|
|
169
|
+
const refreshedInsets = {top: 48, left: 0, bottom: 36, right: 0};
|
|
170
|
+
|
|
171
|
+
NativeModules.SafeAreaManager = {
|
|
172
|
+
// TODO: this will need to be changed when the we get caching to work in tests ("should return cached insets on subsequent calls")
|
|
173
|
+
// getSafeAreaInsets: jest.fn().mockResolvedValueOnce(initialInsets).mockResolvedValueOnce(updatedInsets)
|
|
174
|
+
getSafeAreaInsets: jest
|
|
175
|
+
.fn()
|
|
176
|
+
.mockResolvedValueOnce(initialInsets)
|
|
177
|
+
.mockResolvedValueOnce(initialInsets)
|
|
178
|
+
.mockResolvedValueOnce(refreshedInsets)
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
182
|
+
|
|
183
|
+
// Act
|
|
184
|
+
const result1 = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
185
|
+
expect(result1).toEqual(initialInsets);
|
|
186
|
+
|
|
187
|
+
// Refresh insets
|
|
188
|
+
await SafeAreaInsetsManager.refreshSafeAreaInsets();
|
|
189
|
+
|
|
190
|
+
const result2 = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
191
|
+
|
|
192
|
+
// Assert
|
|
193
|
+
expect(result2).toEqual(refreshedInsets);
|
|
194
|
+
// TODO: this will need to be changed when the we get caching to work in tests ("should return cached insets on subsequent calls")
|
|
195
|
+
expect(NativeModules.SafeAreaManager.getSafeAreaInsets).toHaveBeenCalledTimes(3);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('should not notify delegates when insets remain the same after refresh', async () => {
|
|
199
|
+
// Arrange
|
|
200
|
+
const sameInsets = {top: 44, left: 0, bottom: 34, right: 0};
|
|
201
|
+
|
|
202
|
+
NativeModules.SafeAreaManager = {
|
|
203
|
+
getSafeAreaInsets: jest.fn().mockResolvedValue(sameInsets)
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
207
|
+
|
|
208
|
+
// Add a mock delegate
|
|
209
|
+
const mockDelegate = {
|
|
210
|
+
onSafeAreaInsetsDidChangeEvent: jest.fn()
|
|
211
|
+
};
|
|
212
|
+
SafeAreaInsetsManager.addSafeAreaChangedDelegate(mockDelegate);
|
|
213
|
+
|
|
214
|
+
// Act
|
|
215
|
+
await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
216
|
+
await SafeAreaInsetsManager.refreshSafeAreaInsets();
|
|
217
|
+
|
|
218
|
+
// TODO: this will need to be changed when the we get caching to work in tests ("should return cached insets on subsequent calls")
|
|
219
|
+
expect(NativeModules.SafeAreaManager.getSafeAreaInsets).toHaveBeenCalledTimes(3);
|
|
220
|
+
|
|
221
|
+
// Assert - Delegate should not be notified since insets didn't change
|
|
222
|
+
expect(mockDelegate.onSafeAreaInsetsDidChangeEvent).not.toHaveBeenCalled();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('should return default insets when native getSafeAreaInsets returns null', async () => {
|
|
226
|
+
// Arrange
|
|
227
|
+
NativeModules.SafeAreaManager = {
|
|
228
|
+
getSafeAreaInsets: jest.fn().mockResolvedValue(null)
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
232
|
+
|
|
233
|
+
// Act
|
|
234
|
+
const result = await SafeAreaInsetsManager.getSafeAreaInsets();
|
|
235
|
+
|
|
236
|
+
// Assert
|
|
237
|
+
expect(result).toEqual({top: 47, left: 0, bottom: 34, right: 0});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('should properly manage delegate lifecycle', async () => {
|
|
241
|
+
// Arrange
|
|
242
|
+
NativeModules.SafeAreaManager = {
|
|
243
|
+
getSafeAreaInsets: jest.fn().mockResolvedValue({top: 44, left: 0, bottom: 34, right: 0})
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
|
|
247
|
+
|
|
248
|
+
const mockDelegate1 = {
|
|
249
|
+
onSafeAreaInsetsDidChangeEvent: jest.fn()
|
|
250
|
+
};
|
|
251
|
+
const mockDelegate2 = {
|
|
252
|
+
onSafeAreaInsetsDidChangeEvent: jest.fn()
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
// Act
|
|
256
|
+
SafeAreaInsetsManager.addSafeAreaChangedDelegate(mockDelegate1);
|
|
257
|
+
SafeAreaInsetsManager.addSafeAreaChangedDelegate(mockDelegate2);
|
|
258
|
+
|
|
259
|
+
// Remove one delegate
|
|
260
|
+
SafeAreaInsetsManager.removeSafeAreaChangedDelegate(mockDelegate1);
|
|
261
|
+
|
|
262
|
+
// Trigger notification
|
|
263
|
+
const newInsets = {top: 50, left: 0, bottom: 40, right: 0};
|
|
264
|
+
SafeAreaInsetsManager.notifyDelegates(newInsets);
|
|
265
|
+
|
|
266
|
+
// Assert
|
|
267
|
+
expect(mockDelegate1.onSafeAreaInsetsDidChangeEvent).not.toHaveBeenCalled();
|
|
268
|
+
expect(mockDelegate2.onSafeAreaInsetsDidChangeEvent).toHaveBeenCalledWith(newInsets);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
});
|
package/lib/package.json
CHANGED
package/package.json
CHANGED
package/src/commons/Constants.js
CHANGED
|
@@ -24,16 +24,8 @@ function setStatusBarHeight() {
|
|
|
24
24
|
const {
|
|
25
25
|
StatusBarManager
|
|
26
26
|
} = NativeModules;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
// override guesstimate height with the actual height from StatusBarManager
|
|
31
|
-
StatusBarManager.getHeight(data => statusBarHeight = data.height);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.warn('Constants: StatusBarManager.getHeight not available in new architecture, using fallback');
|
|
34
|
-
// Keep the fallback height we already set above
|
|
35
|
-
}
|
|
36
|
-
}
|
|
27
|
+
// override guesstimate height with the actual height from StatusBarManager
|
|
28
|
+
statusBarHeight = (StatusBar.currentHeight ?? StatusBarManager?.getConstants?.()?.HEIGHT) || 0;
|
|
37
29
|
}
|
|
38
30
|
function getAspectRatio() {
|
|
39
31
|
return screenWidth < screenHeight ? screenHeight / screenWidth : screenWidth / screenHeight;
|
|
@@ -40,6 +40,11 @@ export interface ModalProps extends RNModalProps {
|
|
|
40
40
|
* Send additional props to the KeyboardAvoidingView (iOS only)
|
|
41
41
|
*/
|
|
42
42
|
keyboardAvoidingViewProps?: KeyboardAvoidingViewProps;
|
|
43
|
+
/**
|
|
44
|
+
* Fix RNModal's interaction with react-native-reanimated (Android only, default: true)
|
|
45
|
+
* See this https://github.com/software-mansion/react-native-reanimated/issues/6659#issuecomment-2704931585
|
|
46
|
+
*/
|
|
47
|
+
fixReanimatedInteraction?: boolean;
|
|
43
48
|
}
|
|
44
49
|
/**
|
|
45
50
|
* @description: Component that present content on top of the invoking screen
|
|
@@ -55,6 +55,7 @@ class Modal extends Component {
|
|
|
55
55
|
}
|
|
56
56
|
render() {
|
|
57
57
|
const {
|
|
58
|
+
fixReanimatedInteraction = true,
|
|
58
59
|
blurView,
|
|
59
60
|
enableModalBlur,
|
|
60
61
|
visible,
|
|
@@ -76,16 +77,19 @@ class Modal extends Component {
|
|
|
76
77
|
style: [styles.fill, keyboardAvoidingViewProps?.style]
|
|
77
78
|
} : {};
|
|
78
79
|
const Container = blurView ? blurView : defaultContainer;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
const HackContainer = fixReanimatedInteraction && Constants.isAndroid ? View : React.Fragment;
|
|
81
|
+
return <HackContainer>
|
|
82
|
+
<RNModal visible={Boolean(visible)} {...others}>
|
|
83
|
+
<GestureContainer {...gestureContainerProps}>
|
|
84
|
+
<KeyboardAvoidingContainer {...keyboardAvoidingContainerProps}>
|
|
85
|
+
<Container style={styles.fill} blurType="light">
|
|
86
|
+
{this.renderTouchableOverlay()}
|
|
87
|
+
{this.props.children}
|
|
88
|
+
</Container>
|
|
89
|
+
</KeyboardAvoidingContainer>
|
|
90
|
+
</GestureContainer>
|
|
91
|
+
</RNModal>
|
|
92
|
+
</HackContainer>;
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
const styles = StyleSheet.create({
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"name": "keyboardAvoidingViewProps",
|
|
39
39
|
"type": "object",
|
|
40
40
|
"description": "Send additional props to the KeyboardAvoidingView (iOS only)"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "fixReanimatedInteraction",
|
|
44
|
+
"type": "boolean",
|
|
45
|
+
"description": "Fix RNModal's interaction with react-native-reanimated (Android only, default: true)"
|
|
41
46
|
}
|
|
42
47
|
],
|
|
43
48
|
"snippet": [
|
|
@@ -20,7 +20,7 @@ export let SegmentedControlPreset = /*#__PURE__*/function (SegmentedControlPrese
|
|
|
20
20
|
return SegmentedControlPreset;
|
|
21
21
|
}({});
|
|
22
22
|
export { SegmentedControlItemProps };
|
|
23
|
-
const
|
|
23
|
+
const noneAreUndefined = array => {
|
|
24
24
|
'worklet';
|
|
25
25
|
|
|
26
26
|
for (const item of array) {
|
|
@@ -99,7 +99,7 @@ const SegmentedControl = props => {
|
|
|
99
99
|
x,
|
|
100
100
|
width
|
|
101
101
|
};
|
|
102
|
-
if (segmentsDimensions.current.length === segments.length &&
|
|
102
|
+
if (segmentsDimensions.current.length === segments.length && noneAreUndefined(segmentsDimensions.current)) {
|
|
103
103
|
segmentsStyle.value = [...segmentsDimensions.current];
|
|
104
104
|
// shouldResetOnDimensionsOnNextLayout.current = true;// in case onLayout will be called again (orientation change etc.)
|
|
105
105
|
}
|
|
@@ -122,7 +122,7 @@ const SegmentedControl = props => {
|
|
|
122
122
|
const {
|
|
123
123
|
value: height
|
|
124
124
|
} = containerHeight;
|
|
125
|
-
if (height !== 0 && value.length === segments.length &&
|
|
125
|
+
if (height !== 0 && value.length === segments.length && noneAreUndefined(value)) {
|
|
126
126
|
const isFirstElementSelected = animatedSelectedIndex.value === 0;
|
|
127
127
|
const isLastElementSelected = animatedSelectedIndex.value === value.length - 1;
|
|
128
128
|
const isMiddleSelected = !isFirstElementSelected && !isLastElementSelected;
|