Skip to content

Commit d067629

Browse files
committed
Merge remote-tracking branch 'ms/master'
2 parents 4bca23c + 12f7265 commit d067629

File tree

5 files changed

+11
-158
lines changed

5 files changed

+11
-158
lines changed

Libraries/Components/Picker/PickerIOS.ios.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const React = require('react');
1717
const ReactNative = require('../../Renderer/shims/ReactNative');
1818
const StyleSheet = require('../../StyleSheet/StyleSheet');
1919
const View = require('../View/View');
20+
const Platform = require('../../Utilities/Platform'); // TODO(macOS ISS#2323203)
2021
const processColor = require('../../StyleSheet/processColor');
2122
const RCTPickerNativeComponent = require('./RCTPickerNativeComponent');
2223

@@ -159,7 +160,7 @@ const styles = StyleSheet.create({
159160
// The picker will conform to whatever width is given, but we do
160161
// have to set the component's height explicitly on the
161162
// surrounding view to ensure it gets rendered.
162-
height: 216,
163+
height: Platform.OS === 'ios' ? 216 : 25, // TODO(macOS ISS#2323203): NSComboBox in Storyboards is 25 points.
163164
},
164165
});
165166

Lines changed: 2 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2015-present, Facebook, Inc.
2+
* Copyright (c) Facebook, Inc. and its affiliates.
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -12,156 +12,5 @@
1212

1313
// TODO(macOS ISS#2323203)
1414

15-
'use strict';
16-
17-
const React = require('react');
18-
const ReactNative = require('../../Renderer/shims/ReactNative');
19-
const StyleSheet = require('../../StyleSheet/StyleSheet');
20-
const View = require('../View/View');
21-
const processColor = require('../../StyleSheet/processColor');
22-
const RCTPickerNativeComponent = require('./RCTPickerNativeComponent');
23-
24-
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
25-
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
26-
import type {ViewProps} from '../View/ViewPropTypes';
27-
import type {TextStyleProp} from '../../StyleSheet/StyleSheet';
28-
import type {NativeOrDynamicColorType} from '../../Color/NativeOrDynamicColorType'; // TODO(macOS ISS#2323203)
29-
30-
type PickerIOSChangeEvent = SyntheticEvent<
31-
$ReadOnly<{|
32-
newValue: number | string,
33-
newIndex: number,
34-
|}>,
35-
>;
36-
37-
type RCTPickerIOSItemType = $ReadOnly<{|
38-
label: ?Label,
39-
value: ?(number | string),
40-
textColor: ?(number | NativeOrDynamicColorType), // TODO(macOS ISS#2323203)
41-
|}>;
42-
43-
type RCTPickerIOSType = Class<
44-
ReactNative.NativeComponent<
45-
$ReadOnly<{|
46-
items: $ReadOnlyArray<RCTPickerIOSItemType>,
47-
onChange: (event: PickerIOSChangeEvent) => void,
48-
onResponderTerminationRequest: () => boolean,
49-
onStartShouldSetResponder: () => boolean,
50-
selectedIndex: number,
51-
style?: ?TextStyleProp,
52-
testID?: ?string,
53-
|}>,
54-
>,
55-
>;
56-
57-
type Label = Stringish | number;
58-
59-
type Props = $ReadOnly<{|
60-
...ViewProps,
61-
children: React.ChildrenArray<React.Element<typeof PickerIOSItem>>,
62-
itemStyle?: ?TextStyleProp,
63-
onChange?: ?(event: PickerIOSChangeEvent) => mixed,
64-
onValueChange?: ?(itemValue: string | number, itemIndex: number) => mixed,
65-
selectedValue: ?(number | string),
66-
|}>;
67-
68-
type State = {|
69-
selectedIndex: number,
70-
items: $ReadOnlyArray<RCTPickerIOSItemType>,
71-
|};
72-
73-
type ItemProps = $ReadOnly<{|
74-
label: ?Label,
75-
value?: ?(number | string),
76-
color?: ?ColorValue,
77-
|}>;
78-
79-
const PickerIOSItem = (props: ItemProps) => {
80-
return null;
81-
};
82-
83-
class PickerIOS extends React.Component<Props, State> {
84-
_picker: ?React.ElementRef<RCTPickerIOSType> = null;
85-
86-
state = {
87-
selectedIndex: 0,
88-
items: [],
89-
};
90-
91-
static Item = PickerIOSItem;
92-
93-
static getDerivedStateFromProps(props: Props): State {
94-
let selectedIndex = 0;
95-
const items = [];
96-
React.Children.toArray(props.children)
97-
.filter(child => child !== null)
98-
.forEach(function(child, index) {
99-
if (child.props.value === props.selectedValue) {
100-
selectedIndex = index;
101-
}
102-
items.push({
103-
value: child.props.value,
104-
label: child.props.label,
105-
textColor: processColor(child.props.color),
106-
});
107-
});
108-
return {selectedIndex, items};
109-
}
110-
111-
render() {
112-
return (
113-
<View style={this.props.style}>
114-
<RCTPickerNativeComponent
115-
ref={picker => {
116-
this._picker = picker;
117-
}}
118-
testID={this.props.testID}
119-
style={[styles.pickerIOS, this.props.itemStyle]}
120-
items={this.state.items}
121-
selectedIndex={this.state.selectedIndex}
122-
onChange={this._onChange}
123-
onStartShouldSetResponder={() => true}
124-
onResponderTerminationRequest={() => false}
125-
/>
126-
</View>
127-
);
128-
}
129-
130-
_onChange = event => {
131-
if (this.props.onChange) {
132-
this.props.onChange(event);
133-
}
134-
if (this.props.onValueChange) {
135-
this.props.onValueChange(
136-
event.nativeEvent.newValue,
137-
event.nativeEvent.newIndex,
138-
);
139-
}
140-
141-
// The picker is a controlled component. This means we expect the
142-
// on*Change handlers to be in charge of updating our
143-
// `selectedValue` prop. That way they can also
144-
// disallow/undo/mutate the selection of certain values. In other
145-
// words, the embedder of this component should be the source of
146-
// truth, not the native component.
147-
if (
148-
this._picker &&
149-
this.state.selectedIndex !== event.nativeEvent.newIndex
150-
) {
151-
this._picker.setNativeProps({
152-
selectedIndex: this.state.selectedIndex,
153-
});
154-
}
155-
};
156-
}
157-
158-
const styles = StyleSheet.create({
159-
pickerIOS: {
160-
// The picker will conform to whatever width is given, but we do
161-
// have to set the component's height explicitly on the
162-
// surrounding view to ensure it gets rendered.
163-
height: 216,
164-
},
165-
});
166-
15+
const PickerIOS = require('./PickerIOS.ios');
16716
module.exports = PickerIOS;

local-cli/generator-macos/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,11 @@ function installDependencies(options) {
134134

135135
// Patch package.json to have start:macos
136136
const projectPackageJsonPath = path.join(cwd, 'package.json');
137+
/** @type {{ scripts?: {} }} */
137138
const projectPackageJson = JSON.parse(fs.readFileSync(projectPackageJsonPath, { encoding: 'UTF8' }));
138-
projectPackageJson.scripts['start:macos'] = 'node node_modules/react-native-macos/local-cli/cli.js start --use-react-native-macos';
139+
const scripts = projectPackageJson.scripts || {};
140+
scripts['start:macos'] = 'node node_modules/react-native-macos/local-cli/cli.js start --use-react-native-macos';
141+
projectPackageJson.scripts = scripts;
139142
fs.writeFileSync(projectPackageJsonPath, JSON.stringify(projectPackageJson, null, 2));
140143

141144
// Install dependencies using correct package manager

local-cli/generator-macos/templates/macos/Podfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
1+
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
22

33
abstract_target 'Shared' do
4-
# use_native_modules!
4+
use_native_modules!
55

66
pod 'React', :path => "../node_modules/react-native-macos/"
77
pod 'React-Core', :path => "../node_modules/react-native-macos/React"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native",
3-
"version": "0.60.0-microsoft.73",
3+
"version": "0.60.0-microsoft.75",
44
"description": "[Microsoft Fork] A framework for building native apps using React",
55
"license": "MIT",
66
"repository": {

0 commit comments

Comments
 (0)