This app provides monitoring and information features for the common freifunk user and the technical stuff of a freifunk community.
Code base is taken from a TUM Practical Course project and added here to see if Freifunk Altdorf can use it.
https://www.freifunk-altdorf.de
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
183 lines
5.3 KiB
183 lines
5.3 KiB
/** |
|
* Copyright (c) 2015-present, Facebook, Inc. |
|
* |
|
* This source code is licensed under the MIT license found in the |
|
* LICENSE file in the root directory of this source tree. |
|
*/ |
|
|
|
#import "RCTSurfaceHostingProxyRootView.h" |
|
|
|
#import <objc/runtime.h> |
|
|
|
#import "RCTAssert.h" |
|
#import "RCTBridge.h" |
|
#import "RCTLog.h" |
|
#import "RCTPerformanceLogger.h" |
|
#import "RCTProfile.h" |
|
#import "RCTRootContentView.h" |
|
#import "RCTRootViewDelegate.h" |
|
#import "RCTSurface.h" |
|
#import "UIView+React.h" |
|
|
|
static RCTSurfaceSizeMeasureMode convertToSurfaceSizeMeasureMode(RCTRootViewSizeFlexibility sizeFlexibility) { |
|
switch (sizeFlexibility) { |
|
case RCTRootViewSizeFlexibilityWidthAndHeight: |
|
return RCTSurfaceSizeMeasureModeWidthUndefined | RCTSurfaceSizeMeasureModeHeightUndefined; |
|
case RCTRootViewSizeFlexibilityWidth: |
|
return RCTSurfaceSizeMeasureModeWidthUndefined | RCTSurfaceSizeMeasureModeHeightExact; |
|
case RCTRootViewSizeFlexibilityHeight: |
|
return RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightUndefined; |
|
case RCTRootViewSizeFlexibilityNone: |
|
return RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact; |
|
} |
|
} |
|
|
|
static RCTRootViewSizeFlexibility convertToRootViewSizeFlexibility(RCTSurfaceSizeMeasureMode sizeMeasureMode) { |
|
switch (sizeMeasureMode) { |
|
case RCTSurfaceSizeMeasureModeWidthUndefined | RCTSurfaceSizeMeasureModeHeightUndefined: |
|
return RCTRootViewSizeFlexibilityWidthAndHeight; |
|
case RCTSurfaceSizeMeasureModeWidthUndefined | RCTSurfaceSizeMeasureModeHeightExact: |
|
return RCTRootViewSizeFlexibilityWidth; |
|
case RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightUndefined: |
|
return RCTRootViewSizeFlexibilityHeight; |
|
case RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact: |
|
default: |
|
return RCTRootViewSizeFlexibilityNone; |
|
} |
|
} |
|
|
|
@implementation RCTSurfaceHostingProxyRootView |
|
|
|
- (instancetype)initWithBridge:(RCTBridge *)bridge |
|
moduleName:(NSString *)moduleName |
|
initialProperties:(NSDictionary *)initialProperties |
|
{ |
|
RCTAssertMainQueue(); |
|
RCTAssert(bridge, @"A bridge instance is required to create an RCTSurfaceHostingProxyRootView"); |
|
RCTAssert(moduleName, @"A moduleName is required to create an RCTSurfaceHostingProxyRootView"); |
|
|
|
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTSurfaceHostingProxyRootView init]", nil); |
|
if (!bridge.isLoading) { |
|
[bridge.performanceLogger markStartForTag:RCTPLTTI]; |
|
} |
|
|
|
if (self = [super initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]) { |
|
self.backgroundColor = [UIColor whiteColor]; |
|
} |
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @""); |
|
|
|
return self; |
|
} |
|
|
|
- (instancetype)initWithBundleURL:(NSURL *)bundleURL |
|
moduleName:(NSString *)moduleName |
|
initialProperties:(NSDictionary *)initialProperties |
|
launchOptions:(NSDictionary *)launchOptions |
|
{ |
|
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:bundleURL |
|
moduleProvider:nil |
|
launchOptions:launchOptions]; |
|
|
|
return [self initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]; |
|
} |
|
|
|
RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) |
|
RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) |
|
|
|
# pragma mark proxy methods to RCTSurfaceHostingView |
|
|
|
- (NSString *)moduleName |
|
{ |
|
return super.surface.moduleName; |
|
} |
|
|
|
- (RCTBridge *)bridge |
|
{ |
|
return super.surface.bridge; |
|
} |
|
|
|
- (UIView *)contentView |
|
{ |
|
return self; |
|
} |
|
|
|
- (NSNumber *)reactTag |
|
{ |
|
return super.surface.rootViewTag; |
|
} |
|
|
|
- (RCTRootViewSizeFlexibility)sizeFlexibility |
|
{ |
|
return convertToRootViewSizeFlexibility(super.sizeMeasureMode); |
|
} |
|
|
|
- (void)setSizeFlexibility:(RCTRootViewSizeFlexibility)sizeFlexibility |
|
{ |
|
super.sizeMeasureMode = convertToSurfaceSizeMeasureMode(sizeFlexibility); |
|
} |
|
|
|
- (NSDictionary *)appProperties |
|
{ |
|
return super.surface.properties; |
|
} |
|
|
|
- (void)setAppProperties:(NSDictionary *)appProperties |
|
{ |
|
[super.surface setProperties:appProperties]; |
|
} |
|
|
|
- (CGSize)intrinsicContentSize |
|
{ |
|
return super.surface.intrinsicSize; |
|
} |
|
|
|
- (UIView *)loadingView |
|
{ |
|
return super.activityIndicatorViewFactory ? super.activityIndicatorViewFactory() : nil; |
|
} |
|
|
|
- (void)setLoadingView:(UIView *)loadingView |
|
{ |
|
super.activityIndicatorViewFactory = ^UIView *(void) { |
|
return loadingView; |
|
}; |
|
} |
|
|
|
#pragma mark RCTSurfaceDelegate proxying |
|
|
|
- (void)surface:(RCTSurface *)surface didChangeStage:(RCTSurfaceStage)stage |
|
{ |
|
[super surface:surface didChangeStage:stage]; |
|
if (RCTSurfaceStageIsRunning(stage)) { |
|
[super.surface.bridge.performanceLogger markStopForTag:RCTPLTTI]; |
|
dispatch_async(dispatch_get_main_queue(), ^{ |
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTContentDidAppearNotification |
|
object:self]; |
|
}); |
|
} |
|
} |
|
|
|
- (void)surface:(RCTSurface *)surface didChangeIntrinsicSize:(CGSize)intrinsicSize |
|
{ |
|
[super surface:surface didChangeIntrinsicSize:intrinsicSize]; |
|
|
|
[_delegate rootViewDidChangeIntrinsicSize:(RCTRootView *)self]; |
|
} |
|
|
|
#pragma mark legacy |
|
|
|
- (UIViewController *)reactViewController |
|
{ |
|
return _reactViewController ?: [super reactViewController]; |
|
} |
|
|
|
#pragma mark unsupported |
|
|
|
- (void)cancelTouches |
|
{ |
|
// Not supported. |
|
} |
|
|
|
@end |
|
|
|
|