Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Flipboard/FLEX
Browse files Browse the repository at this point in the history
# Conflicts:
#	Classes/GlobalStateExplorers/DatabaseBrowser/FLEXSQLiteDatabaseManager.m
#	Classes/Utility/FLEXKeyboardShortcutManager.m
#	FLEX.xcodeproj/project.pbxproj
  • Loading branch information
Les Melnychuk committed Nov 11, 2019
2 parents 660be9a + a6cbfbd commit fcf7f91
Show file tree
Hide file tree
Showing 143 changed files with 2,581 additions and 1,242 deletions.
10 changes: 5 additions & 5 deletions Classes/Core/FLEXScopeCarousel.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (id)initWithFrame:(CGRect)frame {
collectionViewLayout:layout
];
cv.showsHorizontalScrollIndicator = NO;
cv.backgroundColor = [UIColor clearColor];
cv.backgroundColor = UIColor.clearColor;
cv.delegate = self;
cv.dataSource = self;
[cv registerClass:[FLEXCarouselCell class] forCellWithReuseIdentifier:kCarouselCellReuseIdentifier];
Expand All @@ -68,15 +68,15 @@ - (id)initWithFrame:(CGRect)frame {

// Dynamic type
__weak __typeof(self) weakSelf = self;
_dynamicTypeObserver = [[NSNotificationCenter defaultCenter]
_dynamicTypeObserver = [NSNotificationCenter.defaultCenter
addObserverForName:UIContentSizeCategoryDidChangeNotification
object:nil queue:nil usingBlock:^(NSNotification *note) {
[self.collectionView setNeedsLayout];
[self setNeedsUpdateConstraints];

// Notify observers
__typeof(self) self = weakSelf;
for (void (^block)() in self.dynamicTypeHandlers) {
for (void (^block)(FLEXScopeCarousel *) in self.dynamicTypeHandlers) {
block(self);
}
}
Expand All @@ -87,15 +87,15 @@ - (id)initWithFrame:(CGRect)frame {
}

- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self.dynamicTypeObserver];
[NSNotificationCenter.defaultCenter removeObserver:self.dynamicTypeObserver];
}

#pragma mark - Overrides

- (void)drawRect:(CGRect)rect {
[super drawRect:rect];

CGFloat width = 1.f / [UIScreen mainScreen].scale;
CGFloat width = 1.f / UIScreen.mainScreen.scale;

// Draw hairline
CGContextRef context = UIGraphicsGetCurrentContext();
Expand Down
2 changes: 1 addition & 1 deletion Classes/Core/FLEXTableViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ extern CGFloat const kFLEXDebounceForExpensiveIO;

/// Convenient for doing some async processor-intensive searching
/// in the background before updating the UI back on the main queue.
- (void)onBackgroundQueue:(NSArray *(^)())backgroundBlock thenOnMainQueue:(void(^)(NSArray *))mainBlock;
- (void)onBackgroundQueue:(NSArray *(^)(void))backgroundBlock thenOnMainQueue:(void(^)(NSArray *))mainBlock;

@end
12 changes: 10 additions & 2 deletions Classes/Core/FLEXTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ - (void)setAutomaticallyShowsSearchBarCancelButton:(BOOL)autoShowCancel {

- (void)updateSearchResults:(NSString *)newText { }

- (void)onBackgroundQueue:(NSArray *(^)())backgroundBlock thenOnMainQueue:(void(^)(NSArray *))mainBlock {
- (void)onBackgroundQueue:(NSArray *(^)(void))backgroundBlock thenOnMainQueue:(void(^)(NSArray *))mainBlock {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSArray *items = backgroundBlock();
dispatch_async(dispatch_get_main_queue(), ^{
Expand Down Expand Up @@ -163,9 +163,17 @@ - (void)viewDidAppear:(BOOL)animated {
}
}

- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];

if (self.searchController.active) {
self.searchController.active = NO;
}
}

#pragma mark - Private

- (void)debounce:(void(^)())block {
- (void)debounce:(void(^)(void))block {
[self.debounceTimer invalidate];

self.debounceTimer = [NSTimer
Expand Down
54 changes: 27 additions & 27 deletions Classes/Editing/ArgumentInputViews/FLEXArgumentInputColorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ @protocol FLEXColorComponentInputViewDelegate;

@interface FLEXColorComponentInputView : UIView

@property (nonatomic, strong) UISlider *slider;
@property (nonatomic, strong) UILabel *valueLabel;
@property (nonatomic) UISlider *slider;
@property (nonatomic) UILabel *valueLabel;

@property (nonatomic, weak) id <FLEXColorComponentInputViewDelegate> delegate;

Expand All @@ -34,12 +34,12 @@ - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.slider = [[UISlider alloc] init];
self.slider = [UISlider new];
self.slider.backgroundColor = self.backgroundColor;
[self.slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
[self addSubview:self.slider];

self.valueLabel = [[UILabel alloc] init];
self.valueLabel = [UILabel new];
self.valueLabel.backgroundColor = self.backgroundColor;
self.valueLabel.font = [FLEXUtility defaultFontOfSize:14.0];
self.valueLabel.textAlignment = NSTextAlignmentRight;
Expand Down Expand Up @@ -94,9 +94,9 @@ - (CGSize)sizeThatFits:(CGSize)size

@interface FLEXColorPreviewBox : UIView

@property (nonatomic, strong) UIColor *color;
@property (nonatomic) UIColor *color;

@property (nonatomic, strong) UIView *colorOverlayView;
@property (nonatomic) UIView *colorOverlayView;

@end

Expand All @@ -107,12 +107,12 @@ - (id)initWithFrame:(CGRect)frame
self = [super initWithFrame:frame];
if (self) {
self.layer.borderWidth = 1.0;
self.layer.borderColor = [[UIColor blackColor] CGColor];
self.layer.borderColor = UIColor.blackColor.CGColor;
self.backgroundColor = [UIColor colorWithPatternImage:[[self class] backgroundPatternImage]];

self.colorOverlayView = [[UIView alloc] initWithFrame:self.bounds];
self.colorOverlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.colorOverlayView.backgroundColor = [UIColor clearColor];
self.colorOverlayView.backgroundColor = UIColor.clearColor;
[self addSubview:self.colorOverlayView];
}
return self;
Expand All @@ -134,12 +134,12 @@ + (UIImage *)backgroundPatternImage
CGSize squareSize = CGSizeMake(kSquareDimension, kSquareDimension);
CGSize imageSize = CGSizeMake(2.0 * kSquareDimension, 2.0 * kSquareDimension);

UIGraphicsBeginImageContextWithOptions(imageSize, YES, [[UIScreen mainScreen] scale]);
UIGraphicsBeginImageContextWithOptions(imageSize, YES, UIScreen.mainScreen.scale);

[[UIColor whiteColor] setFill];
[UIColor.whiteColor setFill];
UIRectFill(CGRectMake(0, 0, imageSize.width, imageSize.height));

[[UIColor grayColor] setFill];
[UIColor.grayColor setFill];
UIRectFill(CGRectMake(squareSize.width, 0, squareSize.width, squareSize.height));
UIRectFill(CGRectMake(0, squareSize.height, squareSize.width, squareSize.height));

Expand All @@ -153,12 +153,12 @@ + (UIImage *)backgroundPatternImage

@interface FLEXArgumentInputColorView () <FLEXColorComponentInputViewDelegate>

@property (nonatomic, strong) FLEXColorPreviewBox *colorPreviewBox;
@property (nonatomic, strong) UILabel *hexLabel;
@property (nonatomic, strong) FLEXColorComponentInputView *alphaInput;
@property (nonatomic, strong) FLEXColorComponentInputView *redInput;
@property (nonatomic, strong) FLEXColorComponentInputView *greenInput;
@property (nonatomic, strong) FLEXColorComponentInputView *blueInput;
@property (nonatomic) FLEXColorPreviewBox *colorPreviewBox;
@property (nonatomic) UILabel *hexLabel;
@property (nonatomic) FLEXColorComponentInputView *alphaInput;
@property (nonatomic) FLEXColorComponentInputView *redInput;
@property (nonatomic) FLEXColorComponentInputView *greenInput;
@property (nonatomic) FLEXColorComponentInputView *blueInput;

@end

Expand All @@ -168,32 +168,32 @@ - (instancetype)initWithArgumentTypeEncoding:(const char *)typeEncoding
{
self = [super initWithArgumentTypeEncoding:typeEncoding];
if (self) {
self.colorPreviewBox = [[FLEXColorPreviewBox alloc] init];
self.colorPreviewBox = [FLEXColorPreviewBox new];
[self addSubview:self.colorPreviewBox];

self.hexLabel = [[UILabel alloc] init];
self.hexLabel = [UILabel new];
self.hexLabel.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.9];
self.hexLabel.textAlignment = NSTextAlignmentCenter;
self.hexLabel.font = [FLEXUtility defaultFontOfSize:12.0];
[self addSubview:self.hexLabel];

self.alphaInput = [[FLEXColorComponentInputView alloc] init];
self.alphaInput.slider.minimumTrackTintColor = [UIColor blackColor];
self.alphaInput = [FLEXColorComponentInputView new];
self.alphaInput.slider.minimumTrackTintColor = UIColor.blackColor;
self.alphaInput.delegate = self;
[self addSubview:self.alphaInput];

self.redInput = [[FLEXColorComponentInputView alloc] init];
self.redInput.slider.minimumTrackTintColor = [UIColor redColor];
self.redInput = [FLEXColorComponentInputView new];
self.redInput.slider.minimumTrackTintColor = UIColor.redColor;
self.redInput.delegate = self;
[self addSubview:self.redInput];

self.greenInput = [[FLEXColorComponentInputView alloc] init];
self.greenInput.slider.minimumTrackTintColor = [UIColor greenColor];
self.greenInput = [FLEXColorComponentInputView new];
self.greenInput.slider.minimumTrackTintColor = UIColor.greenColor;
self.greenInput.delegate = self;
[self addSubview:self.greenInput];

self.blueInput = [[FLEXColorComponentInputView alloc] init];
self.blueInput.slider.minimumTrackTintColor = [UIColor blueColor];
self.blueInput = [FLEXColorComponentInputView new];
self.blueInput.slider.minimumTrackTintColor = UIColor.blueColor;
self.blueInput.delegate = self;
[self addSubview:self.blueInput];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@interface FLEXArgumentInputDateView ()

@property (nonatomic, strong) UIDatePicker *datePicker;
@property (nonatomic) UIDatePicker *datePicker;

@end

Expand All @@ -21,7 +21,7 @@ - (instancetype)initWithArgumentTypeEncoding:(const char *)typeEncoding
{
self = [super initWithArgumentTypeEncoding:typeEncoding];
if (self) {
self.datePicker = [[UIDatePicker alloc] init];
self.datePicker = [UIDatePicker new];
self.datePicker.datePickerMode = UIDatePickerModeDateAndTime;
// Using UTC, because that's what the NSDate description prints
self.datePicker.calendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

@interface FLEXArgumentInputFontView ()

@property (nonatomic, strong) FLEXArgumentInputView *fontNameInput;
@property (nonatomic, strong) FLEXArgumentInputView *pointSizeInput;
@property (nonatomic) FLEXArgumentInputView *fontNameInput;
@property (nonatomic) FLEXArgumentInputView *pointSizeInput;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@interface FLEXArgumentInputFontsPickerView ()

@property (nonatomic, strong) NSMutableArray<NSString *> *availableFonts;
@property (nonatomic) NSMutableArray<NSString *> *availableFonts;

@end

Expand Down Expand Up @@ -40,7 +40,7 @@ - (void)setInputValue:(id)inputValue

- (id)inputValue
{
return [self.inputTextView.text length] > 0 ? [self.inputTextView.text copy] : nil;
return self.inputTextView.text.length > 0 ? [self.inputTextView.text copy] : nil;
}

#pragma mark - private
Expand Down Expand Up @@ -74,7 +74,7 @@ - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [self.availableFonts count];
return self.availableFonts.count;
}

#pragma mark - UIPickerViewDelegate
Expand All @@ -84,7 +84,7 @@ - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forC
UILabel *fontLabel;
if (!view) {
fontLabel = [UILabel new];
fontLabel.backgroundColor = [UIColor clearColor];
fontLabel.backgroundColor = UIColor.clearColor;
fontLabel.textAlignment = NSTextAlignmentCenter;
} else {
fontLabel = (UILabel*)view;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ - (void)setInputValue:(id)inputValue

- (id)inputValue
{
return [FLEXRuntimeUtility valueForNumberWithObjCType:[self.typeEncoding UTF8String] fromInputString:self.inputTextView.text];
return [FLEXRuntimeUtility valueForNumberWithObjCType:self.typeEncoding.UTF8String fromInputString:self.inputTextView.text];
}

+ (BOOL)supportsObjCType:(const char *)type withCurrentValue:(id)value
Expand All @@ -49,7 +49,8 @@ + (BOOL)supportsObjCType:(const char *)type withCurrentValue:(id)value
@(@encode(unsigned long)),
@(@encode(unsigned long long)),
@(@encode(float)),
@(@encode(double))];
@(@encode(double)),
@(@encode(long double))];
});
return type && [primitiveTypes containsObject:@(type)];
}
Expand Down
35 changes: 24 additions & 11 deletions Classes/Editing/ArgumentInputViews/FLEXArgumentInputObjectView.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,35 @@ + (FLEXArgInputObjectType)preferredDefaultTypeForObjCType:(const char *)type wit
if (strcmp(type, @encode(id)) != 0) {
BOOL isJSONSerializableType = NO;

// Parse class name out of the string,
// which is in the form `@"ClassName"`
Class cls = NSClassFromString(({
NSString *className = nil;
NSScanner *scan = [NSScanner scannerWithString:@(type)];
NSCharacterSet *allowed = [NSCharacterSet
characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$"
];

// Skip over the @" then scan the name
if ([scan scanString:@"@\"" intoString:nil]) {
[scan scanCharactersFromSet:allowed intoString:&className];
}

className;
}));

// Note: we can't use @encode(NSString) here because that drops
// the class information and just goes to @encode(id).
NSArray *jsonTypes = @[
@(FLEXEncodeClass(NSString)),
@(FLEXEncodeClass(NSNumber)),
@(FLEXEncodeClass(NSArray)),
@(FLEXEncodeClass(NSDictionary)),
@(FLEXEncodeClass(NSMutableString)),
@(FLEXEncodeClass(NSMutableArray)),
@(FLEXEncodeClass(NSMutableDictionary)),
NSArray<Class> *jsonTypes = @[
[NSString class],
[NSNumber class],
[NSArray class],
[NSDictionary class],
];

// Look for matching types
NSString *typeStr = @(type);
for (NSString *encodedClass in jsonTypes) {
if ([typeStr isEqualToString:encodedClass]) {
for (Class jsonClass in jsonTypes) {
if ([cls isSubclassOfClass:jsonClass]) {
isJSONSerializableType = YES;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ - (id)inputValue
{
// Interpret empty string as nil. We loose the ability to set empty string as a string value,
// but we accept that tradeoff in exchange for not having to type quotes for every string.
return [self.inputTextView.text length] > 0 ? [self.inputTextView.text copy] : nil;
return self.inputTextView.text.length > 0 ? [self.inputTextView.text copy] : nil;
}

// TODO: Support using object address for strings, as in the object arg view.

#pragma mark -

Expand Down
Loading

0 comments on commit fcf7f91

Please sign in to comment.