Просмотр исходного кода

Add FLEXArgumentInputNotSupportedView for types where we don’t have a suitable interface for accepting input.

i.e. blocks, unions, c-arrays, etc. We may support some of these in the future (arrays), but others (blocks) will never be supported.
Ryan Olson лет назад: 12
Родитель
Сommit
706ec18300

+ 13 - 0
Classes/Editing/Argument Input Views/FLEXArgumentInputNotSupportedView.h

@@ -0,0 +1,13 @@
+//
+//  FLEXArgumentInputNotSupportedView.h
+//  Flipboard
+//
+//  Created by Ryan Olson on 6/18/14.
+//  Copyright (c) 2014 Flipboard. All rights reserved.
+//
+
+#import "FLEXArgumentInputTextView.h"
+
+@interface FLEXArgumentInputNotSupportedView : FLEXArgumentInputTextView
+
+@end

+ 25 - 0
Classes/Editing/Argument Input Views/FLEXArgumentInputNotSupportedView.m

@@ -0,0 +1,25 @@
+//
+//  FLEXArgumentInputNotSupportedView.m
+//  Flipboard
+//
+//  Created by Ryan Olson on 6/18/14.
+//  Copyright (c) 2014 Flipboard. All rights reserved.
+//
+
+#import "FLEXArgumentInputNotSupportedView.h"
+
+@implementation FLEXArgumentInputNotSupportedView
+
+- (instancetype)initWithArgumentTypeEncoding:(const char *)typeEncoding
+{
+    self = [super initWithArgumentTypeEncoding:typeEncoding];
+    if (self) {
+        self.inputTextView.userInteractionEnabled = NO;
+        self.inputTextView.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1.0];
+        self.inputTextView.text = @"nil";
+        self.targetSize = FLEXArgumentInputViewSizeSmall;
+    }
+    return self;
+}
+
+@end

+ 4 - 3
Classes/Editing/Argument Input Views/FLEXArgumentInputViewFactory.m

@@ -12,6 +12,7 @@
 #import "FLEXArgumentInputNumberView.h"
 #import "FLEXArgumentInputSwitchView.h"
 #import "FLEXArgumentInputStructView.h"
+#import "FLEXArgumentInputNotSupportedView.h"
 
 @implementation FLEXArgumentInputViewFactory
 
@@ -19,9 +20,9 @@
 {
     Class subclass = [self argumentInputViewSubclassForTypeEncoding:typeEncoding currentValue:nil];
     if (!subclass) {
-        // Fall back to a generic FLEXArgumentInputView if we can't find a subclass that supports the type.
-        // The generic input view does not actually allow input, but it still shows the title of the field.
-        subclass = [FLEXArgumentInputView class];
+        // Fall back to a FLEXArgumentInputNotSupportedView if we can't find a subclass that fits the type encoding.
+        // The unsupported view shows "nil" and does not allow user input.
+        subclass = [FLEXArgumentInputNotSupportedView class];
     }
     return [[subclass alloc] initWithArgumentTypeEncoding:typeEncoding];
 }