@office-iss/react-native-win32 0.0.0-canary.256 → 0.0.0-canary.258
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/.flowconfig +4 -2
- package/CHANGELOG.json +79 -1
- package/CHANGELOG.md +32 -8
- package/Libraries/Components/ScrollView/ScrollView.js +124 -165
- package/Libraries/Core/InitializeCore.js +2 -0
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -1
- package/Libraries/Core/setUpGlobals.js +1 -0
- package/Libraries/Core/setUpTimers.js +19 -0
- package/Libraries/LogBox/Data/LogBoxData.js +39 -4
- package/Libraries/LogBox/Data/LogBoxLog.js +5 -2
- package/Libraries/LogBox/Data/parseLogBoxLog.js +22 -1
- package/Libraries/LogBox/LogBox.js +29 -12
- package/Libraries/LogBox/LogBoxNotificationContainer.js +4 -0
- package/Libraries/LogBox/UI/LogBoxInspector.js +8 -70
- package/Libraries/LogBox/UI/LogBoxInspectorBody.js +87 -0
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +6 -42
- package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +58 -0
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +25 -74
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +27 -80
- package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +76 -0
- package/Libraries/LogBox/UI/LogBoxNotification.js +13 -152
- package/Libraries/LogBox/UI/LogBoxNotificationCountBadge.js +63 -0
- package/Libraries/LogBox/UI/LogBoxNotificationDismissButton.js +67 -0
- package/Libraries/LogBox/UI/LogBoxNotificationMessage.js +57 -0
- package/Libraries/ReactNative/AppContainer-dev.js +1 -5
- package/Libraries/ReactNative/AppContainer-prod.js +1 -5
- package/Libraries/ReactNative/AppContainer.js +0 -1
- package/Libraries/ReactNative/AppRegistry.js +0 -6
- package/Libraries/ReactNative/renderApplication.js +0 -2
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +15690 -26405
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +2675 -1630
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +2945 -1682
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +16141 -27018
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +2723 -1666
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +2984 -1737
- package/Libraries/Share/Share.d.ts +16 -10
- package/Libraries/Share/Share.js +14 -15
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +19 -0
- package/Libraries/StyleSheet/StyleSheetTypes.js +19 -1
- package/Libraries/StyleSheet/processFilter.js +214 -39
- package/Libraries/Text/Text.js +42 -22
- package/Libraries/Text/Text.win32.js +42 -22
- package/Libraries/Text/TextNativeComponent.js +1 -1
- package/Libraries/Text/TextNativeComponent.win32.js +1 -1
- package/Libraries/Text/TextOptimized.js +538 -0
- package/Libraries/Utilities/ReactNativeTestTools.js +7 -24
- package/Libraries/__tests__/ButtonWin32-test.js +7 -6
- package/Libraries/promiseRejectionTrackingOptions.js +1 -0
- package/index.js +1 -0
- package/index.win32.js +1 -0
- package/jest/mockComponent.js +4 -1
- package/jest/renderer.js +25 -14
- package/jest/setup.js +5 -0
- package/overrides.json +6 -6
- package/package.json +26 -26
- package/src/private/core/components/HScrollViewNativeComponents.js +55 -0
- package/src/private/core/components/VScrollViewNativeComponents.js +47 -0
- package/src/private/core/components/useSyncOnScroll.js +48 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +12 -1
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -1
- package/src/private/specs/modules/NativeDevSettings.js +1 -0
- package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
- package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +34 -0
|
@@ -8,35 +8,49 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {
|
|
11
|
+
import type {ViewProps} from '../../Components/View/ViewPropTypes';
|
|
12
12
|
import type {LogLevel} from '../Data/LogBoxLog';
|
|
13
13
|
|
|
14
|
-
import
|
|
14
|
+
import SafeAreaView from '../../Components/SafeAreaView/SafeAreaView';
|
|
15
15
|
import View from '../../Components/View/View';
|
|
16
|
-
import Image from '../../Image/Image';
|
|
17
16
|
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
18
17
|
import Text from '../../Text/Text';
|
|
19
18
|
import Platform from '../../Utilities/Platform';
|
|
20
|
-
import
|
|
19
|
+
import LogBoxInspectorHeaderButton from './LogBoxInspectorHeaderButton';
|
|
21
20
|
import * as LogBoxStyle from './LogBoxStyle';
|
|
22
21
|
import * as React from 'react';
|
|
23
|
-
|
|
22
|
+
|
|
23
|
+
type Props = $ReadOnly<{
|
|
24
24
|
onSelectIndex: (selectedIndex: number) => void,
|
|
25
25
|
selectedIndex: number,
|
|
26
26
|
total: number,
|
|
27
27
|
level: LogLevel,
|
|
28
|
-
|
|
28
|
+
}>;
|
|
29
|
+
|
|
30
|
+
const LogBoxInspectorHeaderSafeArea: React.AbstractComponent<ViewProps> =
|
|
31
|
+
Platform.OS === 'android'
|
|
32
|
+
? function LogBoxInspectorHeaderSafeArea(props) {
|
|
33
|
+
// NOTE: Inline the import of `StatusBar` so that initializing this module
|
|
34
|
+
// does not require initializing a TurboModule (and main thread one, too).
|
|
35
|
+
const {currentHeight} = require('../../Components/StatusBar/StatusBar');
|
|
36
|
+
const style = StyleSheet.compose(
|
|
37
|
+
{paddingTop: currentHeight},
|
|
38
|
+
props.style,
|
|
39
|
+
);
|
|
40
|
+
return <View {...props} style={style} />;
|
|
41
|
+
}
|
|
42
|
+
: SafeAreaView;
|
|
29
43
|
|
|
30
|
-
function LogBoxInspectorHeader(props: Props): React.Node {
|
|
44
|
+
export default function LogBoxInspectorHeader(props: Props): React.Node {
|
|
31
45
|
if (props.level === 'syntax') {
|
|
32
46
|
return (
|
|
33
|
-
<
|
|
47
|
+
<LogBoxInspectorHeaderSafeArea style={styles[props.level]}>
|
|
34
48
|
<View style={styles.header}>
|
|
35
49
|
<View style={styles.title}>
|
|
36
50
|
<Text style={styles.titleText}>Failed to compile</Text>
|
|
37
51
|
</View>
|
|
38
52
|
</View>
|
|
39
|
-
</
|
|
53
|
+
</LogBoxInspectorHeaderSafeArea>
|
|
40
54
|
);
|
|
41
55
|
}
|
|
42
56
|
|
|
@@ -48,7 +62,7 @@ function LogBoxInspectorHeader(props: Props): React.Node {
|
|
|
48
62
|
const titleText = `Log ${props.selectedIndex + 1} of ${props.total}`;
|
|
49
63
|
|
|
50
64
|
return (
|
|
51
|
-
<
|
|
65
|
+
<LogBoxInspectorHeaderSafeArea style={styles[props.level]}>
|
|
52
66
|
<View style={styles.header}>
|
|
53
67
|
<LogBoxInspectorHeaderButton
|
|
54
68
|
disabled={props.total <= 1}
|
|
@@ -66,68 +80,10 @@ function LogBoxInspectorHeader(props: Props): React.Node {
|
|
|
66
80
|
onPress={() => props.onSelectIndex(nextIndex)}
|
|
67
81
|
/>
|
|
68
82
|
</View>
|
|
69
|
-
</
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const backgroundForLevel = (level: LogLevel) =>
|
|
74
|
-
({
|
|
75
|
-
warn: {
|
|
76
|
-
default: 'transparent',
|
|
77
|
-
pressed: LogBoxStyle.getWarningDarkColor(),
|
|
78
|
-
},
|
|
79
|
-
error: {
|
|
80
|
-
default: 'transparent',
|
|
81
|
-
pressed: LogBoxStyle.getErrorDarkColor(),
|
|
82
|
-
},
|
|
83
|
-
fatal: {
|
|
84
|
-
default: 'transparent',
|
|
85
|
-
pressed: LogBoxStyle.getFatalDarkColor(),
|
|
86
|
-
},
|
|
87
|
-
syntax: {
|
|
88
|
-
default: 'transparent',
|
|
89
|
-
pressed: LogBoxStyle.getFatalDarkColor(),
|
|
90
|
-
},
|
|
91
|
-
})[level];
|
|
92
|
-
|
|
93
|
-
function LogBoxInspectorHeaderButton(
|
|
94
|
-
props: $ReadOnly<{|
|
|
95
|
-
disabled: boolean,
|
|
96
|
-
image: ImageSource,
|
|
97
|
-
level: LogLevel,
|
|
98
|
-
onPress?: ?() => void,
|
|
99
|
-
|}>,
|
|
100
|
-
): React.Node {
|
|
101
|
-
return (
|
|
102
|
-
<LogBoxButton
|
|
103
|
-
backgroundColor={backgroundForLevel(props.level)}
|
|
104
|
-
onPress={props.disabled ? null : props.onPress}
|
|
105
|
-
style={headerStyles.button}>
|
|
106
|
-
{props.disabled ? null : (
|
|
107
|
-
<Image source={props.image} style={headerStyles.buttonImage} />
|
|
108
|
-
)}
|
|
109
|
-
</LogBoxButton>
|
|
83
|
+
</LogBoxInspectorHeaderSafeArea>
|
|
110
84
|
);
|
|
111
85
|
}
|
|
112
86
|
|
|
113
|
-
const headerStyles = StyleSheet.create({
|
|
114
|
-
button: {
|
|
115
|
-
alignItems: 'center',
|
|
116
|
-
aspectRatio: 1,
|
|
117
|
-
justifyContent: 'center',
|
|
118
|
-
marginTop: 5,
|
|
119
|
-
marginRight: 6,
|
|
120
|
-
marginLeft: 6,
|
|
121
|
-
marginBottom: -8,
|
|
122
|
-
borderRadius: 3,
|
|
123
|
-
},
|
|
124
|
-
buttonImage: {
|
|
125
|
-
height: 14,
|
|
126
|
-
width: 8,
|
|
127
|
-
tintColor: LogBoxStyle.getTextColor(),
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
|
|
131
87
|
const styles = StyleSheet.create({
|
|
132
88
|
syntax: {
|
|
133
89
|
backgroundColor: LogBoxStyle.getFatalColor(),
|
|
@@ -160,9 +116,4 @@ const styles = StyleSheet.create({
|
|
|
160
116
|
includeFontPadding: false,
|
|
161
117
|
lineHeight: 20,
|
|
162
118
|
},
|
|
163
|
-
safeArea: {
|
|
164
|
-
paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 40,
|
|
165
|
-
},
|
|
166
119
|
});
|
|
167
|
-
|
|
168
|
-
export default LogBoxInspectorHeader;
|
|
@@ -10,33 +10,49 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
import type {ViewProps} from '../../Components/View/ViewPropTypes';
|
|
13
14
|
import type {LogLevel} from '../Data/LogBoxLog';
|
|
14
15
|
|
|
15
|
-
import
|
|
16
|
+
import SafeAreaView from '../../Components/SafeAreaView/SafeAreaView';
|
|
16
17
|
import View from '../../Components/View/View';
|
|
17
18
|
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
18
19
|
import Text from '../../Text/Text';
|
|
19
20
|
import Platform from '../../Utilities/Platform';
|
|
20
|
-
import
|
|
21
|
+
import LogBoxInspectorHeaderButton from './LogBoxInspectorHeaderButton';
|
|
21
22
|
import * as LogBoxStyle from './LogBoxStyle';
|
|
22
23
|
import * as React from 'react';
|
|
23
|
-
|
|
24
|
+
|
|
25
|
+
type Props = $ReadOnly<{
|
|
24
26
|
onSelectIndex: (selectedIndex: number) => void,
|
|
25
27
|
selectedIndex: number,
|
|
26
28
|
total: number,
|
|
27
29
|
level: LogLevel,
|
|
28
|
-
|
|
30
|
+
}>;
|
|
31
|
+
|
|
32
|
+
const LogBoxInspectorHeaderSafeArea: React.AbstractComponent<ViewProps> =
|
|
33
|
+
Platform.OS === 'android'
|
|
34
|
+
? function LogBoxInspectorHeaderSafeArea(props) {
|
|
35
|
+
// NOTE: Inline the import of `StatusBar` so that initializing this module
|
|
36
|
+
// does not require initializing a TurboModule (and main thread one, too).
|
|
37
|
+
const {currentHeight} = require('../../Components/StatusBar/StatusBar');
|
|
38
|
+
const style = StyleSheet.compose(
|
|
39
|
+
{paddingTop: currentHeight},
|
|
40
|
+
props.style,
|
|
41
|
+
);
|
|
42
|
+
return <View {...props} style={style} />;
|
|
43
|
+
}
|
|
44
|
+
: SafeAreaView;
|
|
29
45
|
|
|
30
|
-
function LogBoxInspectorHeader(props: Props): React.Node {
|
|
46
|
+
export default function LogBoxInspectorHeader(props: Props): React.Node {
|
|
31
47
|
if (props.level === 'syntax') {
|
|
32
48
|
return (
|
|
33
|
-
<
|
|
49
|
+
<LogBoxInspectorHeaderSafeArea style={styles[props.level]}>
|
|
34
50
|
<View style={styles.header}>
|
|
35
51
|
<View style={styles.title}>
|
|
36
52
|
<Text style={styles.titleText}>Failed to compile</Text>
|
|
37
53
|
</View>
|
|
38
54
|
</View>
|
|
39
|
-
</
|
|
55
|
+
</LogBoxInspectorHeaderSafeArea>
|
|
40
56
|
);
|
|
41
57
|
}
|
|
42
58
|
|
|
@@ -48,12 +64,12 @@ function LogBoxInspectorHeader(props: Props): React.Node {
|
|
|
48
64
|
const titleText = `Log ${props.selectedIndex + 1} of ${props.total}`;
|
|
49
65
|
|
|
50
66
|
return (
|
|
51
|
-
<
|
|
67
|
+
<LogBoxInspectorHeaderSafeArea style={styles[props.level]}>
|
|
52
68
|
<View style={styles.header}>
|
|
53
69
|
<LogBoxInspectorHeaderButton
|
|
54
70
|
disabled={props.total <= 1}
|
|
55
71
|
level={props.level}
|
|
56
|
-
image={'←'}
|
|
72
|
+
image={new String('←')}
|
|
57
73
|
onPress={() => props.onSelectIndex(prevIndex)}
|
|
58
74
|
/>
|
|
59
75
|
<View style={styles.title}>
|
|
@@ -62,78 +78,14 @@ function LogBoxInspectorHeader(props: Props): React.Node {
|
|
|
62
78
|
<LogBoxInspectorHeaderButton
|
|
63
79
|
disabled={props.total <= 1}
|
|
64
80
|
level={props.level}
|
|
65
|
-
image={'→'}
|
|
81
|
+
image={new String('→')}
|
|
66
82
|
onPress={() => props.onSelectIndex(nextIndex)}
|
|
67
83
|
/>
|
|
68
84
|
</View>
|
|
69
|
-
</
|
|
85
|
+
</LogBoxInspectorHeaderSafeArea>
|
|
70
86
|
);
|
|
71
87
|
}
|
|
72
88
|
|
|
73
|
-
const backgroundForLevel = (level: LogLevel) =>
|
|
74
|
-
({
|
|
75
|
-
warn: {
|
|
76
|
-
default: 'transparent',
|
|
77
|
-
pressed: LogBoxStyle.getWarningDarkColor(),
|
|
78
|
-
},
|
|
79
|
-
error: {
|
|
80
|
-
default: 'transparent',
|
|
81
|
-
pressed: LogBoxStyle.getErrorDarkColor(),
|
|
82
|
-
},
|
|
83
|
-
fatal: {
|
|
84
|
-
default: 'transparent',
|
|
85
|
-
pressed: LogBoxStyle.getFatalDarkColor(),
|
|
86
|
-
},
|
|
87
|
-
syntax: {
|
|
88
|
-
default: 'transparent',
|
|
89
|
-
pressed: LogBoxStyle.getFatalDarkColor(),
|
|
90
|
-
},
|
|
91
|
-
})[level];
|
|
92
|
-
|
|
93
|
-
function LogBoxInspectorHeaderButton(
|
|
94
|
-
props: $ReadOnly<{|
|
|
95
|
-
disabled: boolean,
|
|
96
|
-
image: string,
|
|
97
|
-
level: LogLevel,
|
|
98
|
-
onPress?: ?() => void,
|
|
99
|
-
|}>,
|
|
100
|
-
): React.Node {
|
|
101
|
-
return (
|
|
102
|
-
<LogBoxButton
|
|
103
|
-
backgroundColor={backgroundForLevel(props.level)}
|
|
104
|
-
onPress={props.disabled ? null : props.onPress}
|
|
105
|
-
style={styles.title}>
|
|
106
|
-
{props.disabled ? null : (
|
|
107
|
-
<Text style={[styles.titleText, headerStyles.buttonText]}>
|
|
108
|
-
{props.image}
|
|
109
|
-
</Text>
|
|
110
|
-
)}
|
|
111
|
-
</LogBoxButton>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const headerStyles = StyleSheet.create({
|
|
116
|
-
button: {
|
|
117
|
-
alignItems: 'center',
|
|
118
|
-
aspectRatio: 1,
|
|
119
|
-
justifyContent: 'center',
|
|
120
|
-
marginTop: 0,
|
|
121
|
-
marginRight: 6,
|
|
122
|
-
marginLeft: 6,
|
|
123
|
-
marginBottom: 0,
|
|
124
|
-
borderRadius: 3,
|
|
125
|
-
height: 50,
|
|
126
|
-
width: 50,
|
|
127
|
-
},
|
|
128
|
-
buttonText: {
|
|
129
|
-
fontSize: 30,
|
|
130
|
-
},
|
|
131
|
-
buttonImage: {
|
|
132
|
-
fontSize: 20,
|
|
133
|
-
color: LogBoxStyle.getTextColor(),
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
|
|
137
89
|
const styles = StyleSheet.create({
|
|
138
90
|
syntax: {
|
|
139
91
|
backgroundColor: LogBoxStyle.getFatalColor(),
|
|
@@ -169,9 +121,4 @@ const styles = StyleSheet.create({
|
|
|
169
121
|
includeFontPadding: false,
|
|
170
122
|
lineHeight: 20,
|
|
171
123
|
},
|
|
172
|
-
safeArea: {
|
|
173
|
-
paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 40,
|
|
174
|
-
},
|
|
175
124
|
});
|
|
176
|
-
|
|
177
|
-
export default LogBoxInspectorHeader;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {ImageSource} from '../../Image/ImageSource';
|
|
12
|
+
import type {LogLevel} from '../Data/LogBoxLog';
|
|
13
|
+
|
|
14
|
+
import Image from '../../Image/Image';
|
|
15
|
+
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
16
|
+
import LogBoxButton from './LogBoxButton';
|
|
17
|
+
import * as LogBoxStyle from './LogBoxStyle';
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
|
|
20
|
+
const backgroundForLevel = (level: LogLevel) =>
|
|
21
|
+
({
|
|
22
|
+
warn: {
|
|
23
|
+
default: 'transparent',
|
|
24
|
+
pressed: LogBoxStyle.getWarningDarkColor(),
|
|
25
|
+
},
|
|
26
|
+
error: {
|
|
27
|
+
default: 'transparent',
|
|
28
|
+
pressed: LogBoxStyle.getErrorDarkColor(),
|
|
29
|
+
},
|
|
30
|
+
fatal: {
|
|
31
|
+
default: 'transparent',
|
|
32
|
+
pressed: LogBoxStyle.getFatalDarkColor(),
|
|
33
|
+
},
|
|
34
|
+
syntax: {
|
|
35
|
+
default: 'transparent',
|
|
36
|
+
pressed: LogBoxStyle.getFatalDarkColor(),
|
|
37
|
+
},
|
|
38
|
+
})[level];
|
|
39
|
+
|
|
40
|
+
export default function LogBoxInspectorHeaderButton(
|
|
41
|
+
props: $ReadOnly<{
|
|
42
|
+
disabled: boolean,
|
|
43
|
+
image: ImageSource,
|
|
44
|
+
level: LogLevel,
|
|
45
|
+
onPress?: ?() => void,
|
|
46
|
+
}>,
|
|
47
|
+
): React.Node {
|
|
48
|
+
return (
|
|
49
|
+
<LogBoxButton
|
|
50
|
+
backgroundColor={backgroundForLevel(props.level)}
|
|
51
|
+
onPress={props.disabled ? null : props.onPress}
|
|
52
|
+
style={styles.button}>
|
|
53
|
+
{props.disabled ? null : (
|
|
54
|
+
<Image source={props.image} style={styles.buttonImage} />
|
|
55
|
+
)}
|
|
56
|
+
</LogBoxButton>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const styles = StyleSheet.create({
|
|
61
|
+
button: {
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
aspectRatio: 1,
|
|
64
|
+
justifyContent: 'center',
|
|
65
|
+
marginTop: 5,
|
|
66
|
+
marginRight: 6,
|
|
67
|
+
marginLeft: 6,
|
|
68
|
+
marginBottom: -8,
|
|
69
|
+
borderRadius: 3,
|
|
70
|
+
},
|
|
71
|
+
buttonImage: {
|
|
72
|
+
height: 14,
|
|
73
|
+
width: 8,
|
|
74
|
+
tintColor: LogBoxStyle.getTextColor(),
|
|
75
|
+
},
|
|
76
|
+
});
|
|
@@ -8,18 +8,17 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {Message as MessageType} from '../Data/parseLogBoxLog';
|
|
12
|
-
|
|
13
11
|
import View from '../../Components/View/View';
|
|
14
|
-
import Image from '../../Image/Image';
|
|
15
12
|
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
16
|
-
import Text from '../../Text/Text';
|
|
17
13
|
import * as LogBoxData from '../Data/LogBoxData';
|
|
18
14
|
import LogBoxLog from '../Data/LogBoxLog';
|
|
19
15
|
import LogBoxButton from './LogBoxButton';
|
|
20
|
-
import
|
|
16
|
+
import LogBoxNotificationCountBadge from './LogBoxNotificationCountBadge';
|
|
17
|
+
import LogBoxNotificationDismissButton from './LogBoxNotificationDismissButton';
|
|
18
|
+
import LogBoxNotificationMessage from './LogBoxNotificationMessage';
|
|
21
19
|
import * as LogBoxStyle from './LogBoxStyle';
|
|
22
20
|
import * as React from 'react';
|
|
21
|
+
import {useEffect} from 'react';
|
|
23
22
|
|
|
24
23
|
type Props = $ReadOnly<{
|
|
25
24
|
log: LogBoxLog,
|
|
@@ -29,170 +28,34 @@ type Props = $ReadOnly<{
|
|
|
29
28
|
onPressDismiss: () => void,
|
|
30
29
|
}>;
|
|
31
30
|
|
|
32
|
-
function
|
|
31
|
+
export default function LogBoxNotification(props: Props): React.Node {
|
|
33
32
|
const {totalLogCount, level, log} = props;
|
|
34
33
|
|
|
35
34
|
// Eagerly symbolicate so the stack is available when pressing to inspect.
|
|
36
|
-
|
|
35
|
+
useEffect(() => {
|
|
37
36
|
LogBoxData.symbolicateLogLazy(log);
|
|
38
37
|
}, [log]);
|
|
39
38
|
|
|
40
39
|
return (
|
|
41
|
-
<View style={
|
|
40
|
+
<View style={styles.container}>
|
|
42
41
|
<LogBoxButton
|
|
43
42
|
onPress={props.onPressOpen}
|
|
44
|
-
style={
|
|
43
|
+
style={styles.press}
|
|
45
44
|
backgroundColor={{
|
|
46
45
|
default: LogBoxStyle.getBackgroundColor(1),
|
|
47
46
|
pressed: LogBoxStyle.getBackgroundColor(0.9),
|
|
48
47
|
}}>
|
|
49
|
-
<View style={
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
<
|
|
48
|
+
<View style={styles.content}>
|
|
49
|
+
<LogBoxNotificationCountBadge count={totalLogCount} level={level} />
|
|
50
|
+
<LogBoxNotificationMessage message={log.message} />
|
|
51
|
+
<LogBoxNotificationDismissButton onPress={props.onPressDismiss} />
|
|
53
52
|
</View>
|
|
54
53
|
</LogBoxButton>
|
|
55
54
|
</View>
|
|
56
55
|
);
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<View style={countStyles.outside}>
|
|
62
|
-
{/* $FlowFixMe[incompatible-type] (>=0.114.0) This suppression was added
|
|
63
|
-
* when fixing the type of `StyleSheet.create`. Remove this comment to
|
|
64
|
-
* see the error. */}
|
|
65
|
-
<View style={[countStyles.inside, countStyles[props.level]]}>
|
|
66
|
-
<Text style={countStyles.text}>
|
|
67
|
-
{props.count <= 1 ? '!' : props.count}
|
|
68
|
-
</Text>
|
|
69
|
-
</View>
|
|
70
|
-
</View>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function Message(props: {message: MessageType}) {
|
|
75
|
-
return (
|
|
76
|
-
<View style={messageStyles.container}>
|
|
77
|
-
<Text numberOfLines={1} style={messageStyles.text}>
|
|
78
|
-
{props.message && (
|
|
79
|
-
<LogBoxMessage
|
|
80
|
-
plaintext
|
|
81
|
-
message={props.message}
|
|
82
|
-
style={messageStyles.substitutionText}
|
|
83
|
-
/>
|
|
84
|
-
)}
|
|
85
|
-
</Text>
|
|
86
|
-
</View>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function DismissButton(props: {onPress: () => void}) {
|
|
91
|
-
return (
|
|
92
|
-
<View style={dismissStyles.container}>
|
|
93
|
-
<LogBoxButton
|
|
94
|
-
backgroundColor={{
|
|
95
|
-
default: LogBoxStyle.getTextColor(0.3),
|
|
96
|
-
pressed: LogBoxStyle.getTextColor(0.5),
|
|
97
|
-
}}
|
|
98
|
-
hitSlop={{
|
|
99
|
-
top: 12,
|
|
100
|
-
right: 10,
|
|
101
|
-
bottom: 12,
|
|
102
|
-
left: 10,
|
|
103
|
-
}}
|
|
104
|
-
onPress={props.onPress}
|
|
105
|
-
style={dismissStyles.press}>
|
|
106
|
-
<Image
|
|
107
|
-
source={require('./LogBoxImages/close.png')}
|
|
108
|
-
style={dismissStyles.image}
|
|
109
|
-
/>
|
|
110
|
-
</LogBoxButton>
|
|
111
|
-
</View>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const countStyles = StyleSheet.create({
|
|
116
|
-
warn: {
|
|
117
|
-
backgroundColor: LogBoxStyle.getWarningColor(1),
|
|
118
|
-
},
|
|
119
|
-
error: {
|
|
120
|
-
backgroundColor: LogBoxStyle.getErrorColor(1),
|
|
121
|
-
},
|
|
122
|
-
log: {
|
|
123
|
-
backgroundColor: LogBoxStyle.getLogColor(1),
|
|
124
|
-
},
|
|
125
|
-
outside: {
|
|
126
|
-
padding: 2,
|
|
127
|
-
borderRadius: 25,
|
|
128
|
-
backgroundColor: '#fff',
|
|
129
|
-
marginRight: 8,
|
|
130
|
-
},
|
|
131
|
-
inside: {
|
|
132
|
-
minWidth: 18,
|
|
133
|
-
paddingLeft: 4,
|
|
134
|
-
paddingRight: 4,
|
|
135
|
-
borderRadius: 25,
|
|
136
|
-
fontWeight: '600',
|
|
137
|
-
},
|
|
138
|
-
text: {
|
|
139
|
-
color: LogBoxStyle.getTextColor(1),
|
|
140
|
-
fontSize: 14,
|
|
141
|
-
lineHeight: 18,
|
|
142
|
-
textAlign: 'center',
|
|
143
|
-
fontWeight: '600',
|
|
144
|
-
textShadowColor: LogBoxStyle.getBackgroundColor(0.4),
|
|
145
|
-
textShadowOffset: {width: 0, height: 0},
|
|
146
|
-
textShadowRadius: 3,
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
const messageStyles = StyleSheet.create({
|
|
151
|
-
container: {
|
|
152
|
-
alignSelf: 'stretch',
|
|
153
|
-
flexGrow: 1,
|
|
154
|
-
flexShrink: 1,
|
|
155
|
-
flexBasis: 'auto',
|
|
156
|
-
borderLeftColor: LogBoxStyle.getTextColor(0.2),
|
|
157
|
-
borderLeftWidth: 1,
|
|
158
|
-
paddingLeft: 8,
|
|
159
|
-
},
|
|
160
|
-
text: {
|
|
161
|
-
color: LogBoxStyle.getTextColor(1),
|
|
162
|
-
flex: 1,
|
|
163
|
-
fontSize: 14,
|
|
164
|
-
lineHeight: 22,
|
|
165
|
-
},
|
|
166
|
-
substitutionText: {
|
|
167
|
-
color: LogBoxStyle.getTextColor(0.6),
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
const dismissStyles = StyleSheet.create({
|
|
172
|
-
container: {
|
|
173
|
-
alignSelf: 'center',
|
|
174
|
-
flexDirection: 'row',
|
|
175
|
-
flexGrow: 0,
|
|
176
|
-
flexShrink: 0,
|
|
177
|
-
flexBasis: 'auto',
|
|
178
|
-
marginLeft: 5,
|
|
179
|
-
},
|
|
180
|
-
press: {
|
|
181
|
-
height: 20,
|
|
182
|
-
width: 20,
|
|
183
|
-
borderRadius: 25,
|
|
184
|
-
alignSelf: 'flex-end',
|
|
185
|
-
alignItems: 'center',
|
|
186
|
-
justifyContent: 'center',
|
|
187
|
-
},
|
|
188
|
-
image: {
|
|
189
|
-
height: 8,
|
|
190
|
-
width: 8,
|
|
191
|
-
tintColor: LogBoxStyle.getBackgroundColor(1),
|
|
192
|
-
},
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
const toastStyles = StyleSheet.create({
|
|
58
|
+
const styles = StyleSheet.create({
|
|
196
59
|
container: {
|
|
197
60
|
height: 48,
|
|
198
61
|
position: 'relative',
|
|
@@ -218,5 +81,3 @@ const toastStyles = StyleSheet.create({
|
|
|
218
81
|
flexBasis: 'auto',
|
|
219
82
|
},
|
|
220
83
|
});
|
|
221
|
-
|
|
222
|
-
export default LogBoxLogNotification;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import View from '../../Components/View/View';
|
|
12
|
+
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
13
|
+
import Text from '../../Text/Text';
|
|
14
|
+
import * as LogBoxStyle from './LogBoxStyle';
|
|
15
|
+
import * as React from 'react';
|
|
16
|
+
|
|
17
|
+
export default function LogBoxNotificationCountBadge(props: {
|
|
18
|
+
count: number,
|
|
19
|
+
level: 'error' | 'warn',
|
|
20
|
+
}): React.Node {
|
|
21
|
+
return (
|
|
22
|
+
<View style={styles.outside}>
|
|
23
|
+
{/* $FlowFixMe[incompatible-type] (>=0.114.0) This suppression was added
|
|
24
|
+
* when fixing the type of `StyleSheet.create`. Remove this comment to
|
|
25
|
+
* see the error. */}
|
|
26
|
+
<View style={[styles.inside, styles[props.level]]}>
|
|
27
|
+
<Text style={styles.text}>{props.count <= 1 ? '!' : props.count}</Text>
|
|
28
|
+
</View>
|
|
29
|
+
</View>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const styles = StyleSheet.create({
|
|
34
|
+
warn: {
|
|
35
|
+
backgroundColor: LogBoxStyle.getWarningColor(1),
|
|
36
|
+
},
|
|
37
|
+
error: {
|
|
38
|
+
backgroundColor: LogBoxStyle.getErrorColor(1),
|
|
39
|
+
},
|
|
40
|
+
outside: {
|
|
41
|
+
padding: 2,
|
|
42
|
+
borderRadius: 25,
|
|
43
|
+
backgroundColor: '#fff',
|
|
44
|
+
marginRight: 8,
|
|
45
|
+
},
|
|
46
|
+
inside: {
|
|
47
|
+
minWidth: 18,
|
|
48
|
+
paddingLeft: 4,
|
|
49
|
+
paddingRight: 4,
|
|
50
|
+
borderRadius: 25,
|
|
51
|
+
fontWeight: '600',
|
|
52
|
+
},
|
|
53
|
+
text: {
|
|
54
|
+
color: LogBoxStyle.getTextColor(1),
|
|
55
|
+
fontSize: 14,
|
|
56
|
+
lineHeight: 18,
|
|
57
|
+
textAlign: 'center',
|
|
58
|
+
fontWeight: '600',
|
|
59
|
+
textShadowColor: LogBoxStyle.getBackgroundColor(0.4),
|
|
60
|
+
textShadowOffset: {width: 0, height: 0},
|
|
61
|
+
textShadowRadius: 3,
|
|
62
|
+
},
|
|
63
|
+
});
|