Files
react-navigation/ios/RNSScreen.m
Krzysztof Magiera 31281d6b68 Initial commit.
2018-08-03 13:54:11 +02:00

77 lines
1.1 KiB
Objective-C

#import "RNSScreen.h"
#import "RNSScreenContainer.h"
@interface RNSScreen : UIViewController
- (instancetype)initWithView:(UIView *)view;
@end
@implementation RNSScreenView
- (instancetype)init
{
if (self = [super init]) {
_controller = [[RNSScreen alloc] initWithView:self];
_controller.modalPresentationStyle = UIModalPresentationOverCurrentContext;
}
return self;
}
- (void)setActive:(BOOL)active
{
_active = active;
[_reactSuperview markChildUpdated];
}
- (UIView *)reactSuperview
{
return _reactSuperview;
}
- (void)didSetProps:(NSArray<NSString *> *)changedProps
{
[_reactSuperview didUpdateChildren];
}
- (void)invalidate
{
_controller.view = nil;
_controller = nil;
}
@end
@implementation RNSScreen {
__weak UIView *_view;
}
- (instancetype)initWithView:(UIView *)view
{
if (self = [super init]) {
_view = view;
}
return self;
}
- (void)loadView
{
self.view = _view;
_view = nil;
}
@end
@implementation RNSScreenManager
RCT_EXPORT_MODULE()
RCT_EXPORT_VIEW_PROPERTY(active, BOOL)
- (UIView *)view
{
return [[RNSScreenView alloc] init];
}
@end