Skip to content

Commit

Permalink
Merge branch 'master' into feature/line-break-strategy-ios
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 authored Jun 10, 2021
2 parents 3455aff + b3a715f commit 1450a82
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 17 deletions.
12 changes: 6 additions & 6 deletions Libraries/Components/Picker/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,24 @@ class Picker extends React.Component<PickerProps> {

static Item: typeof PickerItem = PickerItem;

static defaultProps: {|mode: $TEMPORARY$string<'dialog'>|} = {
mode: MODE_DIALOG,
};

render(): React.Node {
const {mode = MODE_DIALOG, children, ...rest} = this.props;

if (Platform.OS === 'ios') {
/* $FlowFixMe[prop-missing] (>=0.81.0 site=react_native_ios_fb) This
* suppression was added when renaming suppression sites. */
/* $FlowFixMe[incompatible-type] (>=0.81.0 site=react_native_ios_fb) This
* suppression was added when renaming suppression sites. */
return <PickerIOS {...this.props}>{this.props.children}</PickerIOS>;
return <PickerIOS {...rest}>{children}</PickerIOS>;
} else if (Platform.OS === 'android') {
return (
/* $FlowFixMe[incompatible-type] (>=0.81.0 site=react_native_android_fb) This
* suppression was added when renaming suppression sites. */
/* $FlowFixMe[prop-missing] (>=0.81.0 site=react_native_android_fb) This
* suppression was added when renaming suppression sites. */
<PickerAndroid {...this.props}>{this.props.children}</PickerAndroid>
<PickerAndroid mode={mode} {...rest}>
{children}
</PickerAndroid>
);
} else {
return <UnimplementedView />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ exports[`<Picker /> should render as expected: should deep render when not mocke

exports[`<Picker /> should render as expected: should shallow render as <Picker /> when mocked 1`] = `
<Picker
mode="dialog"
onValueChange={[MockFunction]}
selectedValue="foo"
>
Expand All @@ -81,7 +80,6 @@ exports[`<Picker /> should render as expected: should shallow render as <Picker

exports[`<Picker /> should render as expected: should shallow render as <Picker /> when not mocked 1`] = `
<Picker
mode="dialog"
onValueChange={[MockFunction]}
selectedValue="foo"
>
Expand Down
8 changes: 5 additions & 3 deletions Libraries/Components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import Platform from '../../Utilities/Platform';
import * as React from 'react';
import StyleSheet from '../../StyleSheet/StyleSheet';
import useMergeRefs from '../../Utilities/useMergeRefs';

import AndroidSwitchNativeComponent, {
Commands as AndroidSwitchCommands,
Expand Down Expand Up @@ -153,7 +154,8 @@ const SwitchWithForwardedRef: React.AbstractComponent<
const nativeSwitchRef = React.useRef<React.ElementRef<
typeof SwitchNativeComponent | typeof AndroidSwitchNativeComponent,
> | null>(null);
React.useImperativeHandle(forwardedRef, () => nativeSwitchRef.current);

const ref = useMergeRefs(nativeSwitchRef, forwardedRef);

const [native, setNative] = React.useState({value: null});

Expand Down Expand Up @@ -200,7 +202,7 @@ const SwitchWithForwardedRef: React.AbstractComponent<
onChange={handleChange}
onResponderTerminationRequest={returnsFalse}
onStartShouldSetResponder={returnsTrue}
ref={nativeSwitchRef}
ref={ref}
/>
);
} else {
Expand Down Expand Up @@ -232,7 +234,7 @@ const SwitchWithForwardedRef: React.AbstractComponent<
onChange={handleChange}
onResponderTerminationRequest={returnsFalse}
onStartShouldSetResponder={returnsTrue}
ref={nativeSwitchRef}
ref={ref}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,14 @@ private void onViewStateDeleted(ViewState viewState) {
viewState.mStateWrapper = null;
}

// Destroy EventEmitterWrapper immediately instead of waiting for Java GC.
// Notably, this is also required to ensure that the EventEmitterWrapper is deallocated
// before the JS VM is deallocated, since it holds onto a JSI::Pointer.
if (viewState.mEventEmitter != null) {
viewState.mEventEmitter.destroy();
viewState.mEventEmitter = null;
}

// For non-root views we notify viewmanager with {@link ViewManager#onDropInstance}
ViewManager viewManager = viewState.mViewManager;
if (!viewState.mIsRoot && viewManager != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public void setSnapToInterval(ReactHorizontalScrollView view, float snapToInterv
@ReactProp(name = "snapToOffsets")
public void setSnapToOffsets(
ReactHorizontalScrollView view, @Nullable ReadableArray snapToOffsets) {
if (snapToOffsets == null) {
view.setSnapOffsets(null);
return;
}

DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics();
List<Integer> offsets = new ArrayList<Integer>();
for (int i = 0; i < snapToOffsets.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public void setSnapToInterval(ReactScrollView view, float snapToInterval) {

@ReactProp(name = "snapToOffsets")
public void setSnapToOffsets(ReactScrollView view, @Nullable ReadableArray snapToOffsets) {
if (snapToOffsets == null) {
view.setSnapOffsets(null);
return;
}

DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics();
List<Integer> offsets = new ArrayList<Integer>();
for (int i = 0; i < snapToOffsets.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ void TextInputEventEmitter::onBlur(

void TextInputEventEmitter::onChange(
TextInputMetrics const &textInputMetrics) const {
dispatchTextInputEvent(
"change", textInputMetrics, EventPriority::SynchronousUnbatched);
dispatchTextInputEvent("change", textInputMetrics);
}

void TextInputEventEmitter::onChangeText(
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ buildscript {
mavenCentral()
}
dependencies {
val kotlin_version: String by project
classpath("com.android.tools.build:gradle:4.2.1")
classpath("de.undercouch:gradle-download-task:4.1.1")

classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ org.gradle.parallel=true

ANDROID_NDK_VERSION=20.1.5948944
android.useAndroidX=true
kotlin_version=1.4.21
1 change: 0 additions & 1 deletion packages/react-native-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
plugins {
`java-gradle-plugin`
`kotlin-dsl`
kotlin("jvm") version "1.4.20"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion scripts/.tests.env
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export AVD_ABI=x86
export ANDROID_DISABLE_AVD_TESTS=1

## IOS ##
export IOS_TARGET_OS="14.5"
export IOS_TARGET_OS="latest"
export IOS_DEVICE="iPhone 8"
export SDK_IOS="iphonesimulator"

Expand Down
1 change: 0 additions & 1 deletion template/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#000000</item>
</style>

</resources>

0 comments on commit 1450a82

Please sign in to comment.