Skip to content

Commit

Permalink
Add tvOS Target (software-mansion#448)
Browse files Browse the repository at this point in the history
Work in progress. I added a new -tvOS Target to the libraries project. Also some gestures are not supported on tvOS. I fixed that with a compiler flag. But there might be a better way to solve that.
  • Loading branch information
hufkens authored and kmagiera committed Feb 13, 2019
1 parent 9022bc9 commit 7fbc2f4
Show file tree
Hide file tree
Showing 12 changed files with 355 additions and 194 deletions.
54 changes: 0 additions & 54 deletions Example/ios/GestureHandler-tvOS/Info.plist

This file was deleted.

19 changes: 18 additions & 1 deletion Example/ios/GestureHandler.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@
remoteGlobalIDString = 58B5119B1A9E6C1200147676;
remoteInfo = RCTText;
};
B55B75702208E9D3001B6E1A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 66D9329E21BEFC5200E14346 /* RNGestureHandler.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = B5AF2F842208E55A0080319A;
remoteInfo = "RNGestureHandler-tvOS";
};
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -336,6 +343,7 @@
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
9959AF8A7D2B4083BD8A4519 /* Zocial.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Zocial.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Zocial.ttf"; sourceTree = "<group>"; };
B55B758D2208EC63001B6E1A /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.1.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; };
BB2E03EAE7A94DF18ADA38F7 /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Octicons.ttf"; sourceTree = "<group>"; };
C5DCC010E8A44473AA39F47E /* Foundation.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Foundation.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Foundation.ttf"; sourceTree = "<group>"; };
D4363B3FAD994C7CB59220D8 /* SimpleLineIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = SimpleLineIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/SimpleLineIcons.ttf"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -517,13 +525,15 @@
isa = PBXGroup;
children = (
66D932A321BEFC5200E14346 /* libRNGestureHandler.a */,
B55B75712208E9D3001B6E1A /* libRNGestureHandler.a */,
);
name = Products;
sourceTree = "<group>";
};
66D932A421BEFC6D00E14346 /* Frameworks */ = {
isa = PBXGroup;
children = (
B55B758D2208EC63001B6E1A /* JavaScriptCore.framework */,
66E46E0121D1296C00C788C0 /* JavaScriptCore.framework */,
);
name = Frameworks;
Expand Down Expand Up @@ -956,6 +966,13 @@
remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
B55B75712208E9D3001B6E1A /* libRNGestureHandler.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNGestureHandler.a;
remoteRef = B55B75702208E9D3001B6E1A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */

/* Begin PBXResourcesBuildPhase section */
Expand Down Expand Up @@ -994,7 +1011,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down

This file was deleted.

17 changes: 10 additions & 7 deletions Example/ios/GestureHandler/Base.lproj/LaunchScreen.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand All @@ -12,20 +15,20 @@
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Powered by React Native" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Powered by React Native" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="GestureHandler" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="GestureHandler" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
2 changes: 2 additions & 0 deletions Example/ios/MBFingerTipWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ - (UIWindow *)overlayWindow
_overlayWindow = [[MBFingerTipOverlayWindow alloc] initWithFrame:self.frame];

_overlayWindow.userInteractionEnabled = NO;
#if !TARGET_OS_TV
_overlayWindow.windowLevel = UIWindowLevelStatusBar;
#endif
_overlayWindow.backgroundColor = [UIColor clearColor];
_overlayWindow.hidden = NO;
}
Expand Down
2 changes: 2 additions & 0 deletions ios/Handlers/RNFlingHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ - (void)configure:(NSDictionary *)config
recognizer.direction = [RCTConvert NSInteger:prop];
}

#ifndef TARGET_OS_TV
prop = config[@"numberOfPointers"];
if (prop != nil) {
recognizer.numberOfTouchesRequired = [RCTConvert NSInteger:prop];
}
#endif
}

@end
Expand Down
2 changes: 2 additions & 0 deletions ios/Handlers/RNForceTouchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ - (BOOL)shouldFail {

- (void)performFeedbackIfRequired
{
#ifndef TARGET_OS_TV
if (_feedbackOnActivation) {
if (@available(iOS 10.0, *)) {
[[[UIImpactFeedbackGenerator alloc] initWithStyle:(UIImpactFeedbackStyleMedium)] impactOccurred];
}
}
#endif
}

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
Expand Down
11 changes: 9 additions & 2 deletions ios/Handlers/RNPanHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ - (id)initWithGestureHandler:(RNGestureHandler*)gestureHandler
_failOffsetYStart = NAN;
_failOffsetYEnd = NAN;
_hasCustomActivationCriteria = NO;
#ifndef TARGET_OS_TV
_realMinimumNumberOfTouches = self.minimumNumberOfTouches;
#endif
}
return self;
}
Expand All @@ -66,6 +68,7 @@ - (void)setMinimumNumberOfTouches:(NSUInteger)minimumNumberOfTouches

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
#ifndef TARGET_OS_TV
if (_hasCustomActivationCriteria) {
// We use "minimumNumberOfTouches" property to prevent pan handler from recognizing
// the gesture too early before we are sure that all criteria (e.g. minimum distance
Expand All @@ -74,6 +77,7 @@ - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
} else {
super.minimumNumberOfTouches = _realMinimumNumberOfTouches;
}
#endif
[super touchesBegan:touches withEvent:event];
}

Expand All @@ -98,11 +102,13 @@ - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
}
}
if (_hasCustomActivationCriteria && self.state == UIGestureRecognizerStatePossible && [self shouldActivateUnderCustomCriteria]) {
#ifndef TARGET_OS_TV
super.minimumNumberOfTouches = _realMinimumNumberOfTouches;
if ([self numberOfTouches] >= _realMinimumNumberOfTouches) {
self.state = UIGestureRecognizerStateBegan;
[self setTranslation:CGPointMake(0, 0) inView:self.view];
}
#endif
}
}

Expand Down Expand Up @@ -200,10 +206,11 @@ - (void)configure:(NSDictionary *)config
APPLY_FLOAT_PROP(failOffsetYStart);
APPLY_FLOAT_PROP(failOffsetYEnd);

#ifndef TARGET_OS_TV
APPLY_NAMED_INT_PROP(minimumNumberOfTouches, @"minPointers");
APPLY_NAMED_INT_PROP(maximumNumberOfTouches, @"maxPointers");

#endif

id prop = config[@"minDist"];
if (prop != nil) {
CGFloat dist = [RCTConvert CGFloat:prop];
Expand Down
Loading

0 comments on commit 7fbc2f4

Please sign in to comment.