Explorar el Código

Fix argument input screen colors

Tanner Bennett hace 6 años
padre
commit
5859017040

+ 18 - 5
Classes/Editing/ArgumentInputViews/FLEXArgumentInputStructView.m

@@ -24,16 +24,21 @@
     if (self) {
         NSMutableArray<FLEXArgumentInputView *> *inputViews = [NSMutableArray array];
         NSArray<NSString *> *customTitles = [[self class] customFieldTitlesForTypeEncoding:typeEncoding];
-        [FLEXRuntimeUtility enumerateTypesInStructEncoding:typeEncoding usingBlock:^(NSString *structName, const char *fieldTypeEncoding, NSString *prettyTypeEncoding, NSUInteger fieldIndex, NSUInteger fieldOffset) {
+        [FLEXRuntimeUtility enumerateTypesInStructEncoding:typeEncoding usingBlock:^(NSString *structName,
+                                                                                     const char *fieldTypeEncoding,
+                                                                                     NSString *prettyTypeEncoding,
+                                                                                     NSUInteger fieldIndex,
+                                                                                     NSUInteger fieldOffset) {
             
             FLEXArgumentInputView *inputView = [FLEXArgumentInputViewFactory argumentInputViewForTypeEncoding:fieldTypeEncoding];
-            inputView.backgroundColor = self.backgroundColor;
             inputView.targetSize = FLEXArgumentInputViewSizeSmall;
             
             if (fieldIndex < customTitles.count) {
                 inputView.title = customTitles[fieldIndex];
             } else {
-                inputView.title = [NSString stringWithFormat:@"%@ field %lu (%@)", structName, (unsigned long)fieldIndex, prettyTypeEncoding];
+                inputView.title = [NSString stringWithFormat:@"%@ field %lu (%@)",
+                    structName, (unsigned long)fieldIndex, prettyTypeEncoding
+                ];
             }
 
             [inputViews addObject:inputView];
@@ -69,7 +74,11 @@
             if (valueSize > 0) {
                 void *unboxedValue = malloc(valueSize);
                 [inputValue getValue:unboxedValue];
-                [FLEXRuntimeUtility enumerateTypesInStructEncoding:structTypeEncoding usingBlock:^(NSString *structName, const char *fieldTypeEncoding, NSString *prettyTypeEncoding, NSUInteger fieldIndex, NSUInteger fieldOffset) {
+                [FLEXRuntimeUtility enumerateTypesInStructEncoding:structTypeEncoding usingBlock:^(NSString *structName,
+                                                                                                   const char *fieldTypeEncoding,
+                                                                                                   NSString *prettyTypeEncoding,
+                                                                                                   NSUInteger fieldIndex,
+                                                                                                   NSUInteger fieldOffset) {
                     
                     void *fieldPointer = unboxedValue + fieldOffset;
                     FLEXArgumentInputView *inputView = self.argumentInputViews[fieldIndex];
@@ -99,7 +108,11 @@
     
     if (structSize > 0) {
         void *unboxedStruct = malloc(structSize);
-        [FLEXRuntimeUtility enumerateTypesInStructEncoding:structTypeEncoding usingBlock:^(NSString *structName, const char *fieldTypeEncoding, NSString *prettyTypeEncoding, NSUInteger fieldIndex, NSUInteger fieldOffset) {
+        [FLEXRuntimeUtility enumerateTypesInStructEncoding:structTypeEncoding usingBlock:^(NSString *structName,
+                                                                                           const char *fieldTypeEncoding,
+                                                                                           NSString *prettyTypeEncoding,
+                                                                                           NSUInteger fieldIndex,
+                                                                                           NSUInteger fieldOffset) {
             
             void *fieldPointer = unboxedStruct + fieldOffset;
             FLEXArgumentInputView *inputView = self.argumentInputViews[fieldIndex];

+ 19 - 26
Classes/Editing/ArgumentInputViews/FLEXArgumentInputTextView.m

@@ -26,20 +26,26 @@
     if (self) {
         self.inputTextView = [UITextView new];
         self.inputTextView.font = [[self class] inputFont];
-        self.inputTextView.backgroundColor = [FLEXColor primaryBackgroundColor];
-        self.inputTextView.layer.borderColor = [FLEXColor borderColor].CGColor;
-        self.inputTextView.layer.borderWidth = 1.f;
-        self.inputTextView.layer.cornerRadius = 5.f;
+        self.inputTextView.backgroundColor = [FLEXColor secondaryGroupedBackgroundColor];
+        self.inputTextView.layer.cornerRadius = 10.f;
+        self.inputTextView.contentInset = UIEdgeInsetsMake(0, 5, 0, 0);
         self.inputTextView.autocapitalizationType = UITextAutocapitalizationTypeNone;
         self.inputTextView.autocorrectionType = UITextAutocorrectionTypeNo;
         self.inputTextView.delegate = self;
         self.inputTextView.inputAccessoryView = [self createToolBar];
-        [self addSubview:self.inputTextView];
+        if (@available(iOS 11, *)) {
+            [self.inputTextView.layer setValue:@YES forKey:@"continuousCorners"];
+        } else {
+            self.inputTextView.layer.borderWidth = 1.f;
+            self.inputTextView.layer.borderColor = [FLEXColor borderColor].CGColor;
+        }
 
         self.placeholderLabel = [UILabel new];
         self.placeholderLabel.font = self.inputTextView.font;
         self.placeholderLabel.textColor = [FLEXColor deemphasizedTextColor];
         self.placeholderLabel.numberOfLines = 0;
+
+        [self addSubview:self.inputTextView];
         [self.inputTextView addSubview:self.placeholderLabel];
 
     }
@@ -52,17 +58,18 @@
 {
     UIToolbar *toolBar = [UIToolbar new];
     [toolBar sizeToFit];
-    UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
-    UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(textViewDone)];
+    UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc]
+        initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
+        target:nil action:nil
+    ];
+    UIBarButtonItem *doneItem = [[UIBarButtonItem alloc]
+        initWithBarButtonSystemItem:UIBarButtonSystemItemDone
+        target:self.inputTextView action:@selector(resignFirstResponder)
+    ];
     toolBar.items = @[spaceItem, doneItem];
     return toolBar;
 }
 
-- (void)textViewDone
-{
-    [self.inputTextView resignFirstResponder];
-}
-
 - (void)setInputPlaceholderText:(NSString *)placeholder
 {
     self.placeholderLabel.text = placeholder;
@@ -137,20 +144,6 @@
 }
 
 
-#pragma mark - Trait collection changes
-
-- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
-{
-#if FLEX_AT_LEAST_IOS13_SDK
-    if (@available(iOS 13.0, *)) {
-        if (previousTraitCollection.userInterfaceStyle != self.traitCollection.userInterfaceStyle) {
-            self.inputTextView.layer.borderColor = [FLEXColor borderColor].CGColor;
-        }
-    }
-#endif
-}
-
-
 #pragma mark - Class Helpers
 
 + (UIFont *)inputFont

+ 2 - 2
Classes/Editing/ArgumentInputViews/FLEXArgumentInputView.m

@@ -8,6 +8,7 @@
 
 #import "FLEXArgumentInputView.h"
 #import "FLEXUtility.h"
+#import "FLEXColor.h"
 
 @interface FLEXArgumentInputView ()
 
@@ -58,8 +59,7 @@
     if (!_titleLabel) {
         _titleLabel = [UILabel new];
         _titleLabel.font = [[self class] titleFont];
-        _titleLabel.backgroundColor = self.backgroundColor;
-        _titleLabel.textColor = [UIColor colorWithWhite:0.3 alpha:1.0];
+        _titleLabel.textColor = [FLEXColor primaryTextColor];
         _titleLabel.numberOfLines = 0;
         [self addSubview:_titleLabel];
     }

+ 3 - 1
Classes/Editing/FLEXFieldEditorViewController.m

@@ -11,6 +11,7 @@
 #import "FLEXArgumentInputViewFactory.h"
 #import "FLEXPropertyAttributes.h"
 #import "FLEXUtility.h"
+#import "FLEXColor.h"
 
 @interface FLEXFieldEditorViewController () <FLEXArgumentInputViewDelegate>
 
@@ -51,6 +52,8 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
 
+    self.view.backgroundColor = [FLEXColor groupedBackgroundColor];
+
     // Create getter button
     _getterButton = [[UIBarButtonItem alloc]
         initWithTitle:@"Get"
@@ -64,7 +67,6 @@
     self.fieldEditorView.fieldDescription = self.fieldDescription;
     FLEXArgumentInputView *inputView = [FLEXArgumentInputViewFactory argumentInputViewForTypeEncoding:self.typeEncoding];
     inputView.inputValue = self.currentValue;
-    inputView.backgroundColor = self.view.backgroundColor;
     inputView.delegate = self;
     self.fieldEditorView.argumentInputViews = @[inputView];
 

+ 0 - 1
Classes/Editing/FLEXVariableEditorViewController.m

@@ -98,7 +98,6 @@
     [self.view addSubview:self.scrollView];
     
     _fieldEditorView = [FLEXFieldEditorView new];
-    self.fieldEditorView.backgroundColor = self.view.backgroundColor;
     self.fieldEditorView.targetDescription = [NSString stringWithFormat:@"%@ %p", [self.target class], self.target];
     [self.scrollView addSubview:self.fieldEditorView];
     

+ 18 - 13
Classes/Utility/FLEXColor.h

@@ -13,28 +13,33 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface FLEXColor : NSObject
 
-// Background colors, from intense to less intense
-+ (UIColor *)primaryBackgroundColor;
+@property (readonly, class) UIColor *primaryBackgroundColor;
 + (UIColor *)primaryBackgroundColorWithAlpha:(CGFloat)alpha;
 
-+ (UIColor *)secondaryBackgroundColor;
+@property (readonly, class) UIColor *secondaryBackgroundColor;
 + (UIColor *)secondaryBackgroundColorWithAlpha:(CGFloat)alpha;
 
-+ (UIColor *)tertiaryBackgroundColor;
+@property (readonly, class) UIColor *tertiaryBackgroundColor;
 + (UIColor *)tertiaryBackgroundColorWithAlpha:(CGFloat)alpha;
 
+@property (readonly, class) UIColor *groupedBackgroundColor;
++ (UIColor *)groupedBackgroundColorWithAlpha:(CGFloat)alpha;
+
+@property (readonly, class) UIColor *secondaryGroupedBackgroundColor;
++ (UIColor *)secondaryGroupedBackgroundColorWithAlpha:(CGFloat)alpha;
+
 // Text colors
-+ (UIColor *)primaryTextColor;
-+ (UIColor *)deemphasizedTextColor;
+@property (readonly, class) UIColor *primaryTextColor;
+@property (readonly, class) UIColor *deemphasizedTextColor;
 
 // UI element colors
-+ (UIColor *)tintColor;
-+ (UIColor *)scrollViewBackgroundColor;
-+ (UIColor *)iconColor;
-+ (UIColor *)borderColor;
-+ (UIColor *)toolbarItemHighlightedColor;
-+ (UIColor *)toolbarItemSelectedColor;
-+ (UIColor *)hairlineColor;
+@property (readonly, class) UIColor *tintColor;
+@property (readonly, class) UIColor *scrollViewBackgroundColor;
+@property (readonly, class) UIColor *iconColor;
+@property (readonly, class) UIColor *borderColor;
+@property (readonly, class) UIColor *toolbarItemHighlightedColor;
+@property (readonly, class) UIColor *toolbarItemSelectedColor;
+@property (readonly, class) UIColor *hairlineColor;
 
 @end
 

+ 20 - 1
Classes/Utility/FLEXColor.m

@@ -38,7 +38,7 @@
 + (UIColor *)secondaryBackgroundColor {
     return FLEXDynamicColor(
         secondarySystemBackgroundColor,
-        colorWithHue:2.0/3.0 saturation:0.02 brightness:0.95 alpha:1
+        colorWithHue:2.0/3.0 saturation:0.02 brightness:0.97 alpha:1
     );
 }
 
@@ -57,6 +57,25 @@
     return [[self tertiaryBackgroundColor] colorWithAlphaComponent:alpha];
 }
 
++ (UIColor *)groupedBackgroundColor {
+    return FLEXDynamicColor(
+        systemGroupedBackgroundColor,
+        colorWithHue:2.0/3.0 saturation:0.02 brightness:0.97 alpha:1
+    );
+}
+
++ (UIColor *)groupedBackgroundColorWithAlpha:(CGFloat)alpha {
+    return [[self groupedBackgroundColor] colorWithAlphaComponent:alpha];
+}
+
++ (UIColor *)secondaryGroupedBackgroundColor {
+    return FLEXDynamicColor(secondarySystemGroupedBackgroundColor, whiteColor);
+}
+
++ (UIColor *)secondaryGroupedBackgroundColorWithAlpha:(CGFloat)alpha {
+    return [[self secondaryGroupedBackgroundColor] colorWithAlphaComponent:alpha];
+}
+
 #pragma mark - Text colors
 
 + (UIColor *)primaryTextColor {