Skip to content

Commit fcf7f91

Browse files
author
Les Melnychuk
committed
Merge branch 'master' of https://github.com/Flipboard/FLEX
# Conflicts: # Classes/GlobalStateExplorers/DatabaseBrowser/FLEXSQLiteDatabaseManager.m # Classes/Utility/FLEXKeyboardShortcutManager.m # FLEX.xcodeproj/project.pbxproj
2 parents 660be9a + a6cbfbd commit fcf7f91

File tree

143 files changed

+2581
-1242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+2581
-1242
lines changed

Classes/Core/FLEXScopeCarousel.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ - (id)initWithFrame:(CGRect)frame {
5252
collectionViewLayout:layout
5353
];
5454
cv.showsHorizontalScrollIndicator = NO;
55-
cv.backgroundColor = [UIColor clearColor];
55+
cv.backgroundColor = UIColor.clearColor;
5656
cv.delegate = self;
5757
cv.dataSource = self;
5858
[cv registerClass:[FLEXCarouselCell class] forCellWithReuseIdentifier:kCarouselCellReuseIdentifier];
@@ -68,15 +68,15 @@ - (id)initWithFrame:(CGRect)frame {
6868

6969
// Dynamic type
7070
__weak __typeof(self) weakSelf = self;
71-
_dynamicTypeObserver = [[NSNotificationCenter defaultCenter]
71+
_dynamicTypeObserver = [NSNotificationCenter.defaultCenter
7272
addObserverForName:UIContentSizeCategoryDidChangeNotification
7373
object:nil queue:nil usingBlock:^(NSNotification *note) {
7474
[self.collectionView setNeedsLayout];
7575
[self setNeedsUpdateConstraints];
7676

7777
// Notify observers
7878
__typeof(self) self = weakSelf;
79-
for (void (^block)() in self.dynamicTypeHandlers) {
79+
for (void (^block)(FLEXScopeCarousel *) in self.dynamicTypeHandlers) {
8080
block(self);
8181
}
8282
}
@@ -87,15 +87,15 @@ - (id)initWithFrame:(CGRect)frame {
8787
}
8888

8989
- (void)dealloc {
90-
[[NSNotificationCenter defaultCenter] removeObserver:self.dynamicTypeObserver];
90+
[NSNotificationCenter.defaultCenter removeObserver:self.dynamicTypeObserver];
9191
}
9292

9393
#pragma mark - Overrides
9494

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

98-
CGFloat width = 1.f / [UIScreen mainScreen].scale;
98+
CGFloat width = 1.f / UIScreen.mainScreen.scale;
9999

100100
// Draw hairline
101101
CGContextRef context = UIGraphicsGetCurrentContext();

Classes/Core/FLEXTableViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ extern CGFloat const kFLEXDebounceForExpensiveIO;
8989

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

9494
@end

Classes/Core/FLEXTableViewController.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ - (void)setAutomaticallyShowsSearchBarCancelButton:(BOOL)autoShowCancel {
127127

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

130-
- (void)onBackgroundQueue:(NSArray *(^)())backgroundBlock thenOnMainQueue:(void(^)(NSArray *))mainBlock {
130+
- (void)onBackgroundQueue:(NSArray *(^)(void))backgroundBlock thenOnMainQueue:(void(^)(NSArray *))mainBlock {
131131
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
132132
NSArray *items = backgroundBlock();
133133
dispatch_async(dispatch_get_main_queue(), ^{
@@ -163,9 +163,17 @@ - (void)viewDidAppear:(BOOL)animated {
163163
}
164164
}
165165

166+
- (void)viewDidDisappear:(BOOL)animated {
167+
[super viewDidDisappear:animated];
168+
169+
if (self.searchController.active) {
170+
self.searchController.active = NO;
171+
}
172+
}
173+
166174
#pragma mark - Private
167175

168-
- (void)debounce:(void(^)())block {
176+
- (void)debounce:(void(^)(void))block {
169177
[self.debounceTimer invalidate];
170178

171179
self.debounceTimer = [NSTimer

Classes/Editing/ArgumentInputViews/FLEXArgumentInputColorView.m

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ @protocol FLEXColorComponentInputViewDelegate;
1414

1515
@interface FLEXColorComponentInputView : UIView
1616

17-
@property (nonatomic, strong) UISlider *slider;
18-
@property (nonatomic, strong) UILabel *valueLabel;
17+
@property (nonatomic) UISlider *slider;
18+
@property (nonatomic) UILabel *valueLabel;
1919

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

@@ -34,12 +34,12 @@ - (id)initWithFrame:(CGRect)frame
3434
{
3535
self = [super initWithFrame:frame];
3636
if (self) {
37-
self.slider = [[UISlider alloc] init];
37+
self.slider = [UISlider new];
3838
self.slider.backgroundColor = self.backgroundColor;
3939
[self.slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
4040
[self addSubview:self.slider];
4141

42-
self.valueLabel = [[UILabel alloc] init];
42+
self.valueLabel = [UILabel new];
4343
self.valueLabel.backgroundColor = self.backgroundColor;
4444
self.valueLabel.font = [FLEXUtility defaultFontOfSize:14.0];
4545
self.valueLabel.textAlignment = NSTextAlignmentRight;
@@ -94,9 +94,9 @@ - (CGSize)sizeThatFits:(CGSize)size
9494

9595
@interface FLEXColorPreviewBox : UIView
9696

97-
@property (nonatomic, strong) UIColor *color;
97+
@property (nonatomic) UIColor *color;
9898

99-
@property (nonatomic, strong) UIView *colorOverlayView;
99+
@property (nonatomic) UIView *colorOverlayView;
100100

101101
@end
102102

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

113113
self.colorOverlayView = [[UIView alloc] initWithFrame:self.bounds];
114114
self.colorOverlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
115-
self.colorOverlayView.backgroundColor = [UIColor clearColor];
115+
self.colorOverlayView.backgroundColor = UIColor.clearColor;
116116
[self addSubview:self.colorOverlayView];
117117
}
118118
return self;
@@ -134,12 +134,12 @@ + (UIImage *)backgroundPatternImage
134134
CGSize squareSize = CGSizeMake(kSquareDimension, kSquareDimension);
135135
CGSize imageSize = CGSizeMake(2.0 * kSquareDimension, 2.0 * kSquareDimension);
136136

137-
UIGraphicsBeginImageContextWithOptions(imageSize, YES, [[UIScreen mainScreen] scale]);
137+
UIGraphicsBeginImageContextWithOptions(imageSize, YES, UIScreen.mainScreen.scale);
138138

139-
[[UIColor whiteColor] setFill];
139+
[UIColor.whiteColor setFill];
140140
UIRectFill(CGRectMake(0, 0, imageSize.width, imageSize.height));
141141

142-
[[UIColor grayColor] setFill];
142+
[UIColor.grayColor setFill];
143143
UIRectFill(CGRectMake(squareSize.width, 0, squareSize.width, squareSize.height));
144144
UIRectFill(CGRectMake(0, squareSize.height, squareSize.width, squareSize.height));
145145

@@ -153,12 +153,12 @@ + (UIImage *)backgroundPatternImage
153153

154154
@interface FLEXArgumentInputColorView () <FLEXColorComponentInputViewDelegate>
155155

156-
@property (nonatomic, strong) FLEXColorPreviewBox *colorPreviewBox;
157-
@property (nonatomic, strong) UILabel *hexLabel;
158-
@property (nonatomic, strong) FLEXColorComponentInputView *alphaInput;
159-
@property (nonatomic, strong) FLEXColorComponentInputView *redInput;
160-
@property (nonatomic, strong) FLEXColorComponentInputView *greenInput;
161-
@property (nonatomic, strong) FLEXColorComponentInputView *blueInput;
156+
@property (nonatomic) FLEXColorPreviewBox *colorPreviewBox;
157+
@property (nonatomic) UILabel *hexLabel;
158+
@property (nonatomic) FLEXColorComponentInputView *alphaInput;
159+
@property (nonatomic) FLEXColorComponentInputView *redInput;
160+
@property (nonatomic) FLEXColorComponentInputView *greenInput;
161+
@property (nonatomic) FLEXColorComponentInputView *blueInput;
162162

163163
@end
164164

@@ -168,32 +168,32 @@ - (instancetype)initWithArgumentTypeEncoding:(const char *)typeEncoding
168168
{
169169
self = [super initWithArgumentTypeEncoding:typeEncoding];
170170
if (self) {
171-
self.colorPreviewBox = [[FLEXColorPreviewBox alloc] init];
171+
self.colorPreviewBox = [FLEXColorPreviewBox new];
172172
[self addSubview:self.colorPreviewBox];
173173

174-
self.hexLabel = [[UILabel alloc] init];
174+
self.hexLabel = [UILabel new];
175175
self.hexLabel.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.9];
176176
self.hexLabel.textAlignment = NSTextAlignmentCenter;
177177
self.hexLabel.font = [FLEXUtility defaultFontOfSize:12.0];
178178
[self addSubview:self.hexLabel];
179179

180-
self.alphaInput = [[FLEXColorComponentInputView alloc] init];
181-
self.alphaInput.slider.minimumTrackTintColor = [UIColor blackColor];
180+
self.alphaInput = [FLEXColorComponentInputView new];
181+
self.alphaInput.slider.minimumTrackTintColor = UIColor.blackColor;
182182
self.alphaInput.delegate = self;
183183
[self addSubview:self.alphaInput];
184184

185-
self.redInput = [[FLEXColorComponentInputView alloc] init];
186-
self.redInput.slider.minimumTrackTintColor = [UIColor redColor];
185+
self.redInput = [FLEXColorComponentInputView new];
186+
self.redInput.slider.minimumTrackTintColor = UIColor.redColor;
187187
self.redInput.delegate = self;
188188
[self addSubview:self.redInput];
189189

190-
self.greenInput = [[FLEXColorComponentInputView alloc] init];
191-
self.greenInput.slider.minimumTrackTintColor = [UIColor greenColor];
190+
self.greenInput = [FLEXColorComponentInputView new];
191+
self.greenInput.slider.minimumTrackTintColor = UIColor.greenColor;
192192
self.greenInput.delegate = self;
193193
[self addSubview:self.greenInput];
194194

195-
self.blueInput = [[FLEXColorComponentInputView alloc] init];
196-
self.blueInput.slider.minimumTrackTintColor = [UIColor blueColor];
195+
self.blueInput = [FLEXColorComponentInputView new];
196+
self.blueInput.slider.minimumTrackTintColor = UIColor.blueColor;
197197
self.blueInput.delegate = self;
198198
[self addSubview:self.blueInput];
199199
}

Classes/Editing/ArgumentInputViews/FLEXArgumentInputDateView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@interface FLEXArgumentInputDateView ()
1313

14-
@property (nonatomic, strong) UIDatePicker *datePicker;
14+
@property (nonatomic) UIDatePicker *datePicker;
1515

1616
@end
1717

@@ -21,7 +21,7 @@ - (instancetype)initWithArgumentTypeEncoding:(const char *)typeEncoding
2121
{
2222
self = [super initWithArgumentTypeEncoding:typeEncoding];
2323
if (self) {
24-
self.datePicker = [[UIDatePicker alloc] init];
24+
self.datePicker = [UIDatePicker new];
2525
self.datePicker.datePickerMode = UIDatePickerModeDateAndTime;
2626
// Using UTC, because that's what the NSDate description prints
2727
self.datePicker.calendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];

Classes/Editing/ArgumentInputViews/FLEXArgumentInputFontView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
@interface FLEXArgumentInputFontView ()
1515

16-
@property (nonatomic, strong) FLEXArgumentInputView *fontNameInput;
17-
@property (nonatomic, strong) FLEXArgumentInputView *pointSizeInput;
16+
@property (nonatomic) FLEXArgumentInputView *fontNameInput;
17+
@property (nonatomic) FLEXArgumentInputView *pointSizeInput;
1818

1919
@end
2020

Classes/Editing/ArgumentInputViews/FLEXArgumentInputFontsPickerView.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@interface FLEXArgumentInputFontsPickerView ()
1313

14-
@property (nonatomic, strong) NSMutableArray<NSString *> *availableFonts;
14+
@property (nonatomic) NSMutableArray<NSString *> *availableFonts;
1515

1616
@end
1717

@@ -40,7 +40,7 @@ - (void)setInputValue:(id)inputValue
4040

4141
- (id)inputValue
4242
{
43-
return [self.inputTextView.text length] > 0 ? [self.inputTextView.text copy] : nil;
43+
return self.inputTextView.text.length > 0 ? [self.inputTextView.text copy] : nil;
4444
}
4545

4646
#pragma mark - private
@@ -74,7 +74,7 @@ - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
7474

7575
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
7676
{
77-
return [self.availableFonts count];
77+
return self.availableFonts.count;
7878
}
7979

8080
#pragma mark - UIPickerViewDelegate
@@ -84,7 +84,7 @@ - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forC
8484
UILabel *fontLabel;
8585
if (!view) {
8686
fontLabel = [UILabel new];
87-
fontLabel.backgroundColor = [UIColor clearColor];
87+
fontLabel.backgroundColor = UIColor.clearColor;
8888
fontLabel.textAlignment = NSTextAlignmentCenter;
8989
} else {
9090
fontLabel = (UILabel*)view;

Classes/Editing/ArgumentInputViews/FLEXArgumentInputNumberView.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ - (void)setInputValue:(id)inputValue
3030

3131
- (id)inputValue
3232
{
33-
return [FLEXRuntimeUtility valueForNumberWithObjCType:[self.typeEncoding UTF8String] fromInputString:self.inputTextView.text];
33+
return [FLEXRuntimeUtility valueForNumberWithObjCType:self.typeEncoding.UTF8String fromInputString:self.inputTextView.text];
3434
}
3535

3636
+ (BOOL)supportsObjCType:(const char *)type withCurrentValue:(id)value
@@ -49,7 +49,8 @@ + (BOOL)supportsObjCType:(const char *)type withCurrentValue:(id)value
4949
@(@encode(unsigned long)),
5050
@(@encode(unsigned long long)),
5151
@(@encode(float)),
52-
@(@encode(double))];
52+
@(@encode(double)),
53+
@(@encode(long double))];
5354
});
5455
return type && [primitiveTypes containsObject:@(type)];
5556
}

Classes/Editing/ArgumentInputViews/FLEXArgumentInputObjectView.m

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,22 +195,35 @@ + (FLEXArgInputObjectType)preferredDefaultTypeForObjCType:(const char *)type wit
195195
if (strcmp(type, @encode(id)) != 0) {
196196
BOOL isJSONSerializableType = NO;
197197

198+
// Parse class name out of the string,
199+
// which is in the form `@"ClassName"`
200+
Class cls = NSClassFromString(({
201+
NSString *className = nil;
202+
NSScanner *scan = [NSScanner scannerWithString:@(type)];
203+
NSCharacterSet *allowed = [NSCharacterSet
204+
characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$"
205+
];
206+
207+
// Skip over the @" then scan the name
208+
if ([scan scanString:@"@\"" intoString:nil]) {
209+
[scan scanCharactersFromSet:allowed intoString:&className];
210+
}
211+
212+
className;
213+
}));
214+
198215
// Note: we can't use @encode(NSString) here because that drops
199216
// the class information and just goes to @encode(id).
200-
NSArray *jsonTypes = @[
201-
@(FLEXEncodeClass(NSString)),
202-
@(FLEXEncodeClass(NSNumber)),
203-
@(FLEXEncodeClass(NSArray)),
204-
@(FLEXEncodeClass(NSDictionary)),
205-
@(FLEXEncodeClass(NSMutableString)),
206-
@(FLEXEncodeClass(NSMutableArray)),
207-
@(FLEXEncodeClass(NSMutableDictionary)),
217+
NSArray<Class> *jsonTypes = @[
218+
[NSString class],
219+
[NSNumber class],
220+
[NSArray class],
221+
[NSDictionary class],
208222
];
209223

210224
// Look for matching types
211-
NSString *typeStr = @(type);
212-
for (NSString *encodedClass in jsonTypes) {
213-
if ([typeStr isEqualToString:encodedClass]) {
225+
for (Class jsonClass in jsonTypes) {
226+
if ([cls isSubclassOfClass:jsonClass]) {
214227
isJSONSerializableType = YES;
215228
break;
216229
}

Classes/Editing/ArgumentInputViews/FLEXArgumentInputStringView.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ - (id)inputValue
2929
{
3030
// Interpret empty string as nil. We loose the ability to set empty string as a string value,
3131
// but we accept that tradeoff in exchange for not having to type quotes for every string.
32-
return [self.inputTextView.text length] > 0 ? [self.inputTextView.text copy] : nil;
32+
return self.inputTextView.text.length > 0 ? [self.inputTextView.text copy] : nil;
3333
}
3434

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

3637
#pragma mark -
3738

0 commit comments

Comments
 (0)