Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fixes to RNTester Xcode tests #6

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Libraries/Animated/AnimatedMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ const spring = function(
return {
...emptyAnimation,
start: (callback?: ?EndCallback): void => {
anyValue.setValue(config.toValue);
// TODO(macOS GH#774) - setValue can't handle AnimatedNodes
if (config.toValue instanceof AnimatedNode) {
anyValue.setValue(config.toValue.__getValue());
} else {
anyValue.setValue(config.toValue);
}
callback && callback({finished: true});
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,26 +716,28 @@ class AccessibilityActionsExample extends React.Component<{}> {
/>
</RNTesterBlock>

<RNTesterBlock title="Text with custom accessibility actions">
<Text
accessible={true}
accessibilityActions={[
{name: 'activate', label: 'activate label'},
{name: 'copy', label: 'copy label'},
]}
onAccessibilityAction={event => {
switch (event.nativeEvent.actionName) {
case 'activate':
Alert.alert('Alert', 'Activate accessiblity action');
break;
case 'copy':
Alert.alert('Alert', 'copy action success');
break;
}
}}>
Text
</Text>
</RNTesterBlock>
{/* TODO(macOS GH#774) - This doesn't work, see https://github.com/facebook/react-native/issues/32616
<RNTesterBlock title="Text with custom accessibility actions">
<Text
accessible={true}
accessibilityActions={[
{name: 'activate', label: 'activate label'},
{name: 'copy', label: 'copy label'},
]}
onAccessibilityAction={event => {
switch (event.nativeEvent.actionName) {
case 'activate':
Alert.alert('Alert', 'Activate accessiblity action');
break;
case 'copy':
Alert.alert('Alert', 'copy action success');
break;
}
}}>
Text
</Text>
</RNTesterBlock>
*/}
</View>
);
}
Expand Down Expand Up @@ -962,15 +964,22 @@ class EnabledExamples extends React.Component<{}> {
}
// [TODO(OSS Candidate ISS#2710739)
type DisplayOptionsStatusExampleState = {
highContrastEnabled: boolean,
invertColorsEnabled: boolean,
reduceMotionEnabled: boolean,
reduceTransparencyEnabled: boolean,
highContrastEnabled?: boolean,
invertColorsEnabled?: boolean,
reduceMotionEnabled?: boolean,
reduceTransparencyEnabled?: boolean,
};
class DisplayOptionsStatusExample extends React.Component<
{},
DisplayOptionsStatusExampleState,
> {
state: DisplayOptionsStatusExampleState = {
highContrastEnabled: undefined,
invertColorsEnabled: undefined,
reduceMotionEnabled: undefined,
reduceTransparencyEnabled: undefined,
};

componentDidMount() {
AccessibilityInfo.addEventListener(
'highContrastChanged',
Expand Down Expand Up @@ -1056,31 +1065,40 @@ class DisplayOptionsStatusExample extends React.Component<
});
};

// TODO(macOS GH#774) - slight refactoring to allow state to handle undefined values
_statusString = isEnabled => {
if (isEnabled !== undefined) {
return isEnabled ? 'enabled' : 'disabled';
} else {
return 'unknown';
}
};

render(): React.Node {
return (
<View>
<View>
<Text>
High contrast is{' '}
{this.state.highContrastEnabled ? 'enabled' : 'disabled'}.
{this._statusString(this.state.highContrastEnabled)}.
</Text>
</View>
<View>
<Text>
Invert colors is{' '}
{this.state.invertColorsEnabled ? 'enabled' : 'disabled'}.
{this._statusString(this.state.invertColorsEnabled)}.
</Text>
</View>
<View>
<Text>
Reduce motion is{' '}
{this.state.reduceMotionEnabled ? 'enabled' : 'disabled'}.
{this._statusString(this.state.reduceMotionEnabled)}.
</Text>
</View>
<View>
<Text>
Reduce transparency is{' '}
{this.state.reduceTransparencyEnabled ? 'enabled' : 'disabled'}.
{this._statusString(this.state.reduceTransparencyEnabled)}.
</Text>
</View>
</View>
Expand Down