Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
henninghall committed Aug 10, 2023
1 parent 54c73e1 commit 6b83b1a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion ios/RNDatePicker2.h → ios/RNDatePicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface RNDatePicker2 : RCTViewComponentView
@interface RNDatePicker : RCTViewComponentView

@end

Expand Down
38 changes: 19 additions & 19 deletions ios/RNDatePicker2.mm → ios/RNDatePicker.mm
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// #import "RCTComponent.h"
#import "RNDatePicker2.h"
#import "RNDatePicker.h"

// #import "RCTUtils.h"
// #import "UIView+React.h"
#import <React/RCTConversions.h>
#import "RCTConvert.h"


#import <react/renderer/components/RNDatePicker2Specs/ComponentDescriptors.h>
#import <react/renderer/components/RNDatePicker2Specs/EventEmitters.h>
#import <react/renderer/components/RNDatePicker2Specs/Props.h>
#import <react/renderer/components/RNDatePicker2Specs/RCTComponentViewHelpers.h>
#import <react/renderer/components/RNDatePickerSpecs/ComponentDescriptors.h>
#import <react/renderer/components/RNDatePickerSpecs/EventEmitters.h>
#import <react/renderer/components/RNDatePickerSpecs/Props.h>
#import <react/renderer/components/RNDatePickerSpecs/RCTComponentViewHelpers.h>

#import "RCTFabricComponentsPlugins.h"

Expand All @@ -19,11 +19,11 @@
using namespace facebook::react;


@interface RNDatePicker2 () <RCTRNDatePicker2ViewProtocol>
@interface RNDatePicker () <RCTRNDatePickerViewProtocol>

@end

@implementation RNDatePicker2 {
@implementation RNDatePicker {
DatePicker *_picker;
UIView *_view;
UILabel *_label;
Expand All @@ -32,7 +32,7 @@ @implementation RNDatePicker2 {

+ (ComponentDescriptorProvider)componentDescriptorProvider
{
return concreteComponentDescriptorProvider<RNDatePicker2ComponentDescriptor>();
return concreteComponentDescriptorProvider<RNDatePickerComponentDescriptor>();
}

NSDate* unixMillisToNSDate (double unixMillis) {
Expand All @@ -43,7 +43,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider
- (instancetype)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
static const auto defaultProps = std::make_shared<const RNDatePicker2Props>();
static const auto defaultProps = std::make_shared<const RNDatePickerProps>();
_props = defaultProps;

_picker = [[DatePicker alloc] initWithFrame:_view.bounds];
Expand Down Expand Up @@ -75,8 +75,8 @@ - (void)setContentView:(UIView *)contentView

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &oldViewProps = *std::static_pointer_cast<RNDatePicker2Props const>(oldProps ? oldProps : _props); //_props equ
const auto &newViewProps = *std::static_pointer_cast<RNDatePicker2Props const>(props);
const auto &oldViewProps = *std::static_pointer_cast<RNDatePickerProps const>(oldProps ? oldProps : _props); //_props equ
const auto &newViewProps = *std::static_pointer_cast<RNDatePickerProps const>(props);

// date
if(oldViewProps.date != newViewProps.date) {
Expand Down Expand Up @@ -108,9 +108,9 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &

// mode
if (oldViewProps.mode != newViewProps.mode) {
if(newViewProps.mode == RNDatePicker2Mode::Time) [_picker setDatePickerMode:UIDatePickerModeTime];
if(newViewProps.mode == RNDatePicker2Mode::Date) [_picker setDatePickerMode:UIDatePickerModeDate];
if(newViewProps.mode == RNDatePicker2Mode::Datetime) [_picker setDatePickerMode:UIDatePickerModeDateAndTime];
if(newViewProps.mode == RNDatePickerMode::Time) [_picker setDatePickerMode:UIDatePickerModeTime];
if(newViewProps.mode == RNDatePickerMode::Date) [_picker setDatePickerMode:UIDatePickerModeDate];
if(newViewProps.mode == RNDatePickerMode::Datetime) [_picker setDatePickerMode:UIDatePickerModeDateAndTime];
// We need to set minuteInterval after setting datePickerMode, otherwise minuteInterval is invalid in time mode.
_picker.minuteInterval = _reactMinuteInterval;
}
Expand All @@ -136,15 +136,15 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
[super updateProps:props oldProps:oldProps];
}

-(void)didChange:(RNDatePicker2 *)sender
-(void)didChange:(RNDatePicker *)sender
{
std::dynamic_pointer_cast<const RNDatePicker2EventEmitter>(_eventEmitter)
->onChange(RNDatePicker2EventEmitter::OnChange{ .timestamp = _picker.date.timeIntervalSince1970 * 1000.0f });
std::dynamic_pointer_cast<const RNDatePickerEventEmitter>(_eventEmitter)
->onChange(RNDatePickerEventEmitter::OnChange{ .timestamp = _picker.date.timeIntervalSince1970 * 1000.0f });
}

@end

Class<RCTComponentViewProtocol> RNDatePicker2Cls(void)
Class<RCTComponentViewProtocol> RNDatePickerCls(void)
{
return RNDatePicker2.class;
return RNDatePicker.class;
}
2 changes: 1 addition & 1 deletion ios/RNDatePicker2Manager.h → ios/RNDatePickerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import <React/RCTConvert.h>
#import <React/RCTViewManager.h>

@interface RNDatePicker2Manager : RCTViewManager
@interface RNDatePickerManager : RCTViewManager

@property (strong, nonatomic) UIViewController *topViewController;

Expand Down
6 changes: 3 additions & 3 deletions ios/RNDatePicker2Manager.mm → ios/RNDatePickerManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import <React/RCTUIManager.h>
#import <React/RCTViewManager.h>

#import "RNDatePicker2Manager.h"
#import "RNDatePickerManager.h"

/**
* Copyright (c) 2015-present, Facebook, Inc.
Expand All @@ -28,9 +28,9 @@ @implementation RCTConvert(UIDatePicker)

@end

@implementation RNDatePicker2Manager
@implementation RNDatePickerManager

RCT_EXPORT_MODULE(RNDatePicker2)
RCT_EXPORT_MODULE(RNDatePicker)

RCT_EXPORT_METHOD(addListener : (NSString *)eventName) {
// Keep: Required for RN built in Event Emitter Calls.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"prettier": "^2.2.1"
},
"codegenConfig": {
"name": "RNDatePicker2Specs",
"name": "RNDatePickerSpecs",
"type": "components",
"jsSrcsDir": "src/fabric"
}
Expand Down
2 changes: 1 addition & 1 deletion src/DatePickerIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { shouldCloseModal, shouldOpenModal } from './modal'

// TODO: Move to its own file
const RCTDatePickerIOS =
Platform.OS === 'ios' ? requireNativeComponent('RNDatePicker2') : null
Platform.OS === 'ios' ? requireNativeComponent('RNDatePicker') : null

export default class DatePickerIOS extends React.Component {
_picker = null
Expand Down
2 changes: 1 addition & 1 deletion src/fabric/RNDatePickerNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ export interface NativeProps extends ViewProps {
}

export default codegenNativeComponent<NativeProps>(
'RNDatePicker2'
'RNDatePicker'
) as HostComponent<NativeProps>

0 comments on commit 6b83b1a

Please sign in to comment.