react-native-macos/React/Views/RCTSlider.h

53 строки
1.6 KiB
C
Исходник Обычный вид История

/**
2019-03-28 23:44:57 +03:00
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
2019-03-01 21:09:07 +03:00
#import <React/RCTUIKit.h> // TODO(macOS ISS#2323203)
#import <React/RCTComponent.h>
2019-03-01 21:09:07 +03:00
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
@protocol RCTSliderDelegate;
#endif
#if !TARGET_OS_OSX // ]TODO(macOS ISS#2323203)
@interface RCTSlider : UISlider
2019-03-01 21:09:07 +03:00
#else // [TODO(macOS ISS#2323203)
@interface RCTSlider : NSSlider
#endif
#if TARGET_OS_OSX
@property (nonatomic, weak) id<RCTSliderDelegate> delegate;
@property (nonatomic, readonly) BOOL pressed;
@property (nonatomic, assign) float value;
@property (nonatomic, assign) float minimumValue;
@property (nonatomic, assign) float maximumValue;
@property (nonatomic, strong) NSColor *minimumTrackTintColor;
@property (nonatomic, strong) NSColor *maximumTrackTintColor;
- (void)setValue:(float)value animated:(BOOL)animated;
#endif // ]TODO(macOS ISS#2323203)
@property (nonatomic, copy) RCTBubblingEventBlock onValueChange;
Switch Slider onSlidingComplete event to a non-bubbling event on iOS to match Android Summary: ## Overview This diff switches the RCTSlider onSlidingComplete event on iOS from a bubbling event to a direct (non-bubbling) event to match the non-bubbling type on android. Note that in this case these seems like a bug. I will still explain the motivation and reasoning as this will come up in future diffs. ## Changelog [Slider][BREAKING] Switch Slider onSlidingComplete event to a non-bubbling event on iOS to match Android ## Motivation: The motivation here is that when we codgen the view configs, we'll need to unify all of the events and props across platforms for components that have the same name on iOS and Android. In this case, the view configs (below) conflict for onSlidingComplete. On iOS this is under bubblingEventTypes, on Android this is under directEventTypes. We have code [here](https://fburl.com/3s1dahm2) in the react native renderer which ensures an event is not listed as both. ``` // iOS const SliderViewConfig = { bubblingEventTypes: { onSlidingComplete: { phasedRegistrationNames: { captured: 'onChangeCapture', bubbled: 'onChange' } } }, directEventTypes: { // None }, validAttributes: { // ... } }; ``` ``` // Android const SliderViewConfig = { bubblingEventTypes: { // None }, directEventTypes: { onSlidingComplete: { registrationName: 'onEventDirect' } }, validAttributes: { // ... } }; ``` ## Solutions There are three solutions to this issue: 1. Don't generate view configs 2. Rename the component on one platform 3. Make a breaking change in the event behavior on one platform to make it consistent across both platforms Here we've chosen option #3 Reviewed By: TheSavior Differential Revision: D15322304 fbshipit-source-id: ff1ab86efe9e2bc50fd3f7619e6760ab5c1c5090
2019-05-16 20:45:54 +03:00
@property (nonatomic, copy) RCTDirectEventBlock onSlidingComplete;
@property (nonatomic, assign) float step;
@property (nonatomic, assign) float lastValue;
@property (nonatomic, strong) UIImage *trackImage;
@property (nonatomic, strong) UIImage *minimumTrackImage;
@property (nonatomic, strong) UIImage *maximumTrackImage;
@property (nonatomic, strong) UIImage *thumbImage;
2019-03-01 21:09:07 +03:00
@end
2019-03-01 21:09:07 +03:00
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
@protocol RCTSliderDelegate <NSObject>
@optional
- (void)slider:(RCTSlider *)slider didPress:(BOOL)press;
@end
2019-03-01 21:09:07 +03:00
#endif // ]TODO(macOS ISS#2323203)