Преглед изворни кода

images render properly now and will attempt to airdrop out to the user if possible

Kevin Bradley пре 5 година
родитељ
комит
88568d58d7

+ 1 - 1
Classes/Editing/ArgumentInputViews/FLEXArgumentInputSwitchView.m

@@ -72,7 +72,7 @@
 - (void)layoutSubviews {
     [super layoutSubviews];
 #if TARGET_OS_TV
-    self.inputSwitch.frame = CGRectMake(20, 50, 200, 60);
+    self.inputSwitch.frame = CGRectMake(50, 50, 200, 60);
 #else
     self.inputSwitch.frame = CGRectMake(0, self.topInputFieldVerticalLayoutGuide, self.inputSwitch.frame.size.width, self.inputSwitch.frame.size.height);
 #endif

+ 13 - 0
Classes/Editing/FLEXFieldEditorViewController.m

@@ -137,6 +137,19 @@
     }
 }
 
+- (void)viewWillLayoutSubviews {
+    [super viewWillLayoutSubviews];
+#if TARGET_OS_TV
+    CGRect getterFrame = _getterButton.frame;
+    CGFloat actionOffset = [[self actionButton] frame].origin.y;
+    //CGRect fieldEditorFrame = self.fieldEditorView.frame;
+    //CGFloat buttonOffset = (fieldEditorFrame.origin.y + fieldEditorFrame.size.height) + (130 + 67);
+    getterFrame.origin.y = actionOffset;
+    _getterButton.frame = getterFrame;
+    
+#endif
+}
+
 #pragma mark - Private
 
 - (id)currentValue {

+ 8 - 0
Classes/Editing/FLEXVariableEditorViewController.m

@@ -119,6 +119,14 @@
     CGSize constrainSize = CGSizeMake(self.scrollView.bounds.size.width, CGFLOAT_MAX);
     CGSize fieldEditorSize = [self.fieldEditorView sizeThatFits:constrainSize];
     self.fieldEditorView.frame = CGRectMake(0, 0, fieldEditorSize.width, fieldEditorSize.height);
+#if TARGET_OS_TV
+    CGRect actionFrame = _actionButton.frame;
+    CGRect fieldEditorFrame = self.fieldEditorView.frame;
+    CGFloat buttonOffset = (fieldEditorFrame.origin.y + fieldEditorFrame.size.height) + (130 + 67);
+    actionFrame.origin.y = buttonOffset;
+    _actionButton.frame = actionFrame;
+    
+#endif
     self.scrollView.contentSize = fieldEditorSize;
 }
 

+ 22 - 0
Classes/ViewHierarchy/FLEXImagePreviewViewController.m

@@ -26,6 +26,9 @@
 #pragma mark Initialization
 
 + (instancetype)previewForView:(UIView *)view {
+#if TARGET_OS_TV
+    return [self forImage:[FLEXUtility previewImageForLayer:view.layer]]; //for some reason the one view 'view' below literally never works on tvOS
+#endif
     return [self forImage:[FLEXUtility previewImageForView:view]];
 }
 
@@ -113,7 +116,26 @@
     self.scrollView.backgroundColor = self.backgroundColors[self.backgroundColorIndex];
 }
 
++ (NSString *)documentsFolder {
+     NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+     return [paths objectAtIndex:0];
+}
+
 - (void)actionButtonPressed:(id)sender {
+#if TARGET_OS_TV
+    NSString *outputFile = [[FLEXImagePreviewViewController documentsFolder] stringByAppendingPathComponent:@"FLEXViewImage.png"];
+    FXLog(@"exporting view image to file: %@", outputFile);
+    NSFileManager *man = [NSFileManager defaultManager];
+    if ([man fileExistsAtPath:outputFile]){
+        [man removeItemAtPath:outputFile error:nil];
+    }
+    [UIImagePNGRepresentation(self.image) writeToFile:outputFile atomically:true];
+    NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
+    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"airdropper://%@?sender=%@", outputFile, bundleID]];
+    [[UIApplication sharedApplication] openURL:url];
+    return;
+#endif
+    
     static BOOL canSaveToCameraRoll = NO, didShowWarning = NO;
     static dispatch_once_t onceToken;
     dispatch_once(&onceToken, ^{

+ 1 - 1
tvOS/fakes.h

@@ -78,7 +78,7 @@
 - (instancetype _Nonnull )initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER;      // This class enforces a size appropriate for the control, and so the frame size is ignored.
 - (nullable instancetype)initWithCoder:(NSCoder *_Nonnull)coder NS_DESIGNATED_INITIALIZER;
 - (void)setOn:(BOOL)on animated:(BOOL)animated; // does not send action
-+ (id)newSwitch;
++ (id _Nonnull )newSwitch;
 @end
 
 @interface UIFakeSlider: UIControl <NSCoding>